Skip to content

Commit

Permalink
improve tests and docs for delay-system inversion
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Dec 4, 2023
1 parent 66e1475 commit bd74b9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
15 changes: 9 additions & 6 deletions lib/ControlSystemsBase/src/types/DelayLtiSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,16 @@ function +(sys::DelayLtiSystem{T1,S}, n::T2) where {T1,T2<:Number,S}
end


"""
/(G1, G2::DelayLtiSystem)
Compute ``G_1 * G_2^{-1} where ``G_2`` is a DelayLtiSystem.
Throws a SingularException if ``G_2`` is not invertible.
"""
function /(anything, sys::DelayLtiSystem)
if !all(iszero, sys.Tau)
ny,nu = size(sys)
ny == nu || error("The denominator system must be square")
return anything * feedback(I(nu), sys - I(nu))
end
/(anything, sys.P.P) # If all delays are zero, invert the inner system
ny,nu = size(sys)
ny == nu || error("The denominator system must be square")
return anything * feedback(I(nu), sys - I(nu))
end

for other_type in [:Number, :AbstractMatrix, :LTISystem]
Expand Down
7 changes: 4 additions & 3 deletions lib/ControlSystemsBase/test/test_delayed_systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ w = 10 .^ (-2:0.1:2)

@test propertynames(delay(1.0)) == (:P, :Tau, :nu, :ny)

@test_throws ErrorException 1/f2
@test_throws ErrorException randn(2,2)/f2
@test_throws ErrorException f2/f2
@test_throws SingularException 1/f2
@test_throws SingularException randn(2,2)/f2
@test_throws SingularException f2/f2
@test 1/(I(2)+f2) == feedback(I(2), f2)

#FIXME: A lot more tests, including MIMO systems in particular

Expand Down

0 comments on commit bd74b9a

Please sign in to comment.