SciML / LinearSolve.jl

LinearSolve.jl: High-Performance Unified Interface for Linear Solvers in Julia. Easily switch between factorization and Krylov methods, add preconditioners, and all in one interface.
https://docs.sciml.ai/LinearSolve/stable/
Other
234 stars 51 forks source link

How to set UMFPACK control vector ? #383

Open sjdaines opened 9 months ago

sjdaines commented 9 months ago

Apologies if I've missed something, but I can't see how to set the UMFPACK control vector...

Would this be possible perhaps as a new control kwarg to UMFPACKFactorization ?

which could then be used eg to reenable iterative refinement:

import SparseArrays 

umfpack_control = SparseArrays.UMFPACK.get_umfpack_control(Float64, Int64) # get Julia defaults (NB: Julia modifies the UMFPACK default to switch off iterative refinement)
umfpack_control[SparseArrays.UMFPACK.JL_UMFPACK_IRSTEP] = 2.0 # reenable UMFPACK default max iterative refinement steps

UMFPACKFactorization(;reuse_symbolic=true, check_pattern=true, control=umfpack_control)

where this could perhaps be implemented as

Base.@kwdef struct UMFPACKFactorization <: AbstractFactorization
    reuse_symbolic::Bool = true
    check_pattern::Bool = true # Check factorization re-use
    control::Vector{Float64} = Float64[] # empty vector will be filled in with defaults from a call to SparseArrays.UMFPACK.get_umfpack_control
end
ChrisRackauckas commented 9 months ago

I didn't know there was more controls here. Are they documented somewhere?

Instead of specifying the control vector, we should raise it to a higher level interface. UMFPACKFactorization(;max_iterative_refinement_steps = 2) or something.

sjdaines commented 9 months ago

I didn't know there was more controls here. Are they documented somewhere?

Just made a PR to add some more doc https://github.com/JuliaSparse/SparseArrays.jl/pull/449

Full doc is the UMFPACK User Guide https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/UMFPACK/Doc/UMFPACK_UserGuide.pdf

ChrisRackauckas commented 9 months ago

Cool thanks for sharing. I don't have a free hand right now to complete this, but would happily take a PR if anyone has a second.

PaoloBiolghini commented 3 months ago

I noticed in the SparseArrays code that they force the value of the control vector to zero when you want to change it. image

So, in order to change the control parameters for LinearSolve, as you suggested, we have to modify the UMFPACKFactorization struct and also the solve function, adding the control vector as parameters to the lu function.

I'm going to open the PR and link it to these issues.