Skip to content

Commit

Permalink
Add static if for 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
rayegun committed Oct 20, 2022
1 parent 8550cf9 commit 24cf079
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,17 @@ function init_cacheval(alg::UMFPACKFactorization, A, b, u, Pl, Pr, maxiters::Int
verbose::Bool, assumptions::OperatorAssumptions)
A = convert(AbstractMatrix, A)
zerobased = SparseArrays.getcolptr(A)[1] == 0
res = SuiteSparse.UMFPACK.UmfpackLU(C_NULL, C_NULL, size(A, 1), size(A, 2),
zerobased ? copy(SparseArrays.getcolptr(A)) :
SuiteSparse.decrement(SparseArrays.getcolptr(A)),
zerobased ? copy(rowvals(A)) :
SuiteSparse.decrement(rowvals(A)),
copy(nonzeros(A)), 0)
finalizer(SuiteSparse.UMFPACK.umfpack_free_symbolic, res)
res
@static if VERSION < v"1.9"
return SuiteSparse.UMFPACK.UmfpackLU(C_NULL, C_NULL, size(A, 1), size(A, 2),
zerobased ? copy(SparseArrays.getcolptr(A)) :
SuiteSparse.decrement(SparseArrays.getcolptr(A)),
zerobased ? copy(rowvals(A)) :
SuiteSparse.decrement(rowvals(A)),
copy(nonzeros(A)), 0)
finalizer(SuiteSparse.UMFPACK.umfpack_free_symbolic, res)
else
return SuiteSparse.UMFPACK.UmfpackLU(A)
end
end

function SciMLBase.solve(cache::LinearCache, alg::UMFPACKFactorization; kwargs...)
Expand Down

0 comments on commit 24cf079

Please sign in to comment.