-
Notifications
You must be signed in to change notification settings - Fork 40
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
collapse nested SubArray and OffsetArray #109
Comments
Doesn't look good to me since |
Hm, I see your point, but that's also, I'd say, the point of collapsing. The ssa = SubArray(sa, (1:3, 1:3))
ssa2= view(sa, 1:3, 1:3) julia> ssa
3×3 view(view(::Array{Float64,2}, 1:3, 1:3), 1:3, 1:3) with eltype Float64:
1.0 5.0 9.0
2.0 6.0 10.0
3.0 7.0 11.0
julia> ssa2
3×3 view(::Array{Float64,2}, 1:3, 1:3) with eltype Float64:
1.0 5.0 9.0
2.0 6.0 10.0
3.0 7.0 11.0
julia> parent(ssa)
3×3 view(::Array{Float64,2}, 1:3, 1:3) with eltype Float64:
1.0 5.0 9.0
2.0 6.0 10.0
3.0 7.0 11.0
julia> parent(ssa2)
4×4 Array{Float64,2}:
1.0 5.0 9.0 13.0
2.0 6.0 10.0 14.0
3.0 7.0 11.0 15.0
4.0 8.0 12.0 16.0 |
This looks like a similar case to JuliaLang/julia#26872 so it might be good to have. @timholy how do you think of this? |
This does have some unexpected consequences julia> sosa3 = @view osa[Base.IdentityUnitRange(11:12), Base.IdentityUnitRange(11:12)]
2×2 view(::Array{Float64,2}, 1:2, 1:2) with eltype Float64:
1.0 5.0
2.0 6.0
julia> axes(sosa3)
(Base.OneTo(2), Base.OneTo(2)) This breaks the rule that if julia> axes(osa[Base.IdentityUnitRange(11:12), Base.IdentityUnitRange(11:12)])
(11:12, 11:12)
julia> axes(@view osa[Base.IdentityUnitRange(11:12), Base.IdentityUnitRange(11:12)])
(Base.OneTo(2), Base.OneTo(2)) This needs some more thinking |
The
map
and splat is probably not great for performance. Other than that, does this seem like a reasonable idea?The text was updated successfully, but these errors were encountered: