JuliaLinearAlgebra / Preconditioners.jl

A few preconditioners for iterative solvers.
https://julialinearalgebra.github.io/Preconditioners.jl/
Other
50 stars 11 forks source link

More general `\` and `ldiv!` for incomplete Cholesky #33

Open JeffFessler opened 1 year ago

JeffFessler commented 1 year ago

The diagonal preconditioner has a general ldiv! method that can apply to a vector or a matrix because b is duck typed: https://github.com/JuliaLinearAlgebra/Preconditioners.jl/blob/52b3702e9c8c5d42d6092ed2df7efdbe07c81411/src/diagonal.jl#L40

In contrast, the incomplete Cholesky preconditioner ldiv! is pinned to a Vector argument: https://github.com/JuliaLinearAlgebra/Preconditioners.jl/blob/52b3702e9c8c5d42d6092ed2df7efdbe07c81411/src/incompletecholesky.jl#L28

Could the package provide a more general RHS? Something like:

@inline function ldiv!(y::AbstractVecOrMat, C::CholeskyPreconditioner, b::AbstractVecOrMat)

One related hack is something like this:

import Base.\
\(C::CholeskyPreconditioner, A::AbstractMatrix) = reduce(hcat, [C \ c for c in eachcol(A)])

but I think there should be a better way?

mohamed82008 commented 1 year ago

We will need to upstream these implementations to the dependency packages first if possible. If the maintainers are not receptive, we can roll our own implementation here.