HybridArrays.jl
HybridArrays.jl copied to clipboard
slices along fixed dimensions
I often want to do something like:
julia> A = HybridArray{Tuple{2,4,StaticArrays.Dynamic()}}(fill(0.0, 2, 4, 3));
julia> v = view(A,:,StaticArrays.SUnitRange(2,3),:)
2×2×3 view(::HybridArray{Tuple{2,4,StaticArrays.Dynamic()},Float64,3,3,Array{Float64,3}}, :, [2, 3], :) with eltype Float64 with indices SOneTo(2)×SOneTo(2)×Base.OneTo(3):
[:, :, 1] =
0.0 0.0
0.0 0.0
[:, :, 2] =
0.0 0.0
0.0 0.0
[:, :, 3] =
0.0 0.0
0.0 0.0
Is it possible to make this return a SizedArray?
Is it possible to make this return a
SizedArray?
Or I guess it should be a HybridArray?
That looks possible, and I think it should return HybridArray. I will try to add it.
When all dynamically sized axes are set to a fixed size (by indexing using SOneTo or some SizedVector like SUnitRange), then views should return SizedArray, otherwise a HybridArray will be returned. I didn't need that case before but that turned out to be simple to add. As a bonus I noticed a small problem with handling SUnitRange so that will be fixed as well :slightly_smiling_face: .