Skip to content

Commit 83f8051

Browse files
committed
allow scaling with number to change element type
1 parent e197d7d commit 83f8051

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/named_systems2.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,9 @@ function Base.:*(s1::NamedStateSpace{T}, s2::NamedStateSpace{T}) where {T <: CS.
432432
end
433433

434434
function Base.:*(s1::Number, s2::NamedStateSpace{T, S}) where {T <: CS.TimeEvolution, S}
435-
return NamedStateSpace{T,S}(
436-
s1*s2.sys,
435+
s3 = s1*s2.sys
436+
return NamedStateSpace{T, typeof(s3)}(
437+
s3,
437438
s2.x,
438439
s2.u,
439440
[Symbol(string(y)*"_scaled") for y in s2.y],
@@ -443,8 +444,9 @@ function Base.:*(s1::Number, s2::NamedStateSpace{T, S}) where {T <: CS.TimeEvolu
443444
end
444445

445446
function Base.:*(s1::NamedStateSpace{T, S}, s2::Number) where {T <: CS.TimeEvolution, S}
446-
return NamedStateSpace{T,S}(
447-
s1.sys*s2,
447+
s3 = s1.sys*s2
448+
return NamedStateSpace{T,typeof(s3)}(
449+
s3,
448450
s1.x,
449451
[Symbol(string(u)*"_scaled") for u in s1.u],
450452
s1.y,

test/test_named_systems2.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ s2 = named_ss(G2, x = [:z], u = [:u2], y=[:y2])
104104

105105
s11 = s1*s1
106106
@test allunique(s11.x)
107+
108+
@test ControlSystemsBase.numeric_type(big(1.0)*s1) <: BigFloat
109+
@test ControlSystemsBase.numeric_type(s1*big(1.0)) <: BigFloat
107110
end
108111

109112
@testset "Concatenation" begin

0 commit comments

Comments
 (0)