SparseMatricesCSR.jl
SparseMatricesCSR.SparseMatrixCSR
SparseMatricesCSR.SparseMatrixCSR
SparseMatricesCSR.SparseMatrixCSR
SparseMatricesCSR.SparseMatrixCSR
SparseMatricesCSR.SparseMatrixCSR
SparseMatricesCSR.SymSparseMatrixCSR
Base.count
Base.count
SparseArrays.findnz
SparseArrays.findnz
SparseArrays.issparse
SparseArrays.issparse
SparseArrays.nnz
SparseArrays.nnz
SparseArrays.nonzeros
SparseArrays.nonzeros
SparseArrays.nzrange
SparseArrays.nzrange
SparseMatricesCSR.colvals
SparseMatricesCSR.colvals
SparseMatricesCSR.getBi
SparseMatricesCSR.getBi
SparseMatricesCSR.getoffset
SparseMatricesCSR.getoffset
SparseMatricesCSR.sparsecsr
SparseMatricesCSR.symsparsecsr
SparseMatricesCSR.SparseMatrixCSR
— TypeSparseMatrixCSR{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 columnsn::Int
Number of rowsrowptr::Vector{Ti}
Rowi
(1-based) innzval
vector at indices (1-based)(rowptr[i]+(1-Bi)):(rowptr[i+1]+(1-Bi)-1)
colval::Vector{Ti}
Col indices (Bi
-based) of stored valuesnzval::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}
SparseMatricesCSR.SparseMatrixCSR
— MethodSparseMatrixCSR(a::AbstractMatrix}
Build a 1-based SparseMatrixCSR
from an AbstractMatrix
.
SparseMatricesCSR.SparseMatrixCSR
— MethodSparseMatrixCSR(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.
SparseMatricesCSR.SparseMatrixCSR
— MethodSparseMatrixCSR(a::SparseMatrixCSC}
Build a 1-based SparseMatrixCSR
from a SparseMatrixCSC
.
SparseMatricesCSR.SparseMatrixCSR
— MethodSparseMatrixCSR{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.
SparseMatricesCSR.SymSparseMatrixCSR
— Typestruct 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.
Base.count
— Methodcount(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.
Base.count
— Methodcount(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.
SparseArrays.findnz
— Methodfindnz(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
.
SparseArrays.findnz
— Methodfindnz(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
.
SparseArrays.issparse
— Methodissparse(S::SparseMatrixCSR)
Returns true
.
SparseArrays.issparse
— Methodissparse(S::SymSparseMatrixCSR)
Returns true
.
SparseArrays.nnz
— Methodnnz(S::SymSparseMatrixCSR)
Returns the number of stored elements in a sparse array, which correspond to the nonzero entries in the upper triangle and diagonal.
SparseArrays.nnz
— Methodnnz(S::SparseMatrixCSR)
Returns the number of stored (filled) elements in a sparse array.
SparseArrays.nonzeros
— Methodnonzeros(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.
SparseArrays.nonzeros
— Methodnonzeros(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.
SparseArrays.nzrange
— Methodnzrange(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
.
SparseArrays.nzrange
— Methodnzrange(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
.
SparseMatricesCSR.colvals
— Methodcolvals(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
.
SparseMatricesCSR.colvals
— Methodcolvals(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
.
SparseMatricesCSR.getBi
— MethodgetBi(S::SparseMatrixCSR{Bi}) where {Bi}
Return Bi
.
SparseMatricesCSR.getBi
— MethodgetBi(S::SymSparseMatrixCSR{Bi}) where {Bi}
Return Bi
.
SparseMatricesCSR.getoffset
— Methodgetoffset(S::SparseMatrixCSR{Bi}) where {Bi}
Return 1-Bi
. Useful to convert from 1-based to Bi
-based indexing (by subtracting the offset).
SparseMatricesCSR.getoffset
— Methodgetoffset(S::SymSparseMatrixCSR{Bi}) where {Bi}
Return 1-Bi
. Useful to convert from 1-based to Bi
-based indexing (by subtracting the offset).
SparseMatricesCSR.sparsecsr
— Methodsparsecsr(args...)
sparsecsr(::Val{Bi},args...) where Bi
Create a SparseMatrixCSR
with Bi
-based indexing (1 by default) from the same args...
as one constructs a SparseMatrixCSC
with the SparseArrays.sparse
function.
SparseMatricesCSR.symsparsecsr
— Methodsymsparsecsr(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).