Skip to content

Commit

Permalink
Merge pull request #956 from JuliaControl/typeissues
Browse files Browse the repository at this point in the history
avoid some type issues arising with Symbolics
  • Loading branch information
baggepinnen authored Jan 16, 2025
2 parents eb34756 + f68bf1c commit b41dde4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions lib/ControlSystemsBase/src/types/StateSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,13 @@ function StateSpace(D::AbstractArray{T}, timeevol::TimeEvolution) where {T<:Numb
A = zeros(T, 0, 0)
B = zeros(T, 0, nu)
C = zeros(T, ny, 0)
D = reshape(D, (ny,nu))
return StateSpace(A, B, C, D, timeevol)
end
StateSpace(D::AbstractArray, Ts::Number) = StateSpace(D, Discrete(Ts))
StateSpace(D::AbstractArray) = StateSpace(D, Continuous())

StateSpace(d::Number, Ts::Number; kwargs...) = StateSpace([d], Discrete(Ts))
StateSpace(d::Number; kwargs...) = StateSpace([d], Continuous())
StateSpace(d::Number, Ts::Number; kwargs...) = StateSpace([d;;], Discrete(Ts))
StateSpace(d::Number; kwargs...) = StateSpace([d;;], Continuous())


# StateSpace(sys) converts to StateSpace
Expand Down
3 changes: 2 additions & 1 deletion lib/ControlSystemsBase/src/types/conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ Base.convert(::Type{StateSpace}, s::HeteroStateSpace) = StateSpace(s.A, s.B, s.C
Base.convert(::Type{StateSpace}, s::HeteroStateSpace{Continuous}) = StateSpace(s.A, s.B, s.C, s.D)

function Base.convert(::Type{StateSpace}, G::TransferFunction{TE,<:SisoTf{T0}}; kwargs...) where {TE,T0<:Number}
T = Base.promote_op(/,T0,T0)
ONE = one(T0)
T = typeof(ONE/ONE)
convert(StateSpace{TE,T}, G; kwargs...)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/ControlSystemsBase/src/types/zpk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ function zpk(G::TransferFunction{TE,S}) where {TE<:TimeEvolution,T0, S<:SisoTf{T
convert(TransferFunction{TE,SisoZpk{T, complex(T)}}, G)
end

zpk(var::AbstractString) = zpk(tf(var))
zpk(var::AbstractString, Ts::Real) = zpk(tf(var, Ts))
zpk(var::Union{AbstractString, Char}) = zpk(tf(var))
zpk(var::Union{AbstractString, Char}, Ts::Real) = zpk(tf(var, Ts))

# Catch all 3(4) argument versions
zpk(z, p, k, Ts::Number) = zpk(z, p, k, Discrete(Ts))
Expand Down

0 comments on commit b41dde4

Please sign in to comment.