MyraMath
|
Stores an IxJ matrix A in compressed sparse column format. More...
#include <SparseMatrix.h>
Public Types | |
typedef std::pair< CSparseMatrixRange< Number >, CSparseMatrixRange< Number > > | CPair |
Useful typedefs. | |
typedef std::pair< SparseMatrixRange< Number >, SparseMatrixRange< Number > > | Pair |
Public Member Functions | |
SparseMatrix () | |
Default constructor, makes 0x0 empty SparseMatrix. | |
SparseMatrix (const PatternRange &P) | |
Constructs SparseMatrix with specified Pattern, filled with zeros. Populate later using operator(i,j) | |
SparseMatrix (const SparseMatrix &that) | |
Copy constructor. | |
void | swap (SparseMatrix &that) |
Member swap. | |
void | swap (Pattern &that) |
SparseMatrix (SparseMatrix &&that) | |
Move constructor, default construct and swap idiom. | |
SparseMatrix (Pattern &&that) | |
SparseMatrix & | operator= (SparseMatrix that) |
Copy-assignment operator, copy construct and swap idiom. | |
SparseMatrix (const CSparseMatrixRange< Number > &that) | |
Constructs from a SparseMatrixRange<Number> (same size, values copied) | |
SparseMatrix (InputStream &in) | |
InputStream constructor, complements write(OutputStream) method. | |
void | write (OutputStream &out) const |
Writes to OutputStream, complements InputStream constructor. | |
const SparseMatrix< Number > & | add_const () const |
Returns const reference to *this. | |
~SparseMatrix () | |
Releases internal resources. | |
std::pair< int, int > | size () const |
Size inspector. | |
int | n_nonzeros () const |
Counts nonzeros in A(:,:) | |
int | n_nonzeros (int j) const |
Counts nonzeros in A(:,j) | |
bool | test (int i, int j) const |
Tests for a structural nonzero. | |
PatternRange | pattern () const |
Returns the nonzero Pattern over all of A(:,:) | |
std::vector< int > | pattern (int j) const |
Returns the (sorted) nonzero pattern of A(:,j) | |
template<class Functor > | |
void | transform (const Functor &f) |
Overwrites every A(i,j) in this SparseMatrix with f(A(i,j)). | |
template<class Functor > | |
void | transform_triangle (const Functor &f, char uplo) |
Overwrites every A(i,j) in the 'U'pper or 'L'ower triangle of this SparseMatrix with f(A(i,j)). | |
template<class Functor > | |
void | transform_diagonal (const Functor &f) |
Overwrites every A(ij,ij) on the diagonal of this SparseMatrix with f(A(ij,ij)). | |
SparseMatrix & | operator= (const CSparseMatrixRange< Number > &that) |
Assigns this = that. | |
void | operator*= (Number alpha) |
Scales this *= alpha. | |
void | operator/= (Number alpha) |
Scales this /= alpha. | |
SparseMatrix< Number > | operator- () |
Unary minus (sign negation). | |
void | debug (std::ostream &out) const |
Prints raw CSC-data on supplied ostream, used for debugging. | |
CSparseMatrixRange< Number > | range () const |
Explicit conversion, returns a SparseMatrixRange over all of *this. | |
SparseMatrixRange< Number > | range () |
Explicit conversion, returns a SparseMatrixRange over all of *this. | |
operator CSparseMatrixRange< Number > () const | |
Implicit conversion into a SparseMatrixRange. | |
operator SparseMatrixRange< Number > () | |
Implicit conversion into a SparseMatrixRange. | |
CSparseMatrixRange< Number > | window (int i0, int i1, int j0, int j1) const |
Returns a SparseMatrixRange over this(i0:i1,j0:j1) | |
SparseMatrixRange< Number > | window (int i0, int i1, int j0, int j1) |
Returns a SparseMatrixRange over this(i0:i1,j0:j1) | |
Array2< CSparseMatrixRange< Number > > | windows (const intCRange &i, const intCRange &j) const |
Tile rows and columns using given sizes. | |
Array2< SparseMatrixRange< Number > > | windows (const intCRange &i, const intCRange &j) |
Tile rows and columns using given sizes. | |
const Number * | pointer (int i, int j) const |
Returns pointer to A(i,j), returns nullptr if structural zero. | |
Number * | pointer (int i, int j) |
Returns pointer to A(i,j), returns nullptr if structural zero. | |
const Number & | operator() (int i, int j) const |
Returns reference to A(i,j), undefined behavior if structural zero. | |
Number & | operator() (int i, int j) |
Returns reference to A(i,j), undefined behavior if structural zero. | |
const Number & | at (int i, int j) const |
Returns reference to A(i,j), throws if structural zero. | |
Number & | at (int i, int j) |
Returns reference to A(i,j), throws if structural zero. | |
CSparseMatrixIterator< Number > | begin () const |
Returns iterators over all of A(:,:) | |
CSparseMatrixIterator< Number > | end () const |
Returns iterators over all of A(:,:) | |
SparseMatrixIterator< Number > | begin () |
Returns iterators over all of A(:,:) | |
SparseMatrixIterator< Number > | end () |
Returns iterators over all of A(:,:) | |
CSparseMatrixIterator< Number > | begin (int j) const |
Returns iterators over column A(:,j) | |
CSparseMatrixIterator< Number > | end (int j) const |
Returns iterators over column A(:,j) | |
SparseMatrixIterator< Number > | begin (int j) |
Returns iterators over column A(:,j) | |
SparseMatrixIterator< Number > | end (int j) |
Returns iterators over column A(:,j) | |
CSparseMatrixRange< Number > | row (int i) const |
Returns a SparseMatrixRange over this(i,:) | |
SparseMatrixRange< Number > | row (int i) |
Returns a SparseMatrixRange over this(i,:) | |
CSparseMatrixRange< Number > | rows (int i0, int i1) const |
Returns a SparseMatrixRange over this(i0:i1,:) | |
SparseMatrixRange< Number > | rows (int i0, int i1) |
Returns a SparseMatrixRange over this(i0:i1,:) | |
CSparseMatrixRange< Number > | top (int i) const |
Returns a SparseMatrixRange over the i topmost rows, this(0:i,:) | |
SparseMatrixRange< Number > | top (int i) |
Returns a SparseMatrixRange over the i topmost rows, this(0:i,:) | |
CSparseMatrixRange< Number > | cut_top (int i) const |
Returns a SparseMatrixRange that cuts the i topmost rows, this(i:I,:) | |
SparseMatrixRange< Number > | cut_top (int i) |
Returns a SparseMatrixRange that cuts the i topmost rows, this(i:I,:) | |
CPair | split_top (int i) const |
Splits by rows, returns [this->top(i), this->cut_top(i)]. | |
Pair | split_top (int i) |
Splits by rows, returns [this->top(i), this->cut_top(i)]. | |
CSparseMatrixRange< Number > | bottom (int i) const |
Returns a SparseMatrixRange over the i bottommost rows, this(I-i:I,:) | |
SparseMatrixRange< Number > | bottom (int i) |
Returns a SparseMatrixRange over the i bottommost rows, this(I-i:I,:) | |
CSparseMatrixRange< Number > | cut_bottom (int i) const |
Returns a SparseMatrixRange that cuts the i bottommost rows, this(0:I-i,:) | |
SparseMatrixRange< Number > | cut_bottom (int i) |
Returns a SparseMatrixRange that cuts the i bottommost rows, this(0:I-i,:) | |
CPair | split_bottom (int i) const |
Splits by rows, returns [this->cut_bottom(i), this->bottom(i)]. | |
Pair | split_bottom (int i) |
Splits by rows, returns [this->cut_bottom(i), this->bottom(i)]. | |
Array1< CSparseMatrixRange< Number > > | rows (const intCRange &i) const |
Returns {this.rows(0:i0,:), this.rows(i0:i0+i1,:), ...}, tiling by rows. | |
Array1< SparseMatrixRange< Number > > | rows (const intCRange &i) |
Returns {this.rows(0:i0,:), this.rows(i0:i0+i1,:), ...}, tiling by rows. | |
CSparseMatrixRange< Number > | column (int j) const |
Returns a SparseMatrixRange over this(:,j) | |
SparseMatrixRange< Number > | column (int i) |
Returns a SparseMatrixRange over this(:,j) | |
CSparseMatrixRange< Number > | columns (int j0, int j1) const |
Returns a SparseMatrixRange over this(:,j0:j1) | |
SparseMatrixRange< Number > | columns (int j0, int j1) |
Returns a SparseMatrixRange over this(:,j0:j1) | |
CSparseMatrixRange< Number > | left (int j) const |
Returns a SparseMatrixRange over the j leftmost columns, this(:,0:j) | |
SparseMatrixRange< Number > | left (int j) |
Returns a SparseMatrixRange over the j leftmost columns, this(:,0:j) | |
CSparseMatrixRange< Number > | cut_left (int j) const |
Returns a SparseMatrixRange that cuts the j leftmost columns, this(:,j:J) | |
SparseMatrixRange< Number > | cut_left (int j) |
Returns a SparseMatrixRange that cuts the j leftmost columns, this(:,j:J) | |
CPair | split_left (int j) const |
Splits by columns, returns [this->left(j), this->cut_left(j)]. | |
Pair | split_left (int j) |
Splits by columns, returns [this->left(j), this->cut_left(j)]. | |
CSparseMatrixRange< Number > | right (int j) const |
Returns a SparseMatrixRange over the j rightmost columns, this(:,J-j:J) | |
SparseMatrixRange< Number > | right (int j) |
Returns a SparseMatrixRange over the j rightmost columns, this(:,J-j:J) | |
CSparseMatrixRange< Number > | cut_right (int j) const |
Returns a SparseMatrixRange that cuts the j rightmost columns, this(:,0:J-j) | |
SparseMatrixRange< Number > | cut_right (int j) |
Returns a SparseMatrixRange that cuts the j rightmost columns, this(:,0:J-j) | |
CPair | split_right (int j) const |
Splits by columns, returns [this->cut_right(j), this->right(j)]. | |
Pair | split_right (int j) |
Splits by columns, returns [this->cut_right(j), this->right(j)]. | |
Array1< CSparseMatrixRange< Number > > | columns (const intCRange &j) const |
Returns {this.columns(:,0:j0), this.columns(:,j0:j0+j1), ...}, tiling by columns. | |
Array1< SparseMatrixRange< Number > > | columns (const intCRange &j) |
Returns {this.columns(:,0:j0), this.columns(:,j0:j0+j1), ...}, tiling by columns. | |
Matrix< Number > | make_Matrix () const |
Accumulates *this onto a Matrix<Number>. | |
void | make_Matrix (const MatrixRange< Number > &A) const |
Accumulates *this onto a Matrix<Number>. | |
Static Public Member Functions | |
static SparseMatrix< Number > | identity (int IJ) |
Generates an identity SparseMatrix of specified size. | |
static SparseMatrix< Number > | random (int I, int J, int N) |
Generates a random SparseMatrix with size IxJ and (approximately) N nonzeros. | |
static SparseMatrix< Number > | random (const PatternRange &P) |
Generates a random SparseMatrix with Pattern P. | |
static SparseMatrix< Number > | zeros (int I, int J) |
Generates a zero-valued SparseMatrix of specified size. Empty, no storage required. | |
static SparseMatrix< Number > | zeros (const PatternRange &P) |
Generates a zero-valued SparseMatrix with explicit strucural zeros given by the Pattern P. | |
static SparseMatrix< Number > | ones (const PatternRange &P) |
Generates a ones SparseMatrix with Pattern P. | |
static SparseMatrix< Number > | fill (const PatternRange &P, Number c) |
Generates a SparseMatrix with Pattern P, filled with constant c. | |
static SparseMatrix< Number > | fill (const intCRange &i, const intCRange &j, const std::vector< Number > &v) |
Generates a SparseMatrix from coordinate format. Works like A = sparse(i,j,v) in Matlab/Octave. Duplicate entries are summed. | |
static SparseMatrix< Number > | swap (int I, int J, std::vector< int > &Ao, std::vector< int > &Ai, std::vector< Number > &Av) |
Generates a SparseMatrix from CSC arrays (offsets/indices/values). Note the inputs are destroyed/swapped-from. | |
static SparseMatrix< Number > | evaluate (const PatternRange &P, const Expression< 2, Number > &e) |
Generates a SparseMatrix with Pattern P, by evaluating an arity-2 Expression of Number at every nonzero P(i,j) | |
Stores an IxJ matrix A in compressed sparse column format.