19 #ifndef _SF_ABSTRACT_MATRIX_H 20 #define _SF_ABSTRACT_MATRIX_H 43 template <
class T,
class S>
86 virtual inline void init(T iNRows, T iNCols, T ilrows, T ilcols,
87 T loc_offset, T mxent)
92 this->start = loc_offset;
93 this->stop = this->start + this->
lsize;
111 this->row_dpn = irow_dpn;
112 this->col_dpn = icol_dpn;
115 MPI_Comm_rank(mesh->
comm, &rank);
127 init(M, N, m, n, loc_offset, nmax*this->col_dpn);
158 virtual void zero() = 0;
201 virtual void scale(S s) = 0;
242 const S* vals,
bool add) = 0;
252 virtual void set_value(T row_idx, T col_idx, S val,
bool add) = 0;
266 assert(row_idx.
size() == col_idx.
size() == values.
size());
268 for (
int i = 0; i < row_idx.
size(); i++)
269 values[i] =
get_value(row_idx[i], col_idx[i]);
306 for (
size_t row = 0; row <
NRows; row++)
307 for (
size_t col = 0; col <
NCols; col++)
321 std::ostringstream stream;
322 stream <<
"matrix (" << this->NRows <<
" x " << this->NCols <<
") [\n";
324 for (
auto row = 0; row < this->
NRows; row++) {
326 for (
auto col = 0; col < this->
NCols; col++) {
327 if (col > 0) stream <<
", ";
342 #endif // _SF_ABSTRACT_MATRIX_H const vector< T > & algebraic_layout() const
Getter function for the global algebraic node layout.
virtual void add_scaled_matrix(const abstract_matrix< T, S > &A, const S s, const bool same_nnz)=0
virtual void mult_LR(const abstract_vector< T, S > &L, const abstract_vector< T, S > &R)=0
int start
start row index of local matrix portion
int NCols
global number of cols
MPI_Comm comm
the parallel mesh is defined on a MPI world
virtual void init(T iNRows, T iNCols, T ilrows, T ilcols, T loc_offset, T mxent)
virtual void duplicate(const abstract_matrix< T, S > &M)=0
overlapping_layout< T > pl
nodal parallel layout
int NRows
global number of rows
int stop
stio row index of local matrix portion
virtual S get_value(SF_int row_idx, SF_int col_idx) const =0
virtual void scale(S s)=0
bool equals(const abstract_matrix< T, S > &rhs) const
int lsize
size of local matrix (#locally stored rows)
virtual ~abstract_matrix()=default
const meshdata< mesh_int_t, mesh_real_t > * mesh
pointer to the associated mesh
virtual void mult(const abstract_vector< T, S > &x, abstract_vector< T, S > &b) const =0
virtual void write(const char *filename) const =0
virtual void set_values(const vector< T > &row_idx, const vector< T > &col_idx, const vector< S > &vals, bool add)=0
void get_values(const vector< T > &row_idx, const vector< T > &col_idx, vector< S > &values) const
int max_nodal_edgecount(const meshdata< T, S > &mesh)
Compute the maximum number of node-to-node edges for a mesh.
const meshdata< mesh_int_t, mesh_real_t > * mesh_ptr() const
virtual void diag_add(const abstract_vector< T, S > &diag)=0
size_t size() const
The current size of the vector.
virtual void get_diagonal(abstract_vector< T, S > &vec) const =0
size_t num_global_idx() const
Retrieve the global number of indices.
virtual void finish_assembly()=0
A vector storing arbitrary data.
virtual void set_value(T row_idx, T col_idx, S val, bool add)=0
Classes and algorithms related to the layout of distributed meshes.
void init(const meshdata< mesh_int_t, mesh_real_t > &imesh, const T irow_dpn, const T icol_dpn, const T max_edges)
std::int32_t SF_int
Use the general std::int32_t as int type.
size_t num_algebraic_idx() const
Retrieve the number of local algebraic indices.
std::string to_string() const