18#ifndef MATRIX_BASE_HPP
19#define MATRIX_BASE_HPP
198 std::ofstream
out (name, std::ios::out | std::ios::binary | std::ios::trunc);
213 std::ifstream
in (name, std::ios::in | std::ios::binary);
227 virtual void print(
const std::string name =
"matrix")
const
229 std::cout <<
"\n--- " << name <<
" (" <<
num_rows() <<
" x " <<
num_cols() <<
") ---" << std::endl;
234 std::cout << std::scientific
235 << std::setprecision(4)
241 std::cout << std::endl;
243 std::cout <<
"---" << std::endl;
Base class for for matrix algebra containers.
virtual void mat_solve(MatrixBase< T > &x, const MatrixBase< T > &b)=0
Solves for matrix with a direct solver, where is this matrix, and is a given right-hand side matr...
virtual T value(Index row, Index col) const =0
Returns the matrix value at the specified row and column.
virtual T * data()=0
Returns a writable pointer to the underlying raw data - use with care.
virtual void add_value(Index row, Index col, const T &a)
Adds to the matrix value at the specified row and column.
virtual void assemble()
Assembles cached data into the matrix.
virtual void write_binary(const std::string name="matrix") const
Writes the matrix to a binary file.
virtual void set_zero()=0
Sets all matrix entries to zero.
virtual void set_identity()
Sets the matrix to identity (ones along the diagonal, zeros elsewhere).
virtual Index num_cols() const =0
Returns the total number of rows in the matrix.
virtual void clear()=0
Clears all data in the matrix and sets its size to 0.
virtual void read_binary(const std::string name="matrix")
Reads the matrix from a binary file.
virtual const T * data() const =0
Returns a read-only pointer to the underlying raw data.
virtual Index num_rows() const =0
Returns the total number of rows in the matrix.
virtual void preallocate(Index num_entries)
Preallocates memory for a given total number of non-zero values.
virtual void scale(const T &a)=0
Scales all matrix entries by a given value.
virtual void preallocate(const std::vector< Index > &nnz)
Preallocates memory for a given number of non-zero values per row.
virtual void resize(Index rows, Index cols)=0
Resizes the matrix to a new number of rows and columns.
virtual void set_value(Index row, Index col, const T &a)=0
Sets the matrix value at the specified row and column.
virtual void print(const std::string name="matrix") const
Prints the matrix to the terminal in a formatted manner.
virtual Index size() const
Returns the size (rows * cols) of the matrix.
virtual void add_ax(const MatrixBase< T > &x, const T &a=T(1))=0
Computes where is this matrix, is a scalar, and is a matrix.
Eigen::Matrix< T, N, 1 > EigColVecN
Fixed-size column vector of size N containing type T.
std::size_t Index
Unsigned integer type for indices and container sizes.
Primary namespace for the OpenBEM library.