JuliaArrays / JuliaArrays/BlockArrays.jl
Can't ldiv! a QR factorization with a BlockVector
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 254
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
This came up while trying to use an implicit solver with OrdinaryDiffEq.
A simple reproducible example:
julia> using BlockArrays, LinearAlgebra
julia> x = BlockArray(rand(3))
1-blocked 3-element BlockVector{Float64, Vector{Vector{Float64}}, Tuple{Base.OneTo{Int64}}}:
0.46021136136833674
0.5138272715735523
0.581072254943535
julia> QR = qr(rand(3,3))
LinearAlgebra.QRCompactWY{Float64, Matrix{Float64}}
Q factor:
3×3 LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}}:
-0.682104 -0.0521373 -0.729394
-0.477444 -0.723754 0.498224
-0.553878 0.688086 0.468783
R factor:
3×3 Matrix{Float64}:
-0.998175 -0.835741 -0.730764
0.0 0.429548 0.36884
0.0 0.0 0.0893908
julia> ldiv!(QR, x)
ERROR: Overload materialize!(::Lmul{ArrayLayouts.AdjQRCompactWYQLayout{ArrayLayouts.DenseColumnMajor, ArrayLayouts.DenseColumnMajor}})
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] materialize!(M::ArrayLayouts.Lmul{ArrayLayouts.AdjQRCompactWYQLayout{ArrayLayouts.DenseColumnMajor, ArrayLayouts.DenseColumnMajor}, BlockArrays.BlockLayout{ArrayLayouts.DenseColumnMajor, ArrayLayouts.DenseColumnMajor}, Adjoint{Float64, LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}}}, BlockVector{Float64, Vector{Vector{Float64}}, Tuple{Base.OneTo{Int64}}}})
@ ArrayLayouts ~/.julia/packages/ArrayLayouts/3lnt1/src/factorizations.jl:127
[3] lmul!(A::Adjoint{Float64, LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}}}, B::BlockVector{Float64, Vector{Vector{Float64}}, Tuple{Base.OneTo{Int64}}})
@ ArrayLayouts ~/.julia/packages/ArrayLayouts/3lnt1/src/lmul.jl:47
[4] materialize!(L::ArrayLayouts.Ldiv{ArrayLayouts.QRCompactWYLayout{ArrayLayouts.DenseColumnMajor, ArrayLayouts.DenseColumnMajor}, BlockArrays.BlockLayout{ArrayLayouts.DenseColumnMajor, ArrayLayouts.DenseColumnMajor}, LinearAlgebra.QRCompactWY{Float64, Matrix{Float64}}, BlockVector{Float64, Vector{Vector{Float64}}, Tuple{Base.OneTo{Int64}}}})
@ ArrayLayouts ~/.julia/packages/ArrayLayouts/3lnt1/src/factorizations.jl:25
[5] ldiv!
@ ~/.julia/packages/ArrayLayouts/3lnt1/src/ldiv.jl:89 [inlined]
[6] ldiv!(A::LinearAlgebra.QRCompactWY{Float64, Matrix{Float64}}, x::BlockVector{Float64, Vector{Vector{Float64}}, Tuple{Base.OneTo{Int64}}})
@ ArrayLayouts ~/.julia/packages/ArrayLayouts/3lnt1/src/ldiv.jl:135
[7] top-level scope
@ REPL[8]:1
Unfortunately I don't understand how ArrayLayouts works: can you give some pointers on what needs to be done?
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
Start with the Julia reproducer in the issue, then read ArrayLayouts' factorization handling at factorization.jl:127 and ldiv.jl:89 and 135. Trace the QRCompactWY and BlockVector path to identify the missing operation; done means ldiv!(QR, x) works for the shown BlockVector without the materialize! error.
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
- 35/100