Skip to content

Commit

Permalink
export balance_statespace (#609)
Browse files Browse the repository at this point in the history
- add test
- fix docstring
  • Loading branch information
baggepinnen authored Jan 25, 2022
1 parent 04cef38 commit 094983a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/ControlSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export LTISystem,
isproper,
# Linear Algebra
balance,
balance_statespace,
care,
dare,
dlyap,
Expand Down
9 changes: 5 additions & 4 deletions src/types/conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,16 @@ function siso_tf_to_ss(T::Type, f::SisoRational)
end

"""
`A, B, C, T = balance_statespace{S}(A::Matrix{S}, B::Matrix{S}, C::Matrix{S}, perm::Bool=false)`
`sys, T = balance_statespace(sys::StateSpace, perm::Bool=false)`
A, B, C, T = balance_statespace{S}(A::Matrix{S}, B::Matrix{S}, C::Matrix{S}, perm::Bool=false)
sys, T = balance_statespace(sys::StateSpace, perm::Bool=false)
Computes a balancing transformation `T` that attempts to scale the system so
that the row and column norms of [T*A/T T*B; C/T 0] are approximately equal.
If `perm=true`, the states in `A` are allowed to be reordered.
This is not the same as finding a balanced realization with equal and diagonal observability and reachability gramians, see `balreal`
The inverse of `sysb, T = balance_statespace(sys)` is given by `similarity_transform(sysb, T)`
This is not the same as finding a balanced realization with equal and diagonal observability and reachability gramians, see [`balreal`](@ref)
"""
function balance_statespace(A::AbstractMatrix, B::AbstractMatrix, C::AbstractMatrix, perm::Bool=false)
try
Expand Down
1 change: 1 addition & 0 deletions test/test_matrix_comps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sysr, G = balreal(sys)
@test sort(poles(sysr)) sort(poles(sys))

sysb,T = ControlSystems.balance_statespace(sys)
@test similarity_transform(sysb, T) sys
Ab,Bb,Cb,T = ControlSystems.balance_statespace(A,B,C)

@test Ab*T T*A
Expand Down

0 comments on commit 094983a

Please sign in to comment.