Skip to content

Commit 066b0c8

Browse files
authored
fix promotion of discrete time evolution (#131)
2 parents 6cfce82 + ab22491 commit 066b0c8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/named_systems2.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function Base.convert(::Type{NamedStateSpace{T, S}}, s::U) where {T, S <: Abstra
105105
end
106106

107107
function Base.convert(::Type{NamedStateSpace{T, S}}, M::AbstractMatrix) where {T, S <: AbstractStateSpace}
108-
te = T <: Discrete ? Discrete(ControlSystemsBase.UNDEF_SAMPLEPETIME) : Continuous()
108+
te = T <: Discrete ? T(Discrete(ControlSystemsBase.UNDEF_SAMPLEPETIME)) : Continuous()
109109
NT = numeric_type(S)
110110
named_ss(ss(NT.(M), te), x = gensym("x"), u = gensym("u"), y = gensym("y"))
111111
end
@@ -121,7 +121,7 @@ function Base.convert(::Type{NamedStateSpace{T, S}}, s::U) where {T, S <: Abstra
121121
end
122122

123123
function Base.convert(::Type{NamedStateSpace{T, S}}, N::Number) where {T, S <: AbstractStateSpace}
124-
te = T <: Discrete ? Discrete(ControlSystemsBase.UNDEF_SAMPLEPETIME) : Continuous()
124+
te = T <: Discrete ? T(Discrete(ControlSystemsBase.UNDEF_SAMPLEPETIME)) : Continuous()
125125
NT = numeric_type(S)
126126
named_ss(tf(NT(N), te), x = gensym("x"), u = gensym("u"), y = gensym("y"))
127127
end

test/test_named_systems2.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,4 +499,9 @@ isys = inv(s1)
499499

500500
isys = 2/s1
501501
@test isys.sys == 2/s1.sys
502-
@test isys.x != s1.x
502+
@test isys.x != s1.x
503+
504+
# Test https://github.com/JuliaControl/RobustAndOptimalControl.jl/issues/130
505+
P = named_ss(ssrand(1,1,2, Ts=1.0))
506+
C = named_ss(ssrand(1,1,2, Ts=1.0))
507+
@test gangoffour(P, C) isa NTuple{4, NamedStateSpace{Discrete{Float64}, StateSpace{Discrete{Float64}, Float64}}}

0 commit comments

Comments
 (0)