Class SparseLinearAlgebra
- Namespace
- NVMathNet.Sparse
- Assembly
- NVMath.Net.dll
Static helpers for sparse linear algebra operations using cuSPARSE.
public static class SparseLinearAlgebraInheritance
Inherited Members
Methods
SddmmAsync<T>(DeviceBuffer<T>, DeviceBuffer<T>, CsrMatrix<T>, long, T?, T?, CudaStream?, CancellationToken)
Sampled dense-dense matrix product:
C = alpha · (A · B) ∘ spy(C) + beta · C, where only the entries in the
sparsity pattern of C are computed and C's values are updated in place.
public static Task SddmmAsync<T>(DeviceBuffer<T> a, DeviceBuffer<T> b, CsrMatrix<T> c, long k, T? alpha = null, T? beta = null, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
aDeviceBuffer<T>-
Dense A (m × k), column-major on device.
bDeviceBuffer<T>-
Dense B (k × n), column-major on device.
cCsrMatrix<T>-
Sparse CSR matrix C (m × n); its values are updated in place.
klong-
Inner dimension.
alphaT?-
Scale for the product. Default: 1.
betaT?-
Scale for the existing values of C. Default: 0.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpGemmAsync<T>(CsrMatrix<T>, CsrMatrix<T>, T?, CudaStream?, CancellationToken)
Sparse-sparse matrix product: returns a new CSR matrix C = alpha · A · B.
public static Task<CsrMatrix<T>> SpGemmAsync<T>(CsrMatrix<T> a, CsrMatrix<T> b, T? alpha = null, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
aCsrMatrix<T>-
Sparse CSR matrix A (m × k).
bCsrMatrix<T>-
Sparse CSR matrix B (k × n).
alphaT?-
Scale for the product. Default: 1.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpMMAsync<T>(CsrMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, long, float, float, bool, CudaStream?, CancellationToken)
Sparse matrix-dense matrix product: C = alpha * op(A) * B + beta * C.
public static Task SpMMAsync<T>(CsrMatrix<T> matrix, DeviceBuffer<T> b, DeviceBuffer<T> c, long n, float alpha = 1, float beta = 0, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCsrMatrix<T>-
Sparse CSR matrix A (m × k).
bDeviceBuffer<T>-
Dense matrix B (k × n), column-major on device.
cDeviceBuffer<T>-
Dense output matrix C (m × n), column-major on device; updated in place.
nlong-
Number of columns in B and C.
alphafloat-
Scalar multiplier for the sparse-dense product. Default: 1.
betafloat-
Scalar multiplier for the existing values in C. Default: 0.
transposebool-
If true, uses the transpose of the sparse matrix.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpMMAsync<T>(CooMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, long, float, float, bool, CudaStream?, CancellationToken)
Sparse-dense matrix product C = alpha · op(A) · B + beta · C for a COO matrix.
public static Task SpMMAsync<T>(CooMatrix<T> matrix, DeviceBuffer<T> b, DeviceBuffer<T> c, long n, float alpha = 1, float beta = 0, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCooMatrix<T>-
Sparse CSR matrix A (m × k).
bDeviceBuffer<T>-
Dense matrix B (k × n), column-major on device.
cDeviceBuffer<T>-
Dense output matrix C (m × n), column-major on device; updated in place.
nlong-
Number of columns in B and C.
alphafloat-
Scalar multiplier for the sparse-dense product. Default: 1.
betafloat-
Scalar multiplier for the existing values in C. Default: 0.
transposebool-
If true, uses the transpose of the sparse matrix.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpMMAsync<T>(BsrMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, long, float, float, bool, CudaStream?, CancellationToken)
Sparse-dense matrix product C = alpha · op(A) · B + beta · C for a BSR matrix.
public static Task SpMMAsync<T>(BsrMatrix<T> matrix, DeviceBuffer<T> b, DeviceBuffer<T> c, long n, float alpha = 1, float beta = 0, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixBsrMatrix<T>-
Sparse CSR matrix A (m × k).
bDeviceBuffer<T>-
Dense matrix B (k × n), column-major on device.
cDeviceBuffer<T>-
Dense output matrix C (m × n), column-major on device; updated in place.
nlong-
Number of columns in B and C.
alphafloat-
Scalar multiplier for the sparse-dense product. Default: 1.
betafloat-
Scalar multiplier for the existing values in C. Default: 0.
transposebool-
If true, uses the transpose of the sparse matrix.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpMMAsync<T>(CscMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, long, float, float, bool, CudaStream?, CancellationToken)
Sparse-dense matrix product C = alpha · op(A) · B + beta · C for a CSC matrix.
public static Task SpMMAsync<T>(CscMatrix<T> matrix, DeviceBuffer<T> b, DeviceBuffer<T> c, long n, float alpha = 1, float beta = 0, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCscMatrix<T>-
Sparse CSR matrix A (m × k).
bDeviceBuffer<T>-
Dense matrix B (k × n), column-major on device.
cDeviceBuffer<T>-
Dense output matrix C (m × n), column-major on device; updated in place.
nlong-
Number of columns in B and C.
alphafloat-
Scalar multiplier for the sparse-dense product. Default: 1.
betafloat-
Scalar multiplier for the existing values in C. Default: 0.
transposebool-
If true, uses the transpose of the sparse matrix.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpMMAsync<T>(CsrMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, long, T, T, bool, CudaStream?, CancellationToken)
C = alpha · op(A) · B + beta · C for a CSR matrix with scalars of the element type, which allows complex
scalars for System.Numerics.Complex matrices.
public static Task SpMMAsync<T>(CsrMatrix<T> matrix, DeviceBuffer<T> b, DeviceBuffer<T> c, long n, T alpha, T beta, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCsrMatrix<T>bDeviceBuffer<T>cDeviceBuffer<T>nlongalphaTbetaTtransposeboolstreamCudaStream?ctCancellationToken
Returns
Type Parameters
T
SpMMAsync<T>(CooMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, long, T, T, bool, CudaStream?, CancellationToken)
C = alpha · op(A) · B + beta · C for a COO matrix with scalars of the element type, which allows complex
scalars for System.Numerics.Complex matrices.
public static Task SpMMAsync<T>(CooMatrix<T> matrix, DeviceBuffer<T> b, DeviceBuffer<T> c, long n, T alpha, T beta, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCooMatrix<T>bDeviceBuffer<T>cDeviceBuffer<T>nlongalphaTbetaTtransposeboolstreamCudaStream?ctCancellationToken
Returns
Type Parameters
T
SpMMAsync<T>(BsrMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, long, T, T, bool, CudaStream?, CancellationToken)
C = alpha · op(A) · B + beta · C for a BSR matrix with scalars of the element type, which allows complex
scalars for System.Numerics.Complex matrices.
public static Task SpMMAsync<T>(BsrMatrix<T> matrix, DeviceBuffer<T> b, DeviceBuffer<T> c, long n, T alpha, T beta, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixBsrMatrix<T>bDeviceBuffer<T>cDeviceBuffer<T>nlongalphaTbetaTtransposeboolstreamCudaStream?ctCancellationToken
Returns
Type Parameters
T
SpMMAsync<T>(CscMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, long, T, T, bool, CudaStream?, CancellationToken)
C = alpha · op(A) · B + beta · C for a CSC matrix with scalars of the element type, which allows complex
scalars for System.Numerics.Complex matrices.
public static Task SpMMAsync<T>(CscMatrix<T> matrix, DeviceBuffer<T> b, DeviceBuffer<T> c, long n, T alpha, T beta, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCscMatrix<T>bDeviceBuffer<T>cDeviceBuffer<T>nlongalphaTbetaTtransposeboolstreamCudaStream?ctCancellationToken
Returns
Type Parameters
T
SpMVAsync<T>(CsrMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, float, float, bool, CudaStream?, CancellationToken)
Sparse matrix-vector product: y = alpha * op(A) * x + beta * y.
public static Task SpMVAsync<T>(CsrMatrix<T> matrix, DeviceBuffer<T> x, DeviceBuffer<T> y, float alpha = 1, float beta = 0, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCsrMatrix<T>-
Sparse CSR matrix A.
xDeviceBuffer<T>-
Dense vector x on device.
yDeviceBuffer<T>-
Dense vector y on device; updated in place.
alphafloat-
Scalar multiplier for the product. Default: 1.
betafloat-
Scalar multiplier for existing y. Default: 0.
transposebool-
If true, uses the transpose of the sparse matrix.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpMVAsync<T>(CooMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, float, float, bool, CudaStream?, CancellationToken)
Sparse matrix-vector product y = alpha · op(A) · x + beta · y for a COO matrix.
public static Task SpMVAsync<T>(CooMatrix<T> matrix, DeviceBuffer<T> x, DeviceBuffer<T> y, float alpha = 1, float beta = 0, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCooMatrix<T>-
Sparse CSR matrix A.
xDeviceBuffer<T>-
Dense vector x on device.
yDeviceBuffer<T>-
Dense vector y on device; updated in place.
alphafloat-
Scalar multiplier for the product. Default: 1.
betafloat-
Scalar multiplier for existing y. Default: 0.
transposebool-
If true, uses the transpose of the sparse matrix.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpMVAsync<T>(BsrMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, float, float, bool, CudaStream?, CancellationToken)
Sparse matrix-vector product y = alpha · op(A) · x + beta · y for a BSR matrix.
public static Task SpMVAsync<T>(BsrMatrix<T> matrix, DeviceBuffer<T> x, DeviceBuffer<T> y, float alpha = 1, float beta = 0, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixBsrMatrix<T>-
Sparse CSR matrix A.
xDeviceBuffer<T>-
Dense vector x on device.
yDeviceBuffer<T>-
Dense vector y on device; updated in place.
alphafloat-
Scalar multiplier for the product. Default: 1.
betafloat-
Scalar multiplier for existing y. Default: 0.
transposebool-
If true, uses the transpose of the sparse matrix.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpMVAsync<T>(CscMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, float, float, bool, CudaStream?, CancellationToken)
Sparse matrix-vector product y = alpha · op(A) · x + beta · y for a CSC matrix.
public static Task SpMVAsync<T>(CscMatrix<T> matrix, DeviceBuffer<T> x, DeviceBuffer<T> y, float alpha = 1, float beta = 0, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCscMatrix<T>-
Sparse CSR matrix A.
xDeviceBuffer<T>-
Dense vector x on device.
yDeviceBuffer<T>-
Dense vector y on device; updated in place.
alphafloat-
Scalar multiplier for the product. Default: 1.
betafloat-
Scalar multiplier for existing y. Default: 0.
transposebool-
If true, uses the transpose of the sparse matrix.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpMVAsync<T>(CsrMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, T, T, bool, CudaStream?, CancellationToken)
y = alpha · op(A) · x + beta · y for a CSR matrix with scalars of the element type, which allows complex
scalars for System.Numerics.Complex matrices.
public static Task SpMVAsync<T>(CsrMatrix<T> matrix, DeviceBuffer<T> x, DeviceBuffer<T> y, T alpha, T beta, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCsrMatrix<T>xDeviceBuffer<T>yDeviceBuffer<T>alphaTbetaTtransposeboolstreamCudaStream?ctCancellationToken
Returns
Type Parameters
T
SpMVAsync<T>(CooMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, T, T, bool, CudaStream?, CancellationToken)
y = alpha · op(A) · x + beta · y for a COO matrix with scalars of the element type, which allows complex
scalars for System.Numerics.Complex matrices.
public static Task SpMVAsync<T>(CooMatrix<T> matrix, DeviceBuffer<T> x, DeviceBuffer<T> y, T alpha, T beta, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCooMatrix<T>xDeviceBuffer<T>yDeviceBuffer<T>alphaTbetaTtransposeboolstreamCudaStream?ctCancellationToken
Returns
Type Parameters
T
SpMVAsync<T>(BsrMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, T, T, bool, CudaStream?, CancellationToken)
y = alpha · op(A) · x + beta · y for a BSR matrix with scalars of the element type, which allows complex
scalars for System.Numerics.Complex matrices.
public static Task SpMVAsync<T>(BsrMatrix<T> matrix, DeviceBuffer<T> x, DeviceBuffer<T> y, T alpha, T beta, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixBsrMatrix<T>xDeviceBuffer<T>yDeviceBuffer<T>alphaTbetaTtransposeboolstreamCudaStream?ctCancellationToken
Returns
Type Parameters
T
SpMVAsync<T>(CscMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, T, T, bool, CudaStream?, CancellationToken)
y = alpha · op(A) · x + beta · y for a CSC matrix with scalars of the element type, which allows complex
scalars for System.Numerics.Complex matrices.
public static Task SpMVAsync<T>(CscMatrix<T> matrix, DeviceBuffer<T> x, DeviceBuffer<T> y, T alpha, T beta, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCscMatrix<T>xDeviceBuffer<T>yDeviceBuffer<T>alphaTbetaTtransposeboolstreamCudaStream?ctCancellationToken
Returns
Type Parameters
T
SpSMAsync<T>(CsrMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, long, SparseTriangle, SparseDiagonal, T?, bool, CudaStream?, CancellationToken)
Sparse triangular solve with a dense matrix right-hand side: solves
op(A) · C = alpha · B for c.
public static Task SpSMAsync<T>(CsrMatrix<T> matrix, DeviceBuffer<T> b, DeviceBuffer<T> c, long n, SparseTriangle triangle = SparseTriangle.Lower, SparseDiagonal diagonal = SparseDiagonal.NonUnit, T? alpha = null, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCsrMatrix<T>-
Square sparse CSR matrix A (m × m).
bDeviceBuffer<T>-
Dense right-hand side (m × n), column-major on device.
cDeviceBuffer<T>-
Dense solution (m × n), column-major on device.
nlong-
Number of right-hand-side columns.
triangleSparseTriangle-
Triangle of A to read.
diagonalSparseDiagonal-
Whether the diagonal is implicit ones.
alphaT?-
Scale applied to B. Default: 1.
transposebool-
Solve with the transpose of A.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpSMAsync<T>(CooMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, long, SparseTriangle, SparseDiagonal, T?, bool, CudaStream?, CancellationToken)
Triangular solve op(A) · C = alpha · B for a COO matrix.
public static Task SpSMAsync<T>(CooMatrix<T> matrix, DeviceBuffer<T> b, DeviceBuffer<T> c, long n, SparseTriangle triangle = SparseTriangle.Lower, SparseDiagonal diagonal = SparseDiagonal.NonUnit, T? alpha = null, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCooMatrix<T>-
Square sparse CSR matrix A (m × m).
bDeviceBuffer<T>-
Dense right-hand side (m × n), column-major on device.
cDeviceBuffer<T>-
Dense solution (m × n), column-major on device.
nlong-
Number of right-hand-side columns.
triangleSparseTriangle-
Triangle of A to read.
diagonalSparseDiagonal-
Whether the diagonal is implicit ones.
alphaT?-
Scale applied to B. Default: 1.
transposebool-
Solve with the transpose of A.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpSVAsync<T>(CsrMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, SparseTriangle, SparseDiagonal, T?, bool, CudaStream?, CancellationToken)
Sparse triangular solve with a vector right-hand side: solves
op(A) · y = alpha · x for y.
public static Task SpSVAsync<T>(CsrMatrix<T> matrix, DeviceBuffer<T> x, DeviceBuffer<T> y, SparseTriangle triangle = SparseTriangle.Lower, SparseDiagonal diagonal = SparseDiagonal.NonUnit, T? alpha = null, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCsrMatrix<T>-
Square sparse CSR matrix A whose
triangleis referenced. xDeviceBuffer<T>-
Right-hand side vector (device).
yDeviceBuffer<T>-
Solution vector (device); must not alias
x. triangleSparseTriangle-
Triangle of A to read.
diagonalSparseDiagonal-
Whether the diagonal is implicit ones.
alphaT?-
Scale applied to x. Default: 1.
transposebool-
Solve with the transpose of A.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T
SpSVAsync<T>(CooMatrix<T>, DeviceBuffer<T>, DeviceBuffer<T>, SparseTriangle, SparseDiagonal, T?, bool, CudaStream?, CancellationToken)
Triangular solve op(A) · y = alpha · x for a COO matrix (row-major sorted entries).
public static Task SpSVAsync<T>(CooMatrix<T> matrix, DeviceBuffer<T> x, DeviceBuffer<T> y, SparseTriangle triangle = SparseTriangle.Lower, SparseDiagonal diagonal = SparseDiagonal.NonUnit, T? alpha = null, bool transpose = false, CudaStream? stream = null, CancellationToken ct = default) where T : unmanaged, INumberBase<T>Parameters
matrixCooMatrix<T>-
Square sparse CSR matrix A whose
triangleis referenced. xDeviceBuffer<T>-
Right-hand side vector (device).
yDeviceBuffer<T>-
Solution vector (device); must not alias
x. triangleSparseTriangle-
Triangle of A to read.
diagonalSparseDiagonal-
Whether the diagonal is implicit ones.
alphaT?-
Scale applied to x. Default: 1.
transposebool-
Solve with the transpose of A.
streamCudaStream?-
Optional CUDA stream.
nullcreates a private stream. ctCancellationToken-
Cancellation token.
Returns
Type Parameters
T