From 5c2d251c7dbde1ed44b300e0f6cec1e36e8ed627 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Mon, 28 Apr 2025 08:24:16 +0200 Subject: [PATCH] implement `typed_hvcat` for LTI systems --- lib/ControlSystemsBase/Project.toml | 2 +- lib/ControlSystemsBase/src/connections.jl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/ControlSystemsBase/Project.toml b/lib/ControlSystemsBase/Project.toml index 6a41efee5..a867e7203 100644 --- a/lib/ControlSystemsBase/Project.toml +++ b/lib/ControlSystemsBase/Project.toml @@ -2,7 +2,7 @@ name = "ControlSystemsBase" uuid = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e" authors = ["Dept. Automatic Control, Lund University"] repo = "https://github.com/JuliaControl/ControlSystems.jl.git" -version = "1.14.6" +version = "1.14.7" [deps] ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" diff --git a/lib/ControlSystemsBase/src/connections.jl b/lib/ControlSystemsBase/src/connections.jl index 3434e2fae..3c0a85405 100644 --- a/lib/ControlSystemsBase/src/connections.jl +++ b/lib/ControlSystemsBase/src/connections.jl @@ -134,6 +134,19 @@ end function Base.typed_hcat(::Type{T}, X...) where {T<:LTISystem} hcat(convert.(T, X)...) end + +# This method is copied from Base on julia v1.11, it was changed in v1.12, but we rely on it to create a MIMO transfer function +function Base.typed_hvcat(::Type{T}, rows::Tuple{Vararg{Int}}, as...) where {T<:LTISystem} + nbr = length(rows) # number of block rows + rs = Vector{Any}(undef, nbr) + a = 1 + for i = 1:nbr + rs[i] = Base.typed_hcat(T, as[a:a-1+rows[i]]...) + a += rows[i] + end + T[rs...;] +end + # Ambiguity Base.typed_hcat(::Type{S}, X::Number...) where {S<:LTISystem} = hcat(convert.(S, X)...) Base.typed_hcat(::Type{S}, X::Union{AbstractArray{<:Number,1}, AbstractArray{<:Number,2}}...) where {S<:LTISystem} = hcat(convert.(S, X)...)