-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Describe the problem
After https://github.com/JuliaDynamics/StateSpaceSets.jl/pull/32/files was merged, hcat is incredibly slow when horizontally concatenating. This is true for both Vector{<:Real} with StateSpaceSets. The operation allocates excessively and is very slow.
The hcat I had implemented before the PR was pretty fast, so I think we should just bring that back in new wrapping, so that it works for any container type.
Minimal Working Example
Illustrative example:
julia> using StateSpaceSets
julia> x = rand(10); y = rand(10, 2) |> StateSpaceSet; z = rand(10) |> StateSpaceSet;
julia> hcat(x, y, z); hcat(x, Matrix(x), Matrix(z));
Julia> using BenchmarkTools
julia> @btime hcat($x, $y, $z);
18.833 μs (341 allocations: 10.98 KiB)
julia> @btime hcat($x, $(Matrix(y)), $(Matrix(z)));
28.991 ns (2 allocations: 416 bytes)hcat with state space sets is 650 times slower than hcat on matrices, which of course will have huge impacts in any code that relies on horizontal concatenation of state space sets (e.g. in Associations.jl).
Package versions
I'm using StateSpaceSets 2.3.0, but this is likely the case on all version following the PR linked above.