Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make balance_statespace work for more system types #837

Merged
merged 3 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
mention balancing in simulation section as well
  • Loading branch information
baggepinnen committed May 12, 2023
commit 5e121f57748f4e0e503ed3f354aa72d91fbdd144
2 changes: 2 additions & 0 deletions docs/src/man/numerical.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,5 @@ Linear systems with zero-order-hold inputs can be exactly simulated in discrete

For discrete-time systems, the function [`lsim!`](@ref) accepts a pre-allocated workspace objects that can be used to avoid allocations for repeated simulations.

### Numerical balancing
If you are only interested in the simulated outputs, not the state trajectories, you may consider applying balancing to the statespace model using [`balance_statespace`](@ref) before simulating, see the section on [State-space balancing](@ref) above. If the state trajectories are of interest, balancing can still be performed before simulation, and the inverse transformation applied to the state trajectories after simulation.
2 changes: 1 addition & 1 deletion lib/ControlSystemsBase/src/types/conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ end
function balance_statespace(sys::AbstractStateSpace, perm::Bool=false)
A, B, C, T = balance_statespace(sys.A,sys.B,sys.C, perm)

return basetype(sys)(A,B,C,sys.D, ntuple(i->getfield(sys, i+4), fieldcount(T)-4)...), T
return basetype(sys)(A,B,C,sys.D, ntuple(i->getfield(sys, i+4), fieldcount(sys)-4)...), T
end

# Method that might fail for some exotic types, such as TrackedArrays
Expand Down
Loading