Skip to content

Sparspak should be called directly with dual numbers #837

@j-fu

Description

@j-fu

When a user explicitly chooses Sparspak as solver in situations
with dual numbers, Sparspak should handle the problem directly as it was
implemented before the transition to LinearSolverForwardDiffExt instead
of being treated as a linear solver unable to handle dual numbers.

Minimal Reproducible Example 👇

using LinearSolve
using Sparspak
using SparseArrays
using ForwardDiff
using BenchmarkTools

N=100
x0=ForwardDiff.Dual{Float64}(1,(0.1,))
D=fill(x0,N)
A=spdiagm(-1=>D[2:end], 0=>2*D, 1=> D[2:end])

@btime begin
    p=LinearProblem(A,D)
    solve(p, SparspakFactorization())
end

@btime begin
    sparspaklu(A)\D
end

** Output **

4.954 ms (363 allocations: 16.01 MiB)
271.164 μs (238 allocations: 608.46 KiB)

So, also, in fact, direct use of sparspak is indeed faster.

@PetrKryslUCSD

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions