Skip to content

Commit 592b61d

Browse files
committed
* Set default algorithm to sparspak for generic float
* precompile sparspak * Mention sparspak in README
1 parent c31e460 commit 592b61d

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ maximum efficiency. Specifically, LinearSolve.jl includes:
1919
- KLU for faster sparse LU factorization on unstructured matrices
2020
- UMFPACK for faster sparse LU factorization on matrices with some repeated structure
2121
- MKLPardiso wrappers for handling many sparse matrices faster than SuiteSparse (KLU, UMFPACK) methods
22+
- Sparspak.jl for sparse LU factorization in pure Julia for generic number types and for non-GPL distributions
2223
- GPU-offloading for large dense matrices
2324
- Wrappers to all of the Krylov implementations (Krylov.jl, IterativeSolvers.jl, KrylovKit.jl) for easy
2425
testing of all of them. LinearSolve.jl handles the API differences, especially with the preconditioner

src/LinearSolve.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,19 @@ end
7575
A = sprand(4, 4, 0.3) + I
7676
b = rand(4)
7777
prob = LinearProblem(A, b)
78-
sol = solve(prob)
7978
sol = solve(prob, KLUFactorization())
8079
sol = solve(prob, UMFPACKFactorization())
81-
sol = solve(prob, SparspakFactorization())
8280
end
8381
end
8482

83+
SnoopPrecompile.@precompile_all_calls begin
84+
A = sprand(4, 4, 0.3) + I
85+
b = rand(4)
86+
prob = LinearProblem(A, b)
87+
sol = solve(prob)
88+
sol = solve(prob, SparspakFactorization())
89+
end
90+
8591
export LUFactorization, SVDFactorization, QRFactorization, GenericFactorization,
8692
GenericLUFactorization, SimpleLUFactorization, RFLUFactorization,
8793
UMFPACKFactorization, KLUFactorization, FastLUFactorization, FastQRFactorization,

src/default.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,22 @@ function defaultalg(A::Diagonal, b, ::OperatorAssumptions{Nothing})
4343
DiagonalFactorization()
4444
end
4545

46+
function defaultalg(A::SparseMatrixCSC{Tv,Ti}, b, ::OperatorAssumptions{true}) where {Tv,Ti}
47+
SparspakFactorization()
48+
end
49+
4650
@static if INCLUDE_SPARSE
47-
function defaultalg(A::SparseMatrixCSC, b, ::OperatorAssumptions{true})
48-
if length(b) <= 10_000
49-
KLUFactorization()
50-
else
51-
UMFPACKFactorization()
51+
for Tv in (:Float64,ComplexF64)
52+
@eval begin
53+
function defaultalg(A::SparseMatrixCSC{$Tv,Ti}, b, ::OperatorAssumptions{true}) where Ti
54+
if length(b) <= 10_000
55+
KLUFactorization()
56+
else
57+
UMFPACKFactorization()
58+
end
59+
end
5260
end
5361
end
54-
else
55-
function defaultalg(A::SparseMatrixCSC, b, ::OperatorAssumptions{true})
56-
SparspakFactorization()
57-
end
5862
end
5963

6064
function defaultalg(A::GPUArraysCore.AbstractGPUArray, b, ::OperatorAssumptions{true})

0 commit comments

Comments
 (0)