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

StackOverFlow Error #106

Open
putianyi889 opened this issue Feb 19, 2021 · 4 comments
Open

StackOverFlow Error #106

putianyi889 opened this issue Feb 19, 2021 · 4 comments

Comments

@putianyi889
Copy link
Contributor

julia> A=BlockBandedMatrix(Zeros(1,1),[1],[1],(0,0))
1×1-blocked 1×1 BlockSkylineMatrix{Float64,Array{Float64,1},BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}},Fill{Int64,1,Tuple{Base.OneTo{Int64}}},Fill{Int64,1,Tuple{Base.OneTo{Int64}}},BandedMatrices.BandedMatrix{Int64,Array{Int64,2},Base.OneTo{Int64}},Array{Int64,1}}}:
 0.0

julia> A[Block(1)]
ERROR: StackOverflowError:
Stacktrace:
 [1] view(::BlockSkylineMatrix{Float64,Array{Float64,1},BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}},Fill{Int64,1,Tuple{Base.OneTo{Int64}}},Fill{Int64,1,Tuple{Base.OneTo{Int64}}},BandedMatrices.BandedMatrix{Int64,Array{Int64,2},Base.OneTo{Int64}},Array{Int64,1}}}, ::Block{1,Int64}) at C:\Users\pty\.julia\packages\BlockArrays\g01fJ\src\abstractblockarray.jl:129 (repeats 79984 times)

An error is expected, but not stack overflow maybe?

@dlfivefifty
Copy link
Member

Same as JuliaArrays/BlockArrays.jl#120

would love a PR fixing this

@putianyi889
Copy link
Contributor Author

putianyi889 commented Feb 20, 2021

What does this code serve for? In which case does the right hand side not refer back again?

@inline @propagate_inbounds Base.view(block_arr::AbstractBlockArray, block::Block{1}...) = view(block_arr, Block(block))

https://github.com/JuliaArrays/BlockArrays.jl/blob/master/src/abstractblockarray.jl#L129

@putianyi889
Copy link
Contributor Author

putianyi889 commented Feb 20, 2021

It would be super easy to achieve only A[Block(1)] but I'm not sure if it breaks flexibility of other codes.

@dlfivefifty
Copy link
Member

What does this code serve for?

This converts, for example, view(A,Block(1), Block(2)) to view(A,Block(1,2)). Note if there is only one block and its a AbstractBlockVector then the line above is called.

This seems to work (leveraging the code for standard arrays using linear indexing):

julia> A = BlockArray(randn(3,3), [2,1], [2,1])
2×2-blocked 3×3 BlockArray{Float64,2}:
 -0.115769   0.690882-1.04413 
  0.661802  -0.217254-0.272209
 ──────────────────────┼───────────
  0.433854   0.501771-0.884769

julia> Base.view(A::AbstractBlockArray, B::Block{1}) = view(A, Block(Base._ind2sub(map(Base.OneTo, blocksize(A)), Int(B))...))

julia> view(A, Block(3))
2×1 Matrix{Float64}:
 -1.0441288027748936
 -0.2722086284730829

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