Closed utkarsh530 closed 1 year ago
So is qr_instance
giving the wrong type? Is there an MWE of that?
Yes:
using LinearSolve
prob = LinearProblem(rand(100,100), rand(100))
linsolve = init(prob, QRFactorization())
@show typeof(linsolve.cacheval)
qr_instance
returns this type for Matrices.
The problem happens as follows:
solve(linearprob)
lowers to solve(init(linearprob...))
, which sets linsolve.cacheval
to the type returned by qr_instance
.solve(linsolve)
happens it dispatches to: https://github.com/SciML/LinearSolve.jl/blob/f9389edccd2ca156d3f18c05481035a88a0d16f0/src/factorization.jl#L9
Which causes do_factorization
to set the cache by qr
as mentioned in the first comment.Possible workaround:
Changeqr_instance
to initialize LinearAlgebra.QRCompactWY
instead of LinearAlgebra.QRCompactWYQ
.
QR just got a bit of a rework in LinearAlgebra so the change is likely related to that?
Yes, this is fixed upstream https://github.com/JuliaArrays/ArrayInterface.jl/pull/413
MWE:
Causes a problem with OrdinaryDiffEq.jl due to the type change.
Possible reason:
there are two different factorization dispatch here: https://github.com/SciML/LinearSolve.jl/blob/f9389edccd2ca156d3f18c05481035a88a0d16f0/src/factorization.jl#L92-L106 This causes problems because
init
callsinit_cacheval
, which gives a different cache, and since solve doesn't have separate dispatch for QR, it callsdo_factorization
and sets a different cache.