From 83f80515764a0579cdde9cc5151d2bb556898ac1 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Tue, 24 Jun 2025 06:17:59 +0200 Subject: [PATCH] allow scaling with number to change element type --- src/named_systems2.jl | 10 ++++++---- test/test_named_systems2.jl | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/named_systems2.jl b/src/named_systems2.jl index a06d54e7..72e10136 100644 --- a/src/named_systems2.jl +++ b/src/named_systems2.jl @@ -432,8 +432,9 @@ function Base.:*(s1::NamedStateSpace{T}, s2::NamedStateSpace{T}) where {T <: CS. end function Base.:*(s1::Number, s2::NamedStateSpace{T, S}) where {T <: CS.TimeEvolution, S} - return NamedStateSpace{T,S}( - s1*s2.sys, + s3 = s1*s2.sys + return NamedStateSpace{T, typeof(s3)}( + s3, s2.x, s2.u, [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 end function Base.:*(s1::NamedStateSpace{T, S}, s2::Number) where {T <: CS.TimeEvolution, S} - return NamedStateSpace{T,S}( - s1.sys*s2, + s3 = s1.sys*s2 + return NamedStateSpace{T,typeof(s3)}( + s3, s1.x, [Symbol(string(u)*"_scaled") for u in s1.u], s1.y, diff --git a/test/test_named_systems2.jl b/test/test_named_systems2.jl index 4cbf9414..20a9b95b 100644 --- a/test/test_named_systems2.jl +++ b/test/test_named_systems2.jl @@ -104,6 +104,9 @@ s2 = named_ss(G2, x = [:z], u = [:u2], y=[:y2]) s11 = s1*s1 @test allunique(s11.x) + + @test ControlSystemsBase.numeric_type(big(1.0)*s1) <: BigFloat + @test ControlSystemsBase.numeric_type(s1*big(1.0)) <: BigFloat end @testset "Concatenation" begin