Nemocas / AbstractAlgebra.jl

Generic abstract algebra functionality in pure Julia (no C dependencies)
https://nemocas.github.io/AbstractAlgebra.jl/dev/index.html
Other
155 stars 60 forks source link

`view(::MatElem, ::Int, ::Int)` errors #1718

Open joschmitt opened 1 month ago

joschmitt commented 1 month ago

This doesn't work:

julia> M = matrix(ZZ, [ 1 2 3 ; 4 5 6])
[1   2   3]
[4   5   6]

julia> view(M, 1, 1)
ERROR: StackOverflowError:
Stacktrace:
 [1] view(M::AbstractAlgebra.Generic.MatSpaceElem{BigInt}, rows::Int64, cols::Int64) (repeats 79984 times)
   @ AbstractAlgebra ~/.julia/dev/AbstractAlgebra/src/Matrix.jl:432

With Julia matrices it does:

julia> view(M.entries, 1, 1)
0-dimensional view(::Matrix{BigInt}, 1, 1) with eltype BigInt:
1

I guess we would have to add a type MatSpaceScalarView (?) to the view interface? Also this particular view function https://github.com/Nemocas/AbstractAlgebra.jl/blob/6b230ed767387281b56af7583a62a092bd39136c/src/Matrix.jl#L429 seems very fishy to me.