SparseMatricesCSR.jl

SparseMatricesCSR.SparseMatrixCSRType
SparseMatrixCSR{Bi,Tv,Ti<:Integer} <: AbstractSparseMatrix{Tv,Ti}

Matrix type for storing sparse matrices in the Compressed Sparse Row format with Bi-based indexing (typically 0 or 1). The standard way of constructing SparseMatrixCSR is through the sparsecsr function.

Properties

  • m::Int Number of columns
  • n::Int Number of rows
  • rowptr::Vector{Ti} Row i (1-based) in nzval vector at indices (1-based) (rowptr[i]+(1-Bi)):(rowptr[i+1]+(1-Bi)-1)
  • colval::Vector{Ti} Col indices (Bi-based) of stored values
  • nzval::Vector{Tv} Stored values, typically non zeros

Inner constructor

SparseMatrixCSR{Bi}(
  m::Integer,
  n::Integer,
  rowptr::Vector{Ti},
  colval::Vector{Ti},
  nzval::Vector{Tv}) where {Bi,Tv,Ti<:Integer}
source
SparseMatricesCSR.SparseMatrixCSRMethod
SparseMatrixCSR(a::Transpose{Tv,<:SparseMatrixCSC} where Tv)

Build a 1-based SparseMatrixCSR from the lazy transpose of a SparseMatrixCSC. The resulting matrix takes ownership of the internal storage of input matrix. Modifying the values of one, will mutate also the other.

source
SparseMatricesCSR.SparseMatrixCSRMethod
SparseMatrixCSR{Bi}(a::Transpose{Tv,<:SparseMatrixCSC} where Tv) where Bi

Build a Bi-based SparseMatrixCSR from the lazy transpose of a SparseMatrixCSC. The resulting matrix takes ownership of the internal storage of input matrix for any Bi and modifies the internal storage when Bi != 1. The input matrix will become unusable in the latter case.

source
SparseMatricesCSR.SymSparseMatrixCSRType
struct SymSparseMatrixCSR{Bi,T,Ti<:Integer} <: AbstractSparseMatrix{T,Ti}
  uppertrian :: SparseMatrixCSR{Bi,T,Ti}
end

Matrix type for storing symmetric sparse matrices in the Compressed Sparse Row format with Bi-based indexing (typically 0 or 1). Only the upper triangle is stored (including the non zero diagonal entries), which is represented by a SparseMatrixCSR. The standard way of constructing a SymSparseMatrixCSR is through the symsparsecsr function.

source
Base.countMethod
count(pred, S::SparseMatrixCSR)
count(S::SparseMatrixCSR)

Count the number of elements in nonzeros(S) for which predicate pred returns true. If pred not given, it counts the number of true values.

source
Base.countMethod
count(pred, S::SymSparseMatrixCSR)
count(S::SymSparseMatrixCSR)

Count the number of elements in nonzeros(S) for which predicate pred returns true. If pred not given, it counts the number of true values.

source
SparseArrays.findnzMethod
findnz(S::SymSparseMatrixCSR)

Return a tuple (I, J, V) where I and J are the row and column 1-based indices of the stored ("structurally non-zero in diagonal + upper trianle") values in sparse matrix A, and V is a vector of the values. The returned vectors are newly allocated and are unrelated to the internal storage of matrix S.

source
SparseArrays.findnzMethod
findnz(S::SparseMatrixCSR{Bi,Tv,Ti})

Return a tuple (I, J, V) where I and J are the row and column 1-based indices of the stored ("structurally non-zero") values in sparse matrix A, and V is a vector of the values. The returned vectors are newly allocated and are unrelated to the internal storage of matrix S.

source
SparseArrays.nnzMethod
nnz(S::SymSparseMatrixCSR)

Returns the number of stored elements in a sparse array, which correspond to the nonzero entries in the upper triangle and diagonal.

source
SparseArrays.nnzMethod
nnz(S::SparseMatrixCSR)

Returns the number of stored (filled) elements in a sparse array.

source
SparseArrays.nonzerosMethod
nonzeros(S::SparseMatrixCSR)

Return a vector (1-based) of the structural nonzero values in sparse array S. This includes zeros that are explicitly stored in the sparse array. The returned vector points directly to the internal nonzero storage of S, and any modifications to the returned vector will mutate S as well.

source
SparseArrays.nonzerosMethod
nonzeros(S::SymSparseMatrixCSR)

Return a vector (1-based) of the structural nonzero values in sparse array S. This includes zeros that are explicitly stored in the sparse array, which correspond to the nonzero entries in the upper triangle and diagonal. The returned vector points directly to the internal nonzero storage of S, and any modifications to the returned vector will mutate S as well.

source
SparseArrays.nzrangeMethod
nzrange(S::SymSparseMatrixCSR, row::Integer)

Return the range of indices to the structural nonzero values of a sparse matrix row section being in the diagonal or upper triangle. The returned range of indices is always 1-based even for Bi != 1.

source
SparseArrays.nzrangeMethod
nzrange(S::SparseMatrixCSR{Bi}, row::Integer) where {Bi}

Return the range of indices to the structural nonzero values of a sparse matrix row. The returned range of indices is always 1-based even for Bi != 1.

source
SparseMatricesCSR.colvalsMethod
colvals(S::SparseMatrixCSR{Bi}) where {Bi}

Return a vector of the col indices of S. The stored values are indexes to arrays with Bi-based indexing, but the colvals(S) array itself is a standard 1-based Julia Vector. Any modifications to the returned vector will mutate S as well. Providing access to how the col indices are stored internally can be useful in conjunction with iterating over structural nonzero values. See also nonzeros and nzrange.

source
SparseMatricesCSR.colvalsMethod
colvals(S::SparseMatrixCSR)

Return a vector of the col indices of S. The stored values are indexes to arrays with Bi-based indexing, but the colvals(S) array itself is a standard 1-based Julia Vector. Any modifications to the returned vector will mutate S as well. Providing access to how the col indices are stored internally can be useful in conjunction with iterating over structural nonzero values. See also nonzeros and nzrange.

source
SparseMatricesCSR.getoffsetMethod
getoffset(S::SparseMatrixCSR{Bi}) where {Bi}

Return 1-Bi. Useful to convert from 1-based to Bi-based indexing (by subtracting the offset).

source
SparseMatricesCSR.getoffsetMethod
getoffset(S::SymSparseMatrixCSR{Bi}) where {Bi}

Return 1-Bi. Useful to convert from 1-based to Bi-based indexing (by subtracting the offset).

source
SparseMatricesCSR.symsparsecsrMethod
symsparsecsr(args...;symmetrize::Bool=false)
symsparsecsr(::Val{Bi},args...;symmetrize::Bool=false) where Bi

Create a SymSparseMatrixCSR with Bi-based indexing (1 by default) from the same args... as one constructs a SparseMatrixCSC with the sparse function. If symmetrize == false (the default) the given arguments should only describe the upper triangle of the matrix (including non zero diagonal values). If symmetrize == true a non symmetric input is accepted and it will be symmetrized in-place (i.e., changing the input arguments).

source