Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the posibility to modify the control paramteres of UMFPACK alg #482

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
10 changes: 7 additions & 3 deletions src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,12 @@
`A` has the same sparsity pattern as the previous `A`. If this algorithm is to
be used in a context where that assumption does not hold, set `reuse_symbolic=false`.
"""
const default_control::Array{FLoat64}=[1.0, 0.2, 0.2, 0.1, 32.0, 0.0, 0.7, 0.0, 1.0, 0.3, 1.0, 1.0, 0.9, 0.0, 10.0, 0.001, 1.0, 0.5, 0.0, 1.0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is blocking the docstring above from going to the right thing.


Base.@kwdef struct UMFPACKFactorization <: AbstractFactorization
reuse_symbolic::Bool = true
check_pattern::Bool = true # Check factorization re-use
control::Vector{Float64}=nothing
end

const PREALLOCATED_UMFPACK = SparseArrays.UMFPACK.UmfpackLU(SparseMatrixCSC(0, 0, [1],
Expand Down Expand Up @@ -771,6 +774,7 @@
function SciMLBase.solve!(cache::LinearCache, alg::UMFPACKFactorization; kwargs...)
A = cache.A
A = convert(AbstractMatrix, A)
isnothing(alg.control) ? control=default_control : control=alg.control

Check warning on line 777 in src/factorization.jl

View check run for this annotation

Codecov / codecov/patch

src/factorization.jl#L777

Added line #L777 was not covered by tests
if cache.isfresh
cacheval = @get_cacheval(cache, :UMFPACKFactorization)
if alg.reuse_symbolic
Expand All @@ -782,15 +786,15 @@
fact = lu(
SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A),
nonzeros(A)),
check = false)
check = false, control=control)
else
fact = lu!(cacheval,
SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A),
nonzeros(A)), check = false)
nonzeros(A)), check = false, control=control)
end
else
fact = lu(SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A), nonzeros(A)),
check = false)
check = false, control=control)
end
cache.cacheval = fact
cache.isfresh = false
Expand Down
12 changes: 12 additions & 0 deletions test/controlvectortest.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using SparseArrays, LinearSolve

A = sparse(rand(3,3));
b=rand(3);
prob = LinearProblem(A, b);

#check without control Vector
u=solve(prob,UMFPACKFactorization()).u

#check plugging in a control vector
controlv=SparseArrays.UMFPACK.get_umfpack_control(Float64,Int64)
u=solve(prob,UMFPACKFactorization(control=controlv)).u
Loading