JuliaArrays / JuliaArrays/BlockArrays.jl
BlockArray errors with generic linear algebra functions
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 254
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
When using the generic fallback functions provided by LinearAlgebra, BlockArray type matrices don't work properly. I'm not sure what the best way of handling this would be, but I guess we could theoretically generate versions of the linear algebra functions that fail and have them take the block array and do a conversion to a normal array when calling the standard linear algebra function.
For example, the cond function fails due to a missing bidiagonalize_tall! function. Of course, explicitly converting the block array to a normal array allows the computation to succeed (since it no longer needs the specialization of bidiagonalize_tall!).
julia> D = BlockArray( randn(4,4), [2, 2], [2, 2] )
2×2-blocked 4×4 BlockArray{Float64,2}:
0.923874 -0.0829803 │ 0.286211 0.46231
0.195939 0.14953 │ 1.8477 -0.321445
────────────────────────┼─────────────────────
-0.0989605 -1.26688 │ 1.42871 -0.659864
0.403813 -0.86728 │ 0.72237 -0.621602
julia> cond( D )
ERROR: MethodError: no method matching bidiagonalize_tall!(::BlockArray{Float64,2,Array{Array{Float64,2},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}})
Closest candidates are:
bidiagonalize_tall!(::Array{T,2}) where T at /home/imcinerney/.julia/packages/GenericSVD/cT5Cu/src/bidiagonalize.jl:51
bidiagonalize_tall!(::Array{T,2}, ::Bidiagonal) where T at /home/imcinerney/.julia/packages/GenericSVD/cT5Cu/src/bidiagonalize.jl:19
bidiagonalize_tall!(::Adjoint{T2,Array{T,2}}) where {T, T2} at /home/imcinerney/.julia/packages/GenericSVD/cT5Cu/src/bidiagonalize.jl:47
Stacktrace:
[1] generic_svdvals!(::BlockArray{Float64,2,Array{Array{Float64,2},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}}; sorted::Bool) at /home/imcinerney/.julia/packages/GenericSVD/cT5Cu/src/GenericSVD.jl:57
[2] generic_svdvals!(::BlockArray{Float64,2,Array{Array{Float64,2},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}}) at /home/imcinerney/.julia/packages/GenericSVD/cT5Cu/src/GenericSVD.jl:53
[3] svdvals!(::BlockArray{Float64,2,Array{Array{Float64,2},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}}) at /home/imcinerney/.julia/packages/GenericSVD/cT5Cu/src/GenericSVD.jl:21
[4] svdvals(::BlockArray{Float64,2,Array{Array{Float64,2},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}}) at /home/imcinerney/dev/julia/main/1.4/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/svd.jl:194
[5] cond(::BlockArray{Float64,2,Array{Array{Float64,2},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}}, ::Int64) at /home/imcinerney/dev/julia/main/1.4/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/dense.jl:1419
[6] cond(::BlockArray{Float64,2,Array{Array{Float64,2},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}}) at /home/imcinerney/dev/julia/main/1.4/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/dense.jl:1418
[7] top-level scope at REPL[15]:1
[8] eval(::Module, ::Any) at ./boot.jl:331
[9] eval_user_input(::Any, ::REPL.REPLBackend) at /home/imcinerney/dev/julia/main/1.4/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
[10] run_backend(::REPL.REPLBackend) at /home/imcinerney/.julia/packages/Revise/XFtoQ/src/Revise.jl:1162
[11] top-level scope at REPL[1]:0
julia> cond( Array( D ) )
8.508044778284596
So far the functions that I have found fail are (but there are probably more):
condsvdsvdvalseigen
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The failure enters through LinearAlgebra.cond and GenericSVD.generic_svdvals! in GenericSVD.jl at line 57; svd, svdvals, and eigen are also reported. Reproduce the BlockArray example and compare it with Array(D); done means these generic functions work on BlockArray without requiring an explicit caller-side conversion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100