|
| CoordMatrix () |
| Default constructor. More...
|
|
| CoordMatrix (int n, int m) |
| Constructor to make empty n x m matrix. More...
|
|
| CoordMatrix (int n, int m, int nz, const int *row, const int *col, const int *val) |
| Constructor to make n x m matrix from row, column and data triplets. More...
|
|
| CoordMatrix (const CoordMatrix &mat) |
| Copy constructor. More...
|
|
| CoordMatrix (const class CRowMatrix &mat) |
| Constructor for conversion from compressed row matrix. More...
|
|
| CoordMatrix (const class CColMatrix &mat) |
| Constructor for conversion from compressed column matrix. More...
|
|
| CoordMatrix (const class Matrix &mat) |
| Constructor for conversion from unknown matrix type. More...
|
|
| ~CoordMatrix () |
| Destructor. More...
|
|
int | columns (void) const |
| Returns the number of columns in the matrix. More...
|
|
int | rows (void) const |
| Returns the number of rows in the matrix. More...
|
|
void | size (int &n, int &m) const |
| Returns the number of columns and number of columns in nn and mm. More...
|
|
int | nz_elements (void) const |
| Returns the number of non-zero elements in the matrix. More...
|
|
int | capacity (void) const |
| Returns the number of elements allocated for matrix. More...
|
|
void | resize (int n, int m) |
| Resizes the matrix to size n x m. More...
|
|
void | merge (CoordMatrix &mat) |
| Merges matrix mat into the matrix leaving mat empty. More...
|
|
void | clear (void) |
| Clear non-zero matrix elements, set all elements to zero. More...
|
|
void | clear (int i, int j) |
| Clear matrix element (i,j). More...
|
|
void | reserve (int size) |
| Reserve memory for size matrix elements. More...
|
|
void | order_ascending_row_column (void) |
| Order (sort) matrix data in ascending (row,column) index order. More...
|
|
void | order_ascending_column_row (void) |
| Order (sort) matrix data in ascending (column,row) index order. More...
|
|
void | debug_print (std::ostream &os) const |
| Print debugging information to os. More...
|
|
double | get (int i, int j) const |
| Function to get a matrix element value at (i,j). More...
|
|
double & | set (int i, int j) |
| Function to get a reference to matrix element value at (i,j). More...
|
|
void | set_no_duplicate_check (int i, int j, double vval) |
| Set element with no checks. More...
|
|
int & | row (int i) |
| Returns a reference to the to the internal row data of the matrix. More...
|
|
int & | col (int i) |
| Returns a reference to the to the internal column data ptr of the matrix. More...
|
|
double & | val (int i) |
| Returns a reference to the to the internal value data of the matrix. More...
|
|
const int & | row (int i) const |
| Returns a const reference to the to the internal row data of the matrix. More...
|
|
const int & | col (int i) const |
| Returns a const reference to the to the internal column data ptr of the matrix. More...
|
|
const double & | val (int i) const |
| Returns a const reference to the to the internal value data of the matrix. More...
|
|
void | set_nz (int nz) |
| Set number of non-zero elements in the matrix. More...
|
|
CoordMatrix & | operator= (const CoordMatrix &mat) |
|
CoordMatrix & | operator= (const CColMatrix &mat) |
|
CoordMatrix & | operator= (const CRowMatrix &mat) |
|
CoordMatrix & | operator= (const Matrix &mat) |
|
void | multiply_by_vector (Vector &res, const Vector &rhs) const |
|
void | lower_unit_solve (Vector &y, const Vector &b) const |
|
void | upper_diag_solve (Vector &x, const Vector &y) const |
|
virtual | ~Matrix () |
| Virtual destructor. More...
|
|
double | get (int i, int j) const |
| Function to get a matrix element value at (i,j). More...
|
|
double & | set (int i, int j) |
| Function to get a reference to matrix element value at (i,j). More...
|
|
MatrixMulVec | operator* (const class Vector &vec) const |
| Operator for matrix-vector multiplication. More...
|
|
Coordinate sparse matrix class.
The matrix is stored in the standard coordinate sparse matrix storage mode. In coordinate storage method all non-zero matrix elements are stored in array as triplets (row, column, val). The format itself does not require a certain ordering of elements, but some implementation might need/be faster on some ordering. Our example matrix
| 1 2 0 0 3|
| 4 5 6 0 0|
A = | 0 7 8 0 9|
| 0 0 0 10 0|
|11 0 0 0 12|
is represented in compressed column sparse matrix class as:
val[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
row[] = {0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 4}
col[] = {0, 1, 4, 0, 1, 2, 1, 2, 4, 3, 0, 4}
double & CoordMatrix::set |
( |
int |
i, |
|
|
int |
j |
|
) |
| |
|
inline |
Function to get a reference to matrix element value at (i,j).
This function can be used to set or modify matrix element value. See following examples:
A.set(0,0) = 1.2
A.set(0,1) *= 2
A.set(0,1) += 0.1
Note that a reference is actually a pointer to the memory location of the element and therefore unexpected things can happen if matrix is modified while using set, for example
A.set(0,0) = A.set(0,1) = A.set(0,2) = 5.0
does not do what you would expect it to do.
Range checking is done for i and j if SPM_RANGE_CHECK
is defined. Throws ErrorRange exception on range checking errors.