A linear solver for sparse circuit simulation problems. This package wraps the SuiteSparse solver KLU.
using Pkg
Pkg.add("KLU")julia> using KLU
julia> using SparseArrays
julia> A = sprand(15, 15, 0.45);
julia> factor = klu(A);
julia> b = rand(15);
julia> x = factor \ b
15-element Vector{Float64}:
22.501711574339556
27.80357152530039
-37.08488119597194
61.470604418791346
-0.49109038415655193
38.03163985997178
1.2417021657549396
-51.154984106483155
0.9488554483842341
1.587572050319512
-31.251127382496147
1.4508846663863602
-25.866070230462796
-5.46661465074706
10.688731342850245KLU's C library keeps scratch workspace inside each numeric factorization, so two
simultaneous solves (or a solve and a refactorization) on the same KLUFactorization
would corrupt each other. KLU.jl therefore guards every libklu call with a lock stored
in the factorization object: sharing one factorization between threads is safe, but those
calls are serialized. Distinct factorizations share no state and run fully in parallel.
To solve many right-hand sides against one matrix in parallel, batch them as the columns
of a single B in one solve!/ldiv! call, or give each task its own klu(A).
The lock is reentrant and can be held by the user across a sequence of calls with
Base.@lock F ....
Please cite both SuiteSparse as well as KLU.