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

fixed promotion for delay systems #506

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 1 addition & 4 deletions src/delay_systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function lsim(sys::DelayLtiSystem{T,S}, u, t::AbstractArray{<:Real};
(out, t) -> (out .= u(t))
end

_lsim(sys, u!, t, x0, alg; abstol=abstol, reltol=reltol, kwargs...)
_lsim(sys, u!, t, x0, alg; abstol, reltol, kwargs...)
end

# Generic parametrized dde used for simulating DelayLtiSystem
Expand Down Expand Up @@ -160,9 +160,6 @@ function _lsim(sys::DelayLtiSystem{T,S}, Base.@nospecialize(u!), t::AbstractArra

P = sys.P

t0 = first(t)
dt = t[2] - t[1]

# Get all matrices to save on allocations
A, B1, B2, C1, C2, D11, D12, D21, D22 = P.A, P.B1, P.B2, P.C1, P.C2, P.D11, P.D12, P.D21, P.D22
Tau = sys.Tau
Expand Down
6 changes: 3 additions & 3 deletions src/types/DelayLtiSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ DelayLtiSystem(sys::TransferFunction{TE,S}) where {TE,T,S<:SisoTf{T}} = DelayLti
Base.promote_rule(::Type{AbstractMatrix{T1}}, ::Type{DelayLtiSystem{T2,S}}) where {T1<:Number,T2<:Number,S} = DelayLtiSystem{promote_type(T1,T2),S}
Base.promote_rule(::Type{T1}, ::Type{DelayLtiSystem{T2,S}}) where {T1<:Number,T2<:Number,S} = DelayLtiSystem{promote_type(T1,T2),S}

Base.promote_rule(::Type{<:StateSpace{<:TimeEvolution,T1}}, ::Type{DelayLtiSystem{T2,S}}) where {T1,T2,S} = DelayLtiSystem{promote_type(T1,T2),S}
Base.promote_rule(::Type{<:TransferFunction}, ::Type{DelayLtiSystem{T,S}}) where {T,S} = DelayLtiSystem{T,S}
Base.promote_rule(::Type{<:StateSpace{Continuous,T1}}, ::Type{DelayLtiSystem{T2,S}}) where {T1,T2,S} = DelayLtiSystem{promote_type(T1,T2),S}
Base.promote_rule(::Type{<:TransferFunction{Continuous,S1}}, ::Type{DelayLtiSystem{T2,S2}}) where {T1,S1<:SisoTf{T1},T2,S2} = DelayLtiSystem{promote_type(T1,T2),S2}
#Base.promote_rule(::Type{<:UniformScaling}, ::Type{S}) where {S<:DelayLtiSystem} = DelayLtiSystem{T,S}

function Base.convert(::Type{DelayLtiSystem{T,S}}, sys::StateSpace) where {T,S}
Expand Down Expand Up @@ -104,7 +104,7 @@ end
# Efficient subtraction with number
-(sys::DelayLtiSystem, n::T) where {T <:Number} = +(sys, -n)
-(n::T, sys::DelayLtiSystem) where {T <:Number} = +(-sys, n)
function /(anything, sys::DelayLtiSystem)
function /(::LTISystem, sys::DelayLtiSystem)
all(iszero, sys.Tau) || error("A delayed system can not be inverted. Consider use of the function `feedback`.")
/(anything, sys.P.P) # If all delays are zero, invert the inner system
end
Expand Down