1#ifndef GENERIC_MATRIX_H
2#define GENERIC_MATRIX_H
39 std::pair<int, int>
size()
const;
55 const std::valarray<T>&
value)
const = 0;
110 std::cerr <<
"Size mismatch between dimensions and provided values.\n";
111 throw std::invalid_argument(
112 static_cast<std::string
>(
"Size mismatch between dimensions and provided values."));
154 std::string m_error_string;
167 const std::string&
tag)
169 std::ostringstream
oss;
172 <<
"Nominal bounds of this matrix are: (" <<
rows <<
", " <<
cols <<
").\n";
173 m_error_string =
oss.str();
MatrixType
Definition CoreEnums.h:36
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:37
CsrSparseMatrix()
Constructor for an empty CsrSparseMatrix object. Leaves all storage arrays empty but sets the flag to...
Definition CsrMatrix.h:94
Template generalized Matrix object that should be the base for all further implementations of a matri...
Definition GenericMatrix.h:19
virtual const MatrixType getMatrixType()=0
void zeroMatrix()
Function that zeros out the matrix.
Definition GenericMatrix.h:129
GenericMatrix(GenericMatrix &&)=default
virtual void buildAtRuntime(int rows, int cols)=0
virtual std::valarray< T > scalarSubtract(T value) const =0
void overwriteMatrixValues(const std::valarray< T > &value)
Overwrites the matrix values with a new valarray. This is used for optimized overwrite when arithmeti...
Definition GenericMatrix.h:142
virtual std::valarray< T > vectorElemMultiply(const std::valarray< T > &value) const =0
std::valarray< T > m_matrix
Definition GenericMatrix.h:24
GenericMatrix(const GenericMatrix &)=default
std::vector< std::pair< int, int > > m_non_zero_elements
Definition GenericMatrix.h:25
GenericMatrix & operator=(const GenericMatrix &)=default
std::pair< int, int > size() const
Function that returns the size of the matrix as a pair in (rows, columns) format.
Definition GenericMatrix.h:120
virtual std::valarray< T > scalarAdd(T value) const =0
virtual void registerElement(T value, int rows, int cols)
Definition GenericMatrix.h:58
virtual T & operator()(int rows, int cols)=0
GenericMatrix & operator=(GenericMatrix &&)=default
int m_rows
Definition GenericMatrix.h:21
virtual void updateNonZeroElements()=0
virtual std::valarray< T > vectorElemAdd(const std::valarray< T > &value) const =0
virtual ~GenericMatrix()=default
GenericMatrix()
Constructor for an empty GenericMatrix object. This should only be used for dynamically created matri...
Definition GenericMatrix.h:77
virtual std::valarray< T > vectorElemDivide(const std::valarray< T > &value) const =0
virtual std::valarray< T > scalarMultiply(T value) const =0
virtual const std::vector< std::pair< int, int > > & getNonZeroElements()=0
virtual T operator()(int rows, int cols) const =0
virtual std::valarray< T > scalarDivide(T value) const =0
virtual std::valarray< T > vectorElemSubtract(const std::valarray< T > &value) const =0
virtual std::valarray< T > matrixVectorMultiplication(const std::valarray< T > &value) const =0
int m_cols
Definition GenericMatrix.h:22
Error class to throw when the matrix is accessed out of bounds. Inherits from std::exception.
Definition GenericMatrix.h:152
MatrixOutOfBoundsError(int access_row, int access_col, int rows, int cols, const std::string &tag)
Constructor for the MatrixErrorOutOfBounds class. Builds the error message and saves it to the member...
Definition GenericMatrix.h:166
const char * what() const noexcept override
Supplies the error message as a c-style string/char array.
Definition GenericMatrix.h:179
~MatrixOutOfBoundsError() override=default