Skip to content

Commit 79e4654

Browse files
authored
Merge pull request #1030 from JuliaControl/det
system determinant
2 parents 76e6490 + 2a51c27 commit 79e4654

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

docs/src/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ The following is a list of packages from the wider Julia ecosystem that may be o
8484
- [DescriptorSystems.jl](https://github.com/andreasvarga/DescriptorSystems.jl) contains types that represent statespace systems on descriptor form, i.e., with a mass matrix. These systems can represent linear DAE systems and non-proper systems.
8585
- [LowLevelParticleFilters.jl](https://github.com/baggepinnen/LowLevelParticleFilters.jl) is a library for state estimation using particle filters and Kalman filters of different flavors.
8686
- [ModelingToolkit.jl](https://mtk.sciml.ai/stable/) is an acausal modeling tool, similar in spirit to Modelica. A video showing ControlSystems and ModelingToolkit together is [available here](https://youtu.be/favQKOyyx4o). [ControlSystemsMTK.jl](https://juliacontrol.github.io/ControlSystemsMTK.jl/dev/) exists to ease the use of these two packages together.
87-
- [JuliaSimControl.jl](https://help.juliahub.com/juliasimcontrol/dev/) is a product that builds upon the JuliaControl ecosystem and ModelingToolkit, providing additional nonlinear and robust control methods.
87+
- [DyadControlSystems.jl](https://help.juliahub.com/dyadcontrol/dev/) is a product that builds upon the JuliaControl ecosystem and ModelingToolkit, providing additional nonlinear and robust control methods.
88+
- [LinearMPC.jl](https://darnstrom.github.io/LinearMPC.jl/stable/) A package for linear quadratic MPC that supports generation of embeddable C-code for real-time applications.
8889
- [FaultDetectionTools.jl](https://github.com/andreasvarga/FaultDetectionTools.jl) contains utilities and observers for online fault detection.
8990
- [ReachabilityAnalysis.jl](https://juliareach.github.io/ReachabilityAnalysis.jl/dev/generated_examples/Building/) is a package for reachability analysis. This can be used to verify stability and safety properties of linear and nonlinear systems.
9091
- [MatrixEquations.jl](https://github.com/andreasvarga/MatrixEquations.jl) contains solvers for many different matrix equations common in control. ControlSystems.jl makes use of this package for solving Riccati and Lyapunov equations.

lib/ControlSystemsBase/src/matrix_comps.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,4 +1019,13 @@ end
10191019

10201020
function observer_filter(sys::AbstractStateSpace{Continuous}, K::AbstractMatrix; kwargs...)
10211021
observer_predictor(sys, K; kwargs...)
1022-
end
1022+
end
1023+
1024+
function LinearAlgebra.det(sys::LTISystem)
1025+
sys = deepcopy(sys)
1026+
arrayofsys = getindex.(Ref(sys), 1:sys.ny, (1:sys.nu)')
1027+
if sys isa AbstractStateSpace
1028+
@. arrayofsys = sminreal(arrayofsys)
1029+
end
1030+
LinearAlgebra.det_bareiss!(arrayofsys)
1031+
end

lib/ControlSystemsBase/src/types/StateSpace.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ Base.zero(sys::AbstractStateSpace) = basetype(sys)(zero(sys.D), sys.timeevol)
265265
Base.zero(::Type{StateSpace{Continuous, F}}) where {F} = ss([zero(F)], Continuous())
266266
Base.zero(::Type{StateSpace{D, F}}) where {D<:Discrete, F} = ss([zero(F)], undef_sampletime(D))
267267

268+
# one is a multiplicative identity, which can be set to the one of the element type. This is different from oneunit which should be of the same type.
269+
Base.one(::Type{StateSpace{TE, T}}) where {TE, T} = Base.one(T)
270+
271+
268272
function +(s1::ST, s2::ST) where {ST <: AbstractStateSpace}
269273
#Ensure systems have same dimensions
270274
if size(s1) != size(s2)

lib/ControlSystemsBase/test/test_matrix_comps.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ sysr, G = balreal(sys)
1111
@test gram(sysr, :o) diagm(G)
1212
@test sort(poles(sysr), by=real) sort(poles(sys), by=real)
1313

14+
@testset "det" begin
15+
detsys = det(sys)
16+
w = 0.1
17+
@test freqresp(detsys, w)[1] det(freqresp(sys, w))
18+
end
19+
1420
sysb,T = ControlSystemsBase.balance_statespace(sys)
1521
@test similarity_transform(sysb, T) sys
1622
Ab,Bb,Cb,T = ControlSystemsBase.balance_statespace(A,B,C)

0 commit comments

Comments
 (0)