Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slices along fixed dimensions #31

Open
simonbyrne opened this issue Jan 6, 2021 · 3 comments
Open

slices along fixed dimensions #31

simonbyrne opened this issue Jan 6, 2021 · 3 comments

Comments

@simonbyrne
Copy link
Contributor

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?

@simonbyrne
Copy link
Contributor Author

Is it possible to make this return a SizedArray?

Or I guess it should be a HybridArray?

@mateuszbaran
Copy link
Collaborator

That looks possible, and I think it should return HybridArray. I will try to add it.

@mateuszbaran
Copy link
Collaborator

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 🙂 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants