Public Member Functions |
| | CColMatrix () |
| | Default constructor.
|
| | CColMatrix (int n, int m) |
| | Constructor to make empty n x m matrix.
|
| | CColMatrix (int n, int m, int nz, int *ptr, int *row, double *val) |
| | Constructor to make n x m matrix from compressed column matrix data.
|
| | CColMatrix (const CColMatrix &mat) |
| | Copy constructor.
|
| | CColMatrix (const class CRowMatrix &mat) |
| | Constructor for conversion from compressed row matrix.
|
| | CColMatrix (const class CoordMatrix &mat) |
| | Constructor for conversion from coordinate matrix.
|
| | CColMatrix (const class Matrix &mat) |
| | Constructor for conversion from unknown matrix type.
|
| | ~CColMatrix () |
| | Destructor.
|
| int | columns (void) const |
| | Returns the number of columns in the matrix.
|
| int | rows (void) const |
| | Returns the number of rows in the matrix.
|
| void | size (int &n, int &m) const |
| | Returns the number of columns and number of columns in n and m.
|
| int | nz_elements (void) const |
| | Returns the number of non-zero elements in the matrix.
|
| int | capacity (void) const |
| | Returns the number of elements allocated for matrix.
|
| void | resize (int n, int m) |
| | Resizes the matrix to size n x m.
|
| void | merge (CColMatrix &mat) |
| | Merges matrix mat into the matrix leaving mat empty.
|
| void | clear (void) |
| | Clear non-zero matrix elements, set all elements to zero.
|
| void | clear (int i, int j) |
| | Clear matrix element (i,j).
|
| void | reserve (int size) |
| | Reserve memory for size matrix elements.
|
| void | order_ascending (void) |
| | Order (sort) matrix data in ascending row index order within each column.
|
| bool | check_ascending (void) |
| | Check if matrix data is in ascending row index order within each column.
|
| void | debug_print (std::ostream &os) const |
| | Print debugging information to os.
|
| double | get (int i, int j) const |
| | Function to get a matrix element value at (i,j).
|
| double & | set (int i, int j) |
| | Function to get a reference to matrix element value at (i,j).
|
| void | set_column (int j, int N, const int *row, const double *val) |
| | Function to set matrix column elements.
|
| void | construct_add (int i, int j, double val) |
| | Adds an element to matrix while constructing the whole matrix.
|
| int & | ptr (int i) |
| | Returns a reference to the to the internal pointer index data ptr of the matrix.
|
| int & | row (int i) |
| | Returns a reference to the to the internal column data of the matrix.
|
| double & | val (int i) |
| | Returns a reference to the to the internal value data of the matrix.
|
| const int & | ptr (int i) const |
| | Returns a const reference to the to the internal pointer index data ptr of the matrix.
|
| const int & | row (int i) const |
| | Returns a const reference to the to the internal row data of the matrix.
|
| const double & | val (int i) const |
| | Returns a const reference to the to the internal value data of the matrix.
|
| void | set_nz (int nz) |
| | Set number of non-zero elements in the matrix.
|
| CColMatrix & | operator= (const CColMatrix &mat) |
| | Assignment operator.
|
| CColMatrix & | operator= (const class CRowMatrix &mat) |
| | Assignment operator for conversion from compressed row matrix.
|
| CColMatrix & | operator= (const class CoordMatrix &mat) |
| | Assignment operator for conversion from coordinate matrix.
|
| CColMatrix & | operator= (const Matrix &mat) |
| | Assignment operator for conversion from unknown matrix type.
|
| void | multiply_by_vector (Vector &x, const Vector &b) const |
| void | lower_unit_solve (Vector &x, const Vector &b) const |
| | Solves A*x = b for lower unit diagonal matrix.
|
| void | upper_diag_solve (Vector &x, const Vector &b) const |
| | Solves A*x = b for upper diagonal matrix.
|
| virtual | ~Matrix () |
| | Virtual destructor.
|
| MatrixMulVec | operator* (const class Vector &vec) const |
| | Operator for matrix-vector multiplication.
|
Compressed column sparse matrix class.
The matrix is stored in the standard compressed column sparse matrix storage mode. In compressed column storage method all non-zero matrix elements are stored in array val in column-by-column order. The corresponding row indices are stored in another array row in the same order. The third array ptr contains "pointer" indices indicating start and end of each row in the first two arrays. 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:
ptr[] = {0, 3, 6, 8, 9, 12}
val[] = {1, 4, 11, 2, 5, 7, 6, 8, 10, 3, 9, 12}
row[] = {0, 1, 4, 0, 1, 2, 1, 2, 3, 0, 2, 4}
| double & CColMatrix::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.
Reimplemented from Matrix.