@@ -49,7 +49,7 @@ function Base.promote_rule(::Type{N}, ::Type{δ{C, F}}) where {N <: Number, F, C
4949 δ{promote_type (N, C), promote_type (N, F)}
5050end
5151
52- Base. convert (:: Type{δ{C, F}} , n:: Number ) where {C,F} = δ (n, 0.0 )
52+ Base. convert (:: Type{δ{C, F}} , n:: Number ) where {C,F} = δ (C (n), zero (F) )
5353Base. convert (:: Type{δ{C, F}} , d: :δ ) where {C,F} = δ (C (d. val), F (d. radius), d. name)
5454
5555# + and - we define here, all other ops generate ExtendedStateSpace. THis is to avoid creating a complicated tagging mechanism
@@ -140,16 +140,16 @@ for f in [:system_mapping, :performance_mapping, :ss]
140140 @eval $ f (s:: UncertainSS , args... ; kwargs... ) = $ f (s. sys, args... ; kwargs... )
141141end
142142
143- function Base. promote_rule (:: Type{U} , :: Type{δ{C, F}} ) where {U <: UncertainSS , F, C}
144- UncertainSS
143+ function Base. promote_rule (:: Type{UncertainSS{TE}} , :: Type{δ{C, F}} ) where {TE , F, C}
144+ UncertainSS{TE}
145145end
146146
147- function Base. promote_rule (:: Type{U} , :: Type{L} ) where {U <: UncertainSS , L <: LTISystem }
148- UncertainSS
147+ function Base. promote_rule (:: Type{UncertainSS{TE}} , :: Type{L} ) where {TE , L <: LTISystem }
148+ UncertainSS{TE}
149149end
150150
151- function Base. promote_rule (:: Type{U} , :: Type{L} ) where {U <: UncertainSS , L <: AbstractArray }
152- UncertainSS
151+ function Base. promote_rule (:: Type{UncertainSS{TE}} , :: Type{L} ) where {TE , L <: AbstractArray }
152+ UncertainSS{TE}
153153end
154154
155155function Base. convert (:: Type{U} , d: :δ ) where {U <: UncertainSS }
@@ -206,8 +206,12 @@ Create a diagonal uncertain statespace object with the uncertain elements `d` on
206206function uss (d:: AbstractVector{<:δ} , Ts = nothing )
207207 vals = getfield .(d, :val )
208208 rads = getfield .(d, :radius )
209+ nonzero = rads .> 0
210+ # vals = vals
211+ # rads = rads
212+ nd = count (nonzero)
209213 n = length (d)
210- uss (0 I (n ), I (n), diagm (rads), diagm (vals), normalize .(d), Ts)
214+ uss (0 I (nd ), I (n)[nonzero, :], diagm (rads)[:, nonzero], diagm (vals), normalize .(d[nonzero] ), Ts)
211215end
212216
213217uss (n:: Number , Ts= nothing ) = uss (zeros (0 ,0 ), zeros (0 ,1 ), zeros (1 ,0 ), 1 , [], Ts)
@@ -336,11 +340,12 @@ function ControlSystems.lft(G::UncertainSS, Δ::AbstractArray=G.Δ, type=:u)
336340end
337341
338342function ControlSystems. lft (G:: UncertainSS , K:: LTISystem , type= :l )
339- if type != = :l
340- error ( " Invalid type of lft ( $type ), specify type=:l " )
343+ if type === :u
344+ sys = lft ( ss (G . sys), ss (K ), :u )
341345 else
346+ nu1, ny1 = G. nw, G. nz
342347 sys = lft (ss (G. sys), ss (K), :l )
343- sys = partition (sys, sys . nu, sys . nu )
348+ sys = partition (sys, nu1, ny1 )
344349 UncertainSS (sys, G. Δ)
345350 end
346351end
0 commit comments