Skip to content

Commit a141260

Browse files
committed
perform (optional) balancing before minreal
1 parent c2ade34 commit a141260

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/ControlSystemsBase/src/types/StateSpace.jl

+5-2
Original file line numberDiff line numberDiff line change
@@ -595,20 +595,23 @@ end
595595

596596

597597
"""
598-
minreal(sys::StateSpace; fast=false, kwargs...)
598+
minreal(sys::StateSpace; fast=false, balance=true, kwargs...)
599599
600600
Minimal realisation algorithm from P. Van Dooreen, The generalized eigenstructure problem in linear system theory, IEEE Transactions on Automatic Control
601601
602602
For information about the options, see `?ControlSystemsBase.MatrixPencils.lsminreal`
603603
604604
See also [`sminreal`](@ref), which is both numerically exact and substantially faster than `minreal`, but with a much more limited potential in removing non-minimal dynamics.
605605
"""
606-
function minreal(sys::T, tol=nothing; fast=false, atol=0.0, kwargs...) where T <: AbstractStateSpace
606+
function minreal(sys::T, tol=nothing; fast=false, atol=0.0, balance=true, kwargs...) where T <: AbstractStateSpace
607607
A,B,C,D = ssdata(sys)
608608
if tol !== nothing
609609
atol == 0 || atol == tol || error("Both positional argument `tol` and keyword argument `atol` were set but were not equal. `tol` is provided for backwards compat and can not be set to another value than `atol`.")
610610
atol = tol
611611
end
612+
if balance
613+
A,B,C,_ = balance_statespace(A,B,C)
614+
end
612615
Ar, Br, Cr = MatrixPencils.lsminreal(A,B,C; atol, fast, kwargs...)
613616
if hasfield(T, :sys)
614617
basetype(T)(ss(Ar,Br,Cr,D), ntuple(i->getfield(sys, i+1), fieldcount(T)-1)...)

0 commit comments

Comments
 (0)