Table of Contents

Class SparseDirectSolver<T>

Namespace
NVMathNet.Sparse
Assembly
NVMath.Net.dll

Sparse direct solver for A·X = B backed by NVIDIA cuDSS. Mirrors the staged workflow of nvmath-python's DirectSolver:

  1. NVMathNet.Sparse.SparseDirectSolver`1.Analyze — reordering and symbolic factorisation (depends only on the sparsity pattern).
  2. NVMathNet.Sparse.SparseDirectSolver`1.Factorize — numerical factorisation.
  3. NVMathNet.Sparse.SparseDirectSolver`1.Solve(NVMathNet.DeviceBuffer{`0},NVMathNet.DeviceBuffer{`0},System.Int32) — forward/backward substitution; call repeatedly for new right-hand sides.
  4. Change the values of A in place and call NVMathNet.Sparse.SparseDirectSolver`1.Refactorize to reuse the analysis.

Requires the cuDSS runtime library (cudss64_0.dll / libcudss.so.0) on the library path. The CSR matrix must have sorted column indices and must outlive this solver.

public sealed class SparseDirectSolver<T> : IDisposable where T : unmanaged, INumberBase<T>

Type Parameters

T

System.Single, System.Double or System.Numerics.Complex (double-precision complex; use the Hermitian structures for Hermitian matrices).

Inheritance

Implements

Inherited Members

Constructors

SparseDirectSolver(CsrMatrix<T>, DirectSolverOptions?, CudaStream?)

Creates a solver for matrix.

public SparseDirectSolver(CsrMatrix<T> matrix, DirectSolverOptions? options = null, CudaStream? stream = null)

Parameters

matrix CsrMatrix<T>

Square CSR matrix; must outlive the solver.

options DirectSolverOptions?

Solver options; null uses defaults.

stream CudaStream?

Optional CUDA stream; a private stream is created if null.

Properties

FactorNonZeros

Number of non-zeros in the factors; available after NVMathNet.Sparse.SparseDirectSolver`1.Factorize.

public long FactorNonZeros { get; }

Property Value

long

PerturbedPivots

Number of pivots cuDSS perturbed during the last factorisation.

public int PerturbedPivots { get; }

Property Value

int

Methods

Analyze()

Reordering and symbolic factorisation. Depends only on the sparsity pattern, so it is done once even if the values change.

public void Analyze()

AnalyzeAsync(CancellationToken)

Asynchronous version of NVMathNet.Sparse.SparseDirectSolver`1.Analyze (runs on the thread pool).

public Task AnalyzeAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Factorize()

Numerical factorisation. Runs NVMathNet.Sparse.SparseDirectSolver`1.Analyze first if it has not been done. Throws System.InvalidOperationException if cuDSS reports a failure (for example a singular matrix).

public void Factorize()

FactorizeAsync(CancellationToken)

Asynchronous version of NVMathNet.Sparse.SparseDirectSolver`1.Factorize (runs on the thread pool).

public Task FactorizeAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

Refactorize()

Re-factorises after the values of the matrix changed in place (same sparsity pattern), reusing the analysis.

public void Refactorize()

RefactorizeAsync(CancellationToken)

Asynchronous version of NVMathNet.Sparse.SparseDirectSolver`1.Refactorize (runs on the thread pool).

public Task RefactorizeAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

SetValues(DeviceBuffer<T>)

Points the solver at a different values array (same sparsity pattern). NVMathNet.Sparse.SparseDirectSolver`1.Solve(NVMathNet.DeviceBuffer{`0},NVMathNet.DeviceBuffer{`0},System.Int32) refactorises automatically afterwards; call NVMathNet.Sparse.SparseDirectSolver`1.Refactorize explicitly to do it earlier.

public void SetValues(DeviceBuffer<T> values)

Parameters

values DeviceBuffer<T>

Solve(DeviceBuffer<T>, DeviceBuffer<T>, int)

Solves A·X = B. Runs NVMathNet.Sparse.SparseDirectSolver`1.Factorize first if it has not been done.

public void Solve(DeviceBuffer<T> b, DeviceBuffer<T> x, int nrhs = 1)

Parameters

b DeviceBuffer<T>

Right-hand sides, column-major n × nrhs (leading dimension n).

x DeviceBuffer<T>

Solution, column-major n × nrhs; must not alias b.

nrhs int

Number of right-hand sides.

SolveAsync(DeviceBuffer<T>, DeviceBuffer<T>, int, CancellationToken)

Asynchronous version of NVMathNet.Sparse.SparseDirectSolver`1.Solve(NVMathNet.DeviceBuffer{`0},NVMathNet.DeviceBuffer{`0},System.Int32) (runs on the thread pool).

public Task SolveAsync(DeviceBuffer<T> b, DeviceBuffer<T> x, int nrhs = 1, CancellationToken ct = default)

Parameters

b DeviceBuffer<T>
x DeviceBuffer<T>
nrhs int
ct CancellationToken

Returns

Task