Matrix extensions
AbstractSparseMatrixExtension
ExtendableSparse.AbstractSparseMatrixExtension — Type
abstract type AbstractSparseMatrixExtension{Tv, Ti} <: AbstractSparseMatrix{Tv, Ti} endAbstract type for sparse matrix extension.
Subtypes T_ext must implement:
- Constructor
T_ext(m,n) SparseArrays.nnz(ext::T_ext)Base.size(ext::T_ext)Base.sum(extmatrices::Vector{T_ext}, csx): add csr or csc matrix and extension matrices (one per partition) and return csx matrixBase.+(ext::T_ext, csx)(optional) - Add extension matrix and csc/csr matrix, return csx matrixrawupdateindex!(ext::Text, op, v, i, j, tid) where {Tv, Ti}: Setext[i,j]op=v, possibly insert new entry into matrix.tidis a task or partition id
SparseMatrixLNK
ExtendableSparse.SparseMatrixLNK — Type
mutable struct SparseMatrixLNK{Tv, Ti<:Integer} <: ExtendableSparse.AbstractSparseMatrixExtension{Tv, Ti<:Integer}AbstractSparseMatrixExtension where entries are organized in the linked list sparse matrix format. This was the standard structure in ExtendableSparse v1.x.
Modeled after the linked list sparse matrix format described in the whitepaper and the SPARSEKIT2 source code by Y. Saad. He writes "This is one of the oldest data structures used for sparse matrix computations."
The relevant source formats.f is also available in the debian/science gitlab.
The advantage of the linked list structure is the fact that upon insertion of a new entry, the arrays describing the structure can grow at their respective ends and can be conveniently updated via push!. No copying of existing data is necessary.
Via the type aliases STExtendableSparseMatrixCSC, ExtendableSparseMatrixCSC, and ExtendableSparseMatrix this extension is used as default for handling scalar assembly.
m::Integer: Number of rows
n::Integer: Number of columns
nnz::Integer: Number of nonzeros
nentries::Integer: Length of arrays
colptr::Vector{Ti} where Ti<:Integer: Linked list of column entries. Initial length is n, it grows with each new entry.colptr[index] contains the next index in the list or zero, in the later case terminating the list which starts at index 1<=j<=n for each column j.
rowval::Vector{Ti} where Ti<:Integer: Row numbers. For each index it contains the zero (initial state) or the row numbers corresponding to the column entry list in colptr.Initial length is n, it grows with each new entry.
nzval::Vector: Nonzero entry values corresponding to each pair (colptr[index],rowval[index])Initial length is n, it grows with each new entry.
ExtendableSparse.SparseMatrixLNK — Method
SparseMatrixLNK(
m,
n
) -> ExtendableSparse.SparseMatrixLNK{Float64, Int64}
Constructor of empty matrix.
ExtendableSparse.SparseMatrixLNK — Method
SparseMatrixLNK(
csc::SparseMatrixCSC{Tv, Ti<:Integer}
) -> ExtendableSparse.SparseMatrixLNK
Constructor from SparseMatrixCSC.
ExtendableSparse.SparseMatrixLNK — Method
SparseMatrixLNK(
m,
n
) -> ExtendableSparse.SparseMatrixLNK{Float64, Int64}
Constructor of empty matrix.
ExtendableSparse.SparseMatrixLNK — Method
SparseMatrixLNK(
valuetype::Type{Tv},
indextype::Type{Ti<:Integer},
m,
n
) -> ExtendableSparse.SparseMatrixLNK
Constructor of empty matrix.
ExtendableSparse.SparseMatrixLNK — Method
SparseMatrixLNK(
valuetype::Type{Tv},
m,
n
) -> ExtendableSparse.SparseMatrixLNK{_A, Int64} where _A
Constructor of empty matrix.
SparseArrays.SparseMatrixCSC — Method
SparseMatrixCSC(
lnk::ExtendableSparse.SparseMatrixLNK
) -> SparseMatrixCSC
Constructor from SparseMatrixLNK.
Base.:+ — Method
+(
lnk::ExtendableSparse.SparseMatrixLNK{Tv, Ti<:Integer},
csc::SparseMatrixCSC
) -> SparseMatrixCSC
Add SparseMatrixCSC matrix and SparseMatrixLNK lnk, returning a SparseMatrixCSC
Base.getindex — Method
getindex(
lnk::ExtendableSparse.SparseMatrixLNK{Tv, Ti},
i,
j
) -> Any
Return value stored for entry or zero if not found
Base.setindex! — Method
setindex!(
lnk::ExtendableSparse.SparseMatrixLNK,
v,
i,
j
) -> ExtendableSparse.SparseMatrixLNK
Update value of existing entry, otherwise extend matrix if v is nonzero.
ExtendableSparse.rawupdateindex! — Method
rawupdateindex!(
lnk::ExtendableSparse.SparseMatrixLNK{Tv, Ti},
op,
v,
i,
j
) -> ExtendableSparse.SparseMatrixLNK{Tv, Ti} where {Tv, Ti}
Update element of the matrix with operation op. It assumes that op(0,0)==0. If v is zero a new entry is created nevertheless.
ExtendableSparse.updateindex! — Method
updateindex!(
lnk::ExtendableSparse.SparseMatrixLNK{Tv, Ti},
op,
v,
i,
j
) -> ExtendableSparse.SparseMatrixLNK{Tv, Ti} where {Tv, Ti}
Update element of the matrix with operation op. It assumes that op(0,0)==0. If v is zero, no new entry is created.
SparseArrays.nnz — Method
nnz(lnk::ExtendableSparse.SparseMatrixLNK) -> Integer
Return number of nonzero entries.
SparseMatrixDILNKC
ExtendableSparse.SparseMatrixDILNKC — Type
mutable struct SparseMatrixDILNKC{Tv, Ti<:Integer} <: ExtendableSparse.AbstractSparseMatrixExtension{Tv, Ti<:Integer}AbstractSparseMatrixExtension where entries are stored as linked list, but where – in difference to SparseMatrixLNK – the pointer to first index of column j is stored in a dictionary.
Thus this format – similar to SparseMatrixDict – avoids to store a vector of the length of unknowns indicating the first column indices, avoiding storage overhead during parallel assembly.
Via the type alias MTExtendableSparseMatrixCSC, this extension is used as default for handling parallel assembly.
m::Integer: Number of rows
n::Integer: Number of columns
nnz::Integer: Number of nonzeros
nentries::Integer: Length of arrays
colptr::Vector{Ti} where Ti<:Integer: Linked list of column entries. Initial length is n, it grows with each new entry.colptr[index] contains the next index in the list or zero, in the later case terminating the list which starts at index 1<=j<=n for each column j.
colstart::Dict{Ti, Ti} where Ti<:Integer: Dictionary to store start indices of columns
rowval::Vector{Ti} where Ti<:Integer: Row numbers. For each index it contains the zero (initial state) or the row numbers corresponding to the column entry list in colptr.
nzval::Vector: Nonzero entry values corresponding to each pair (colptr[index],rowval[index])
ExtendableSparse.SparseMatrixDILNKC — Method
SparseMatrixDILNKC(
m,
n
) -> ExtendableSparse.SparseMatrixDILNKC{Float64, Int64}
Constructor of empty matrix.
ExtendableSparse.SparseMatrixDILNKC — Method
SparseMatrixDILNKC(
csc::SparseMatrixCSC{Tv, Ti<:Integer}
) -> ExtendableSparse.SparseMatrixDILNKC
Constructor from SparseMatrixCSC.
ExtendableSparse.SparseMatrixDILNKC — Method
SparseMatrixDILNKC(
m,
n
) -> ExtendableSparse.SparseMatrixDILNKC{Float64, Int64}
Constructor of empty matrix.
ExtendableSparse.SparseMatrixDILNKC — Method
SparseMatrixDILNKC(
valuetype::Type{Tv},
indextype::Type{Ti<:Integer},
m,
n
) -> ExtendableSparse.SparseMatrixDILNKC
Constructor of empty matrix.
ExtendableSparse.SparseMatrixDILNKC — Method
SparseMatrixDILNKC(
valuetype::Type{Tv},
m,
n
) -> ExtendableSparse.SparseMatrixDILNKC{_A, Int64} where _A
Constructor of empty matrix.
SparseArrays.SparseMatrixCSC — Method
SparseMatrixCSC(
lnk::ExtendableSparse.SparseMatrixDILNKC
) -> SparseMatrixCSC{Float64, Int64}
Constructor from SparseMatrixDILNKC.
Base.getindex — Method
getindex(
lnk::ExtendableSparse.SparseMatrixDILNKC{Tv, Ti},
i,
j
) -> Any
Return value stored for entry or zero if not found
Base.setindex! — Method
setindex!(
lnk::ExtendableSparse.SparseMatrixDILNKC,
v,
i,
j
) -> ExtendableSparse.SparseMatrixDILNKC
Update value of existing entry, otherwise extend matrix if v is nonzero.
ExtendableSparse.add_directly — Method
add_directly(
lnk::ExtendableSparse.SparseMatrixDILNKC{Tv, Ti<:Integer},
csc::SparseMatrixCSC
) -> SparseMatrixCSC
Add lnk and csc without creation of intermediate data. (to be fixed)
ExtendableSparse.add_via_COO — Method
add_via_COO(
lnk::ExtendableSparse.SparseMatrixDILNKC{Tv, Ti<:Integer},
csc::SparseMatrixCSC
) -> SparseMatrixCSC
Add lnk and csc via interim COO (coordinate) format, i.e. arrays I,J,V.
ExtendableSparse.addentry! — Method
addentry!(
lnk::ExtendableSparse.SparseMatrixDILNKC,
i,
j,
k,
k0
) -> Integer
Add entry.
ExtendableSparse.findindex — Method
findindex(
lnk::ExtendableSparse.SparseMatrixDILNKC,
i,
j
) -> Union{Tuple{Int64, Integer}, Tuple{Integer, Int64}}
Find index in matrix.
ExtendableSparse.rawupdateindex! — Method
rawupdateindex!(
lnk::ExtendableSparse.SparseMatrixDILNKC{Tv, Ti},
op,
v,
i,
j
) -> ExtendableSparse.SparseMatrixDILNKC
Update element of the matrix with operation op. It assumes that op(0,0)==0. If v is zero a new entry is created nevertheless.
ExtendableSparse.updateindex! — Method
updateindex!(
lnk::ExtendableSparse.SparseMatrixDILNKC{Tv, Ti},
op,
v,
i,
j
) -> ExtendableSparse.SparseMatrixDILNKC
Update element of the matrix with operation op. It assumes that op(0,0)==0. If v is zero, no new entry is created.
SparseArrays.nnz — Method
nnz(lnk::ExtendableSparse.SparseMatrixDILNKC) -> Integer
Return number of nonzero entries.
SparseMatrixDict
ExtendableSparse.SparseMatrixDict — Type
mutable struct SparseMatrixDict{Tv, Ti} <: ExtendableSparse.AbstractSparseMatrixExtension{Tv, Ti}AbstractSparseMatrixExtension extension where entries are organized as dictionary. This is meant as an example implementation to show how a sparse matrix extension could be implemented. As dictionary access tends to be slow, it is not meant for general use.
An advantage of this format is the fact that it avoids to store a vector of the length of unknowns indicating the first column indices, avoiding storage overhead during parallel assembly.
m::Any: Number of rows
n::Any: Number of columns
values::Dict{Pair{Ti, Ti}, Tv} where {Tv, Ti}: Dictionary with pairs of integers as keys containing values
ExtendableSparse.SparseMatrixDict — Method
SparseMatrixDict(
m,
n
) -> ExtendableSparse.SparseMatrixDict{Float64, Int64}
ExtendableSparse.SparseMatrixDict — Method
SparseMatrixDict(Acsc::SparseMatrixCSC{Tv, Ti}) -> Any
ExtendableSparse.SparseMatrixDict — Method
SparseMatrixDict(
valuetype::Type{Tv},
indextype::Type{Ti<:Integer},
m,
n
) -> ExtendableSparse.SparseMatrixDict{Tv, Ti} where {Tv, Ti<:Integer}
ExtendableSparse.SparseMatrixDict — Method
SparseMatrixDict(
valuetype::Type{Tv},
m,
n
) -> ExtendableSparse.SparseMatrixDict{T, Int64} where T
Base.getindex — Method
getindex(
m::ExtendableSparse.SparseMatrixDict{Tv},
i,
j
) -> Any
Base.setindex! — Method
setindex!(
m::ExtendableSparse.SparseMatrixDict,
v,
i,
j
) -> Any
ExtendableSparse.rawupdateindex! — Method
rawupdateindex!(
m::ExtendableSparse.SparseMatrixDict{Tv, Ti},
op,
v,
i,
j
) -> Any
ExtendableSparse.reset! — Method
reset!(
m::ExtendableSparse.SparseMatrixDict{Tv, Ti}
) -> Dict{Pair{_A, _B}} where {_A, _B}
ExtendableSparse.updateindex! — Method
updateindex!(
m::ExtendableSparse.SparseMatrixDict{Tv, Ti},
op,
v,
i,
j
) -> Any
SparseArrays.nnz — Method
nnz(m::ExtendableSparse.SparseMatrixDict) -> Int64
SparseArrays.sparse — Method
sparse(
mat::ExtendableSparse.SparseMatrixDict{Tv, Ti}
) -> SparseMatrixCSC