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
7 changes: 4 additions & 3 deletions src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ patterns with “more structure”.
Base.@kwdef struct UMFPACKFactorization <: AbstractFactorization
reuse_symbolic::Bool = true
check_pattern::Bool = true # Check factorization re-use
control::Vector{Float64}=SparseArrays.UMFPACK.get_umfpack_control(Float64,Int64) # Control Parameters of UMFPACK
Copy link
Member

Choose a reason for hiding this comment

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

This will heap allocate each time in the default algorithm. Instead, make a const of the default, set the default here to nothing, and then if nothing use the const global.

end

const PREALLOCATED_UMFPACK = SparseArrays.UMFPACK.UmfpackLU(SparseMatrixCSC(0, 0, [1],
Expand Down Expand Up @@ -782,15 +783,15 @@ function SciMLBase.solve!(cache::LinearCache, alg::UMFPACKFactorization; kwargs.
fact = lu(
SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A),
nonzeros(A)),
check = false)
check = false, control=alg.control)
else
fact = lu!(cacheval,
SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A),
nonzeros(A)), check = false)
nonzeros(A)), check = false, control=alg.control)
end
else
fact = lu(SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A), nonzeros(A)),
check = false)
check = false, control=alg.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 contro Vector

Check warning on line 7 in test/controlvectortest.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"contro" should be "control".
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