43 #ifndef COORDMATRIX_HPP
44 #define COORDMATRIX_HPP 1
81 void allocate(
void );
82 void reallocate(
void );
84 double get_check(
int i,
int j )
const;
85 double &set_check(
int i,
int j );
86 double get_no_check(
int i,
int j )
const;
87 double &set_no_check(
int i,
int j );
89 void clear_check(
int i,
int j );
90 void clear_no_check(
int i,
int j );
104 CoordMatrix() : _n(0), _m(0), _nz(0), _asize(0), _row(NULL), _col(NULL), _val(NULL) { }
119 const int *
row,
const int *
col,
const int *
val );
151 int rows(
void )
const {
return( _n ); }
155 void size(
int &n,
int &m )
const { n = _n; m = _m; }
173 void resize(
int n,
int m );
191 void clear(
int i,
int j );
220 double get(
int i,
int j )
const;
240 double &
set(
int i,
int j );
257 int &
row(
int i ) {
return( _row[i] ); }
262 int &
col(
int i ) {
return( _col[i] ); }
267 double &
val(
int i ) {
return( _val[i] ); }
272 const int &
row(
int i )
const {
return( _row[i] ); }
277 const int &
col(
int i )
const {
return( _col[i] ); }
282 const double &
val(
int i )
const {
return( _val[i] ); }
319 #ifdef SPM_RANGE_CHECK
320 return( get_check( i, j ) );
322 return( get_no_check( i, j ) );
329 #ifdef SPM_RANGE_CHECK
330 return( set_check( i, j ) );
332 return( set_no_check( i, j ) );
339 #ifdef SPM_RANGE_CHECK
342 clear_no_check( i, j );
int nz_elements(void) const
Returns the number of non-zero elements in the matrix.
Definition: coordmatrix.hpp:159
Compressed row sparse matrix class.
Definition: crowmatrix.hpp:76
const double & val(int i) const
Returns a const reference to the to the internal value data of the matrix.
Definition: coordmatrix.hpp:282
void multiply_by_vector(Vector &res, const Vector &rhs) const
void order_ascending_column_row(void)
Order (sort) matrix data in ascending (column,row) index order.
void order_ascending_row_column(void)
Order (sort) matrix data in ascending (row,column) index order.
Basis for matrix implementations.
void upper_diag_solve(Vector &x, const Vector &y) const
CoordMatrix()
Default constructor.
Definition: coordmatrix.hpp:104
Dense math vector class.
Definition: mvector.hpp:68
void debug_print(std::ostream &os) const
Print debugging information to os.
void set_nz(int nz)
Set number of non-zero elements in the matrix.
int columns(void) const
Returns the number of columns in the matrix.
Definition: coordmatrix.hpp:147
int & row(int i)
Returns a reference to the to the internal row data of the matrix.
Definition: coordmatrix.hpp:257
const int & row(int i) const
Returns a const reference to the to the internal row data of the matrix.
Definition: coordmatrix.hpp:272
int rows(void) const
Returns the number of rows in the matrix.
Definition: coordmatrix.hpp:151
void merge(CoordMatrix &mat)
Merges matrix mat into the matrix leaving mat empty.
void clear(void)
Clear non-zero matrix elements, set all elements to zero.
Base matrix class.
Definition: matrix.hpp:76
int & col(int i)
Returns a reference to the to the internal column data ptr of the matrix.
Definition: coordmatrix.hpp:262
const int & col(int i) const
Returns a const reference to the to the internal column data ptr of the matrix.
Definition: coordmatrix.hpp:277
Error classes and handling
void reserve(int size)
Reserve memory for size matrix elements.
double & set(int i, int j)
Function to get a reference to matrix element value at (i,j).
Definition: coordmatrix.hpp:327
CoordMatrix & operator=(const CoordMatrix &mat)
int capacity(void) const
Returns the number of elements allocated for matrix.
Definition: coordmatrix.hpp:163
void resize(int n, int m)
Resizes the matrix to size n x m.
double & val(int i)
Returns a reference to the to the internal value data of the matrix.
Definition: coordmatrix.hpp:267
void set_no_duplicate_check(int i, int j, double vval)
Set element with no checks.
void lower_unit_solve(Vector &y, const Vector &b) const
Compressed column sparse matrix class.
Definition: ccolmatrix.hpp:75
void size(int &n, int &m) const
Returns the number of columns and number of columns in nn and mm.
Definition: coordmatrix.hpp:155
Coordinate sparse matrix class.
Definition: coordmatrix.hpp:72
double get(int i, int j) const
Function to get a matrix element value at (i,j).
Definition: coordmatrix.hpp:317
~CoordMatrix()
Destructor.