Skip to content

Cannot solve with AdjointFactorization of Cholesky factorizations and Adjoint right-hand side #594

@jonas-schulze

Description

@jonas-schulze

Consider the following MWE:

using LinearAlgebra, SparseArrays

n = 10
A = sprand(n, n, 1/n)
A = A + A' + 10I

B = rand(n, 2)
Bt = Matrix(B')

F = factorize(A')
F \ B   # works just fine
F \ Bt' # breaks
ERROR: MethodError: no method matching ldiv!(::LinearAlgebra.AdjointFactorization{Float64, SparseArrays.CHOLMOD.Factor{Float64, Int64}}, ::Matrix{Float64})

Closest candidates are:
  ldiv!(::BunchKaufman{T, <:StridedMatrix{T} where T}, ::StridedVecOrMat{T}) where T<:Union{Float32, Float64}
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/bunchkaufman.jl:329
  ldiv!(::LinearAlgebra.QRCompactWY{T, M, C} where {M<:AbstractMatrix{T}, C<:AbstractMatrix{T}}, ::AbstractMatrix{T}) where T
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/qr.jl:523
  ldiv!(::UpperHessenberg, ::AbstractVecOrMat; shift)
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/hessenberg.jl:179
  ...

Stacktrace:
 [1] \(F::LinearAlgebra.AdjointFactorization{Float64, SparseArrays.CHOLMOD.Factor{Float64, Int64}}, B::Adjoint{Float64, Matrix{Float64}})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/factorization.jl:143
 [2] top-level scope
   @ REPL[27]:1
 [3] top-level scope
   @ none:1

A similar situation happens in one of my codes that implements the Sherman-Morrison-Woodbury formula. What is the proper way to fix this?

  1. Define adjoint(F::SparseArrays.CHOLMOD.Factor) = F?
  2. Make Adjoint{T, Matrix{T}} a StridedMatrix?
  3. Define the missing method of ldiv!?
  4. ...?

Option 1 would work, but seems out of place given this method of (\) (permalink created from release-1.10). I didn't test options 2 or 3. What would be the best option to have this work with the current LTS?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions