HermesCommon
3.0
|
General (abstract) sparse matrix representation in Hermes. More...
#include <matrix.h>
Classes | |
struct | Page |
Structure for storing indices in sparse matrix. More... | |
Public Member Functions | |
SparseMatrix (unsigned int size) | |
virtual void | prealloc (unsigned int n) |
virtual void | free () |
free the memory associated with stiffness matrix | |
virtual void | pre_add_ij (unsigned int row, unsigned int col) |
virtual void | finish () |
Finish manipulation with matrix (called before solving) | |
virtual void | add_sparse_matrix (SparseMatrix< Scalar > *mat) |
virtual void | add_sparse_to_diagonal_blocks (int num_stages, SparseMatrix< Scalar > *mat) |
virtual void | add_as_block (unsigned int i, unsigned int j, SparseMatrix< Scalar > *mat) |
virtual int | get_num_row_entries (unsigned int row) const |
virtual void | extract_row_copy (unsigned int row, unsigned int len, unsigned int &n_entries, double *vals, unsigned int *idxs) const |
virtual int | get_num_col_entries (unsigned int col) const |
virtual void | extract_col_copy (unsigned int col, unsigned int len, unsigned int &n_entries, double *vals, unsigned int *idxs) const |
virtual SparseMatrix< Scalar > * | duplicate () const |
Duplicate sparse matrix (including allocation). | |
virtual double | get_fill_in () const =0 |
Get fill-in. | |
virtual unsigned int | get_nnz () const |
![]() | |
Matrix (unsigned int size=0) | |
virtual void | alloc ()=0 |
allocate the memory for stiffness matrix | |
virtual Scalar | get (unsigned int m, unsigned int n) const =0 |
virtual void | zero ()=0 |
Zero the matrix. | |
virtual void | set_row_zero (unsigned int n) |
virtual void | add (unsigned int m, unsigned int n, Scalar v)=0 |
virtual void | add (unsigned int m, unsigned int n, Scalar *mat, int *rows, int *cols, const int size) |
virtual void | add_to_diagonal (Scalar v) |
Add a number to each diagonal entry. | |
virtual void | multiply_with_vector (Scalar *vector_in, Scalar *&vector_out, bool vector_out_initialized=false) const |
Multiply with a vector. | |
virtual void | multiply_with_Scalar (Scalar value) |
Multiply with a Scalar. | |
virtual unsigned int | get_size () const |
template<> | |
void | add (unsigned int m, unsigned int n, double *mat, int *rows, int *cols, const int size) |
template<> | |
void | add (unsigned int m, unsigned int n, std::complex< double > *mat, int *rows, int *cols, const int size) |
![]() | |
Loggable (bool verbose_output=false, callbackFn verbose_callback=NULL, bool add_newline=true) | |
void | set_file_output_only (bool onOff) |
void | set_timestamps (bool onOff) |
Sets the addition of a time stamp on each line in the log file. By default it is on. | |
void | set_erase_on_beginning (bool onOff) |
Sets the logFile being always erased before logging. | |
void | set_logFile_name (const char *filename) |
void | set_logFile_name (std::string filename) |
void | info (const char *msg,...) const |
void | info_if (bool cond, const char *msg,...) const |
void | warn (const char *msg,...) const |
void | warn_if (bool cond, const char *msg,...) const |
void | error (const char *msg,...) const |
void | error_if (bool cond, const char *msg,...) const |
virtual void | set_verbose_output (bool to_set) |
bool | get_verbose_output () const |
Returns the current value of verbose_output;. | |
virtual void | set_verbose_callback (callbackFn callback) |
callbackFn | get_verbose_callback () const |
Returns the current value of verbose_callback;. | |
![]() | |
virtual void | export_to_file (const char *filename, const char *var_name, Algebra::MatrixExportFormat fmt, char *number_format="%lf")=0 |
void | export_to_file (std::string filename, const char *var_name, Algebra::MatrixExportFormat fmt, char *number_format="%lf") |
void | export_to_file (std::string filename, std::string var_name, Algebra::MatrixExportFormat fmt, char *number_format="%lf") |
virtual void | import_from_file (const char *filename, const char *var_name, Algebra::MatrixExportFormat fmt) |
void | import_from_file (std::string filename, const char *var_name, Algebra::MatrixExportFormat fmt) |
void | import_from_file (std::string filename, std::string var_name, Algebra::MatrixExportFormat fmt) |
Protected Member Functions | |
int | sort_and_store_indices (Page *page, int *buffer, int *max) |
int | get_num_indices () |
![]() | |
void | hermes_fwrite (const void *ptr, size_t size, size_t nitems, FILE *stream) const |
void | hermes_fread (void *ptr, size_t size, size_t nitems, FILE *stream) const |
Protected Attributes | |
Page * | pages |
array of pages with indices array. Each field of arra contains pages for one column | |
Page ** | next_pages |
![]() | |
unsigned int | size |
matrix size | |
Static Protected Attributes | |
static const int | PAGE_SIZE = 100 |
Additional Inherited Members | |
![]() | |
static void | set_static_logFile_name (const char *filename) |
static void | set_static_logFile_name (std::string filename) |
![]() | |
char * | logFileName |
Logfile name. | |
![]() | |
static char * | staticLogFileName = nullptr |
General (abstract) sparse matrix representation in Hermes.
Definition at line 34 of file algebra_mixins.h.
Hermes::Algebra::SparseMatrix< Scalar >::SparseMatrix | ( | unsigned int | size | ) |
Constructor of sparse matrix
[in] | size | size of matrix |
Definition at line 129 of file matrix.cpp.
|
virtual |
Add matrix to specific position.
[in] | i | row in target matrix coresponding with top row of added matrix |
[in] | j | column in target matrix coresponding with lef column of added matrix |
[in] | mat | added matrix |
Reimplemented in Hermes::Algebra::CSMatrix< Scalar >.
Definition at line 207 of file matrix.cpp.
Referenced by Hermes::Algebra::CSMatrix< Scalar >::add_as_block().
|
virtual |
Add matrix
mat | matrix to add |
Reimplemented in Hermes::Algebra::EpetraMatrix< Scalar >.
Definition at line 190 of file matrix.cpp.
|
virtual |
Add matrix to diagonal Matrices must be the same type of solver
[in] | num_stages | matrix is added to num_stages positions. num_stages * size(added matrix) = size(target matrix) |
[in] | mat | added matrix |
Definition at line 196 of file matrix.cpp.
|
virtual |
Extract the copy of a column
[in] | col | - global column to extract |
[in] | len | - length of 'vals' and 'idxs' arrays. |
[out] | n_entries | - number of nonzero entries extracted. |
[out] | vals | - extracted values for this column. |
[out] | idxs | - extracted global row indices for the corresponding values. |
Definition at line 183 of file matrix.cpp.
|
virtual |
Extract the copy of a row
[in] | row | - global row to extract |
[in] | len | - length of 'vals' and 'idxs' arrays. |
[out] | n_entries | - number of nonzero entries extracted. |
[out] | vals | - extracted values for this row. |
[out] | idxs | - extracted global column indices for the corresponding values. |
Definition at line 170 of file matrix.cpp.
|
virtual |
get number of nonzero numbers in matrix
Reimplemented in Hermes::Algebra::CSMatrix< Scalar >, and Hermes::Algebra::EpetraMatrix< Scalar >.
Definition at line 228 of file matrix.cpp.
|
virtual |
Return the number of entries in a specified column
[in] | col | - index of the column |
Definition at line 177 of file matrix.cpp.
|
protected |
get number of indices in all pages
Definition at line 287 of file matrix.cpp.
|
virtual |
Return the number of entries in a specified row
[in] | row | - index of the row |
Definition at line 164 of file matrix.cpp.
|
virtual |
add indices of nonzero matrix element
[in] | row | - row index |
[in] | col | - column index |
Reimplemented in Hermes::Algebra::CSRMatrix< Scalar >, and Hermes::Algebra::EpetraMatrix< Scalar >.
Definition at line 242 of file matrix.cpp.
|
virtual |
prepare memory
[in] | n | - number of unknowns |
Reimplemented in Hermes::Algebra::EpetraMatrix< Scalar >.
Definition at line 235 of file matrix.cpp.
|
protected |
gather all pages in the buffer, delete them, sort buffer and remove duplicities
[in] | page | first page with indices |
[out] | buffer | buffer to which indices will be copied |
[in] | max | maximum indices to be stored (probably) |
Definition at line 262 of file matrix.cpp.
|
staticprotected |