|
HermesCommon
3.0
|
General CS Matrix class. Either row- or column- specific (see subclassses). More...
#include <cs_matrix.h>
Inheritance diagram for Hermes::Algebra::CSMatrix< Scalar >:Public Member Functions | |
| void | create (unsigned int size, unsigned int nnz, int *ap, int *ai, Scalar *ax) |
| CSMatrix () | |
| Default constructor. | |
| CSMatrix (unsigned int size) | |
| Constructor with specific size Calls alloc. More... | |
| void | switch_orientation () |
| Switches CSR / CSC arrays. | |
| virtual void | add (unsigned int Ai_data_index, unsigned int Ai_index, Scalar v) |
| virtual Scalar | get (unsigned int Ai_data_index, unsigned int Ai_index) const |
| virtual void | alloc () |
| Allocate utility storage (row, column indices, etc.). | |
| virtual void | alloc_data () |
| virtual void | free () |
| Utility method. | |
| virtual void | zero () |
| Utility method. | |
| virtual void | set_row_zero (unsigned int n) |
| Utility method. | |
| void | export_to_file (const char *filename, const char *var_name, MatrixExportFormat fmt, char *number_format="%lf", bool invert_storage=false) |
| void | import_from_file (const char *filename, const char *var_name, MatrixExportFormat fmt, bool invert_storage=false) |
| virtual unsigned int | get_nnz () const |
| Utility method. | |
| virtual double | get_fill_in () const |
| Utility method. | |
| void | multiply_with_Scalar (Scalar value) |
| Multiplies matrix with a Scalar. | |
| int * | get_Ap () const |
| int * | get_Ai () const |
| Scalar * | get_Ax () const |
| virtual void | add_as_block (unsigned int i, unsigned int j, SparseMatrix< Scalar > *mat) |
| template<> | |
| void | add (unsigned int m, unsigned int n, double v) |
| template<> | |
| void | add (unsigned int m, unsigned int n, std::complex< double > v) |
Public Member Functions inherited from Hermes::Algebra::SparseMatrix< Scalar > | |
| SparseMatrix (unsigned int size) | |
| virtual void | prealloc (unsigned int n) |
| 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 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). | |
Public Member Functions inherited from Hermes::Algebra::Matrix< Scalar > | |
| Matrix (unsigned int size=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 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) |
Public Member Functions inherited from Hermes::Mixins::Loggable | |
| 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;. | |
Public Member Functions inherited from Hermes::Algebra::Mixins::MatrixRhsImportExport< Scalar > | |
| 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) |
Static Public Member Functions | |
| static int | find_position (int *Ai, int Alen, unsigned int idx) |
| Finds the correct position to insert / retrieve elements. | |
Static Public Member Functions inherited from Hermes::Mixins::Loggable | |
| static void | set_static_logFile_name (const char *filename) |
| static void | set_static_logFile_name (std::string filename) |
Protected Attributes | |
| Scalar * | Ax |
| int * | Ai |
| Row / Column indices of values in Ax. | |
| int * | Ap |
| Index to Ax/Ai, where each column / row starts. | |
| unsigned int | nnz |
| Number of non-zero entries ( = Ap[size]). | |
Protected Attributes inherited from Hermes::Algebra::SparseMatrix< Scalar > | |
| Page * | pages |
| array of pages with indices array. Each field of arra contains pages for one column | |
| Page ** | next_pages |
Protected Attributes inherited from Hermes::Algebra::Matrix< Scalar > | |
| unsigned int | size |
| matrix size | |
Friends | |
| template<typename T > | |
| SparseMatrix< T > * | create_matrix () |
Additional Inherited Members | |
Public Attributes inherited from Hermes::Mixins::Loggable | |
| char * | logFileName |
| Logfile name. | |
Static Public Attributes inherited from Hermes::Mixins::Loggable | |
| static char * | staticLogFileName = nullptr |
Protected Member Functions inherited from Hermes::Algebra::SparseMatrix< Scalar > | |
| int | sort_and_store_indices (Page *page, int *buffer, int *max) |
| int | get_num_indices () |
Protected Member Functions inherited from Hermes::Mixins::Loggable | |
| 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 |
Static Protected Attributes inherited from Hermes::Algebra::SparseMatrix< Scalar > | |
| static const int | PAGE_SIZE = 100 |
General CS Matrix class. Either row- or column- specific (see subclassses).
Definition at line 35 of file cs_matrix.h.
| Hermes::Algebra::CSMatrix< Scalar >::CSMatrix | ( | unsigned int | size | ) |
Constructor with specific size Calls alloc.
| [in] | size | size of matrix (number of rows and columns) |
Definition at line 81 of file cs_matrix.cpp.
|
virtual |
Main addition method. Virtual - the method body is 1:1 for CSCMatrix, inverted for CSR.
Implements Hermes::Algebra::Matrix< Scalar >.
Reimplemented in Hermes::Algebra::CSRMatrix< Scalar >, Hermes::Algebra::CSCMatrix< Scalar >, and Hermes::Algebra::MumpsMatrix< Scalar >.
|
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 from Hermes::Algebra::SparseMatrix< Scalar >.
Definition at line 233 of file cs_matrix.cpp.
| void Hermes::Algebra::CSMatrix< Scalar >::create | ( | unsigned int | size, |
| unsigned int | nnz, | ||
| int * | ap, | ||
| int * | ai, | ||
| Scalar * | ax | ||
| ) |
Creates matrix in CS format using size, nnz, and the three arrays.
| [in] | size | size of matrix (num of rows and columns) |
| [in] | nnz | number of nonzero values |
| [in] | ap | index to ap/ax, where each column /row starts (size is matrix size + 1) |
| [in] | ai | row / column indices |
| [in] | ax | values |
Definition at line 167 of file cs_matrix.cpp.
Referenced by Hermes::Algebra::CSCMatrix< Scalar >::duplicate(), and Hermes::Algebra::CSRMatrix< Scalar >::duplicate().
| void Hermes::Algebra::CSMatrix< Scalar >::export_to_file | ( | const char * | filename, |
| const char * | var_name, | ||
| MatrixExportFormat | fmt, | ||
| char * | number_format = "%lf", |
||
| bool | invert_storage = false |
||
| ) |
Matrix export method. Utility version MatrixRhsImportExport<Scalar>::export_to_file.
Definition at line 371 of file cs_matrix.cpp.
Referenced by Hermes::Algebra::CSCMatrix< Scalar >::export_to_file(), and Hermes::Algebra::CSRMatrix< Scalar >::export_to_file().
|
virtual |
Main get method. Virtual - the method body is 1:1 for CSCMatrix, inverted for CSR.
Implements Hermes::Algebra::Matrix< Scalar >.
Reimplemented in Hermes::Algebra::CSRMatrix< Scalar >, Hermes::Algebra::CSCMatrix< Scalar >, and Hermes::Algebra::MumpsMatrix< Scalar >.
Definition at line 295 of file cs_matrix.cpp.
Referenced by Hermes::Algebra::CSCMatrix< Scalar >::get(), and Hermes::Algebra::CSRMatrix< Scalar >::get().
| int * Hermes::Algebra::CSMatrix< Scalar >::get_Ai | ( | ) | const |
Exposes pointers to the CS arrays.
Definition at line 221 of file cs_matrix.cpp.
| int * Hermes::Algebra::CSMatrix< Scalar >::get_Ap | ( | ) | const |
Exposes pointers to the CS arrays.
Definition at line 215 of file cs_matrix.cpp.
| Scalar * Hermes::Algebra::CSMatrix< Scalar >::get_Ax | ( | ) | const |
Exposes pointers to the CS arrays.
Definition at line 227 of file cs_matrix.cpp.
| void Hermes::Algebra::CSMatrix< Scalar >::import_from_file | ( | const char * | filename, |
| const char * | var_name, | ||
| MatrixExportFormat | fmt, | ||
| bool | invert_storage = false |
||
| ) |
Reading matrix Utility version Matrix<Scalar>::import_from_file.
Definition at line 584 of file cs_matrix.cpp.
Referenced by Hermes::Algebra::CSCMatrix< Scalar >::import_from_file(), and Hermes::Algebra::CSRMatrix< Scalar >::import_from_file().
|
protected |
UMFPack specific data structures for storing the system matrix (CSC format). Matrix entries (column-wise).
Definition at line 117 of file cs_matrix.h.
Referenced by Hermes::Algebra::CSMatrix< Scalar >::add_as_block().