22 #ifndef __HERMES_COMMON_MATRIX_H
23 #define __HERMES_COMMON_MATRIX_H
35 template<
typename Scalar>
41 Matrix(
unsigned int size = 0);
45 virtual void alloc() = 0;
48 virtual void free() = 0;
54 virtual Scalar
get(
unsigned int m,
unsigned int n)
const = 0;
57 virtual void zero() = 0;
64 virtual void set_row_zero(
unsigned int n);
71 virtual void add(
unsigned int m,
unsigned int n, Scalar v) = 0;
80 virtual void add(
unsigned int m,
unsigned int n, Scalar *mat,
int *rows,
int *cols,
const int size);
83 virtual void add_to_diagonal(Scalar v);
86 virtual void multiply_with_vector(Scalar* vector_in, Scalar*& vector_out,
bool vector_out_initialized =
false)
const;
89 virtual void multiply_with_Scalar(Scalar value);
93 virtual unsigned int get_size()
const;
101 template<
typename Scalar>
113 virtual void prealloc(
unsigned int n);
122 virtual void pre_add_ij(
unsigned int row,
unsigned int col);
125 virtual void finish();
147 virtual int get_num_row_entries(
unsigned int row)
const;
156 virtual void extract_row_copy(
unsigned int row,
unsigned int len,
157 unsigned int &n_entries,
double *vals,
unsigned int *idxs)
const;
163 virtual int get_num_col_entries(
unsigned int col)
const;
172 virtual void extract_col_copy(
unsigned int col,
unsigned int len,
173 unsigned int &n_entries,
double *vals,
unsigned int *idxs)
const;
179 virtual double get_fill_in()
const = 0;
183 virtual unsigned int get_nnz()
const;
188 static const int PAGE_SIZE = 100;
192 Page(
bool dyn_stored_ =
false) : dyn_stored(dyn_stored_), next(
nullptr), count(0) {
214 int sort_and_store_indices(
Page *page,
int *buffer,
int *max);
217 int get_num_indices();
222 template<
typename Scalar> HERMES_API
General (abstract) matrix representation in Hermes.
General namespace for the Hermes library.
bool dyn_stored
this page is stored in the dynamically allocated part.
HERMES_API SparseMatrix< Scalar > * create_matrix(bool use_direct_solver=false)
Function returning a matrix according to the users's choice.
unsigned int size
matrix size
General (abstract) sparse matrix representation in Hermes.
Utilities for all Algebra code.
Mixins classes for algebraic purposes.
Structure for storing indices in sparse matrix.
Mix-in classes for one functionality, for various classes to be derived from.
Page * pages
array of pages with indices array. Each field of arra contains pages for one column ...
Page * next
pointer to next page
Class the output of which is loggable, i.e. that uses functionality of info(), warn() Contains the cl...