Matrices
SparseDirectSolver.CSR — Type
CSR{T,INT,VI,VT}Compressed sparse row matrix on any backend: rowptr::VI, colval::VI (VI <: AbstractVector{INT}), nzval::VT (VT <: AbstractVecOrMat{T}), nrows, ncols, index::IndexBase and transposed::Bool.
indexis the base ofrowptr/colval(INDEX_ONEorINDEX_ZERO); the arrays are never rebased in place.transposed = truemeans the stored CSR arrays describetranspose(M)of the matrixMthe caller means (for example a CSC matrix reinterpreted as the CSR of its transpose, seecsr_of_transpose).size,nnzandSparseMatrixCSC(A)refer to the stored CSR matrix; consumers honor the flag.- A uniform batch shares
rowptr/colval; its values are either a vector of lengthnbatch * nnz(members one after the other) or annnz × nbatchmatrix.
Constructors:
CSR(rowptr, colval, nzval[, nrows, ncols]; index = 'O', transposed = false)
CSR(A::SparseMatrixCSC; index = 'O')The first wraps the arrays without copying (square nrows = ncols = length(rowptr) - 1 when the sizes are omitted); the second builds the CSR arrays of A on the host. Only lengths are validated, never array contents, so no device memory is read.
SparseDirectSolver.csr_of_transpose — Function
csr_of_transpose(A::SparseMatrixCSC) -> CSRZero-copy reinterpretation of the CSC matrix A (m × n) as the CSR matrix of transpose(A) (n × m): A.colptr becomes rowptr, A.rowval becomes colval, the arrays are shared and transposed = true records that the caller means A. This is how MadNLP passes colPtr/rowVal (PLAN §1.1). A solver on such a matrix reads it with the view flipped ('L' ↔ 'U'; for "G" the view is ignored). Raises InvalidValueError when A.rowval or A.nzval is longer than nnz(A) (a SparseMatrixCSC may keep spare capacity, which the shared CSR arrays cannot describe).
SparseDirectSolver.to_backend — Function
to_backend(A, backend) -> CSRA (a SparseMatrixCSC or a CSR) as a CSR whose arrays live on the KernelAbstractions backend. A SparseMatrixCSC is first converted on the host (index keyword as in CSR(A; index)); arrays already on backend are not copied.
to_backend(A::SparseMatrixCSC, ::CUDABackend; index = 'O') -> CSRCSR arrays of A built on the host, then uploaded as CuVectors.
to_backend(A::SparseMatrixCSC, ::ROCBackend; index = 'O') -> CSRCSR arrays of A built on the host, then uploaded as ROCVectors.
SparseDirectSolver.nbatch — Function
nbatch(A::CSR)
nbatch(desc::MatrixDescriptor)Number of matrices in a uniform batch: size(nzval, 2) for matrix values, length(nzval) ÷ nnz for vector values (1 for a plain matrix).
SparseDirectSolver.MatrixDescriptor — Type
MatrixDescriptor{T,A}Dense right-hand side / solution descriptor (≅ CudssMatrix for dense data): data::Union{Nothing,A}, nrows, ncols, nbatch, transposed. nrows × ncols is the logical size of one batch member. With transposed = true the data is row-major, i.e. a column-major array of size (ncols, nrows), as in CUDSS.jl.
MatrixDescriptor(T, n; nbatch = 1) # n × 1, no data yet
MatrixDescriptor(T, m, n; nbatch = 1, transposed = false) # as CUDSS.jl: transposed gives n × m
MatrixDescriptor(x::AbstractArray; transposed = false) # vector, matrix or (n, p, nbatch) arrayupdate! re-points the descriptor to a new buffer without copying. Descriptors created without data accept any AbstractArray{T}; descriptors created from an array accept arrays of the same type.
update! also replaces the data of a MatrixDescriptor.