Skip to content

Commit 935d2db

Browse files
Merge pull request #255 from j-fu/sparspak_defaults
More on sparspak
2 parents c31e460 + d224203 commit 935d2db

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
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: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,20 @@ function defaultalg(A::Diagonal, b, ::OperatorAssumptions{Nothing})
4343
DiagonalFactorization()
4444
end
4545

46+
function defaultalg(A::SparseMatrixCSC{Tv, Ti}, b,
47+
::OperatorAssumptions{true}) where {Tv, Ti}
48+
SparspakFactorization()
49+
end
50+
4651
@static if INCLUDE_SPARSE
47-
function defaultalg(A::SparseMatrixCSC, b, ::OperatorAssumptions{true})
52+
function defaultalg(A::SparseMatrixCSC{<:Union{Float64,ComplexF64}, Ti}, b,
53+
::OperatorAssumptions{true}) where {Ti}
4854
if length(b) <= 10_000
4955
KLUFactorization()
5056
else
5157
UMFPACKFactorization()
5258
end
5359
end
54-
else
55-
function defaultalg(A::SparseMatrixCSC, b, ::OperatorAssumptions{true})
56-
SparspakFactorization()
57-
end
5860
end
5961

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

src/factorization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ function init_cacheval(::SparspakFactorization, A, b, u, Pl, Pr, maxiters::Int,
511511
reltol,
512512
verbose::Bool, assumptions::OperatorAssumptions)
513513
A = convert(AbstractMatrix, A)
514-
return sparspaklu(A, factorize=false)
514+
return sparspaklu(A, factorize = false)
515515
end
516516

517517
function SciMLBase.solve(cache::LinearCache, alg::SparspakFactorization; kwargs...)

0 commit comments

Comments
 (0)