MoCSI API Reference
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
GenericMatrix< T > Class Template Referenceabstract

Template generalized Matrix object that should be the base for all further implementations of a matrix class. Only provides the most basic functionality and contains mainly pure virtual functions. More...

#include <GenericMatrix.h>

Inheritance diagram for GenericMatrix< T >:
Inheritance graph
Collaboration diagram for GenericMatrix< T >:
Collaboration graph

Public Member Functions

 GenericMatrix ()
 Constructor for an empty GenericMatrix object. This should only be used for dynamically created matrices.
 
 GenericMatrix (int rows, int cols)
 Constructor for an empty GenericMatrix object whose value array holds rows*cols values.
 
 GenericMatrix (int rows, int cols, const std::valarray< T > &values, bool allow_mismatched_size)
 Constructor for a GenericMatrix object whose value array holds rows*cols values given by the user. Can throw an std::ivalid_argument if provided with a value array of different size than rows*cols.
 
 GenericMatrix (const GenericMatrix &)=default
 
GenericMatrixoperator= (const GenericMatrix &)=default
 
 GenericMatrix (GenericMatrix &&)=default
 
GenericMatrixoperator= (GenericMatrix &&)=default
 
std::pair< int, intsize () const
 Function that returns the size of the matrix as a pair in (rows, columns) format.
 
virtual Toperator() (int rows, int cols)=0
 
virtual T operator() (int rows, int cols) const =0
 
virtual std::valarray< TscalarAdd (T value) const =0
 
virtual std::valarray< TscalarSubtract (T value) const =0
 
virtual std::valarray< TscalarMultiply (T value) const =0
 
virtual std::valarray< TscalarDivide (T value) const =0
 
virtual void buildAtRuntime (int rows, int cols)=0
 
virtual void updateNonZeroElements ()=0
 
virtual const std::vector< std::pair< int, int > > & getNonZeroElements ()=0
 
void zeroMatrix ()
 Function that zeros out the matrix.
 
virtual ~GenericMatrix ()=default
 

Protected Attributes

int m_rows {0}
 
int m_cols {0}
 
std::valarray< Tm_matrix {}
 
std::vector< std::pair< int, int > > m_non_zero_elements
 

Detailed Description

template<typename T>
class GenericMatrix< T >

Template generalized Matrix object that should be the base for all further implementations of a matrix class. Only provides the most basic functionality and contains mainly pure virtual functions.

Constructor & Destructor Documentation

◆ GenericMatrix() [1/5]

Constructor for an empty GenericMatrix object. This should only be used for dynamically created matrices.

◆ GenericMatrix() [2/5]

template<typename T >
GenericMatrix< T >::GenericMatrix ( int  rows,
int  cols 
)

Constructor for an empty GenericMatrix object whose value array holds rows*cols values.

Parameters
rowsThe number of rows.
colsThe number of columns.

◆ GenericMatrix() [3/5]

template<typename T >
GenericMatrix< T >::GenericMatrix ( int  rows,
int  cols,
const std::valarray< T > &  values,
bool  allow_mismatched_size 
)

Constructor for a GenericMatrix object whose value array holds rows*cols values given by the user. Can throw an std::ivalid_argument if provided with a value array of different size than rows*cols.

Parameters
rowsThe number of rows.
colsThe number of columns.
valuesThe values to be stored in the m_matrix valarray.

◆ GenericMatrix() [4/5]

template<typename T >
GenericMatrix< T >::GenericMatrix ( const GenericMatrix< T > &  )
default

◆ GenericMatrix() [5/5]

template<typename T >
GenericMatrix< T >::GenericMatrix ( GenericMatrix< T > &&  )
default

◆ ~GenericMatrix()

template<typename T >
virtual GenericMatrix< T >::~GenericMatrix ( )
virtualdefault

Member Function Documentation

◆ buildAtRuntime()

template<typename T >
virtual void GenericMatrix< T >::buildAtRuntime ( int  rows,
int  cols 
)
pure virtual

Implemented in CsrSparseMatrix< T >, and DenseMatrix< T >.

◆ getNonZeroElements()

template<typename T >
virtual const std::vector< std::pair< int, int > > & GenericMatrix< T >::getNonZeroElements ( )
pure virtual

Implemented in CsrSparseMatrix< T >, and DenseMatrix< T >.

◆ operator()() [1/2]

template<typename T >
virtual T GenericMatrix< T >::operator() ( int  rows,
int  cols 
) const
pure virtual

Implemented in CsrSparseMatrix< T >, and DenseMatrix< T >.

◆ operator()() [2/2]

template<typename T >
virtual T & GenericMatrix< T >::operator() ( int  rows,
int  cols 
)
pure virtual

Implemented in CsrSparseMatrix< T >, and DenseMatrix< T >.

◆ operator=() [1/2]

template<typename T >
GenericMatrix & GenericMatrix< T >::operator= ( const GenericMatrix< T > &  )
default

◆ operator=() [2/2]

template<typename T >
GenericMatrix & GenericMatrix< T >::operator= ( GenericMatrix< T > &&  )
default

◆ scalarAdd()

template<typename T >
virtual std::valarray< T > GenericMatrix< T >::scalarAdd ( T  value) const
pure virtual

Implemented in CsrSparseMatrix< T >, and DenseMatrix< T >.

◆ scalarDivide()

template<typename T >
virtual std::valarray< T > GenericMatrix< T >::scalarDivide ( T  value) const
pure virtual

Implemented in CsrSparseMatrix< T >, and DenseMatrix< T >.

◆ scalarMultiply()

template<typename T >
virtual std::valarray< T > GenericMatrix< T >::scalarMultiply ( T  value) const
pure virtual

Implemented in CsrSparseMatrix< T >, and DenseMatrix< T >.

◆ scalarSubtract()

template<typename T >
virtual std::valarray< T > GenericMatrix< T >::scalarSubtract ( T  value) const
pure virtual

Implemented in CsrSparseMatrix< T >, and DenseMatrix< T >.

◆ size()

template<typename T >
std::pair< int, int > GenericMatrix< T >::size ( ) const

Function that returns the size of the matrix as a pair in (rows, columns) format.

◆ updateNonZeroElements()

template<typename T >
virtual void GenericMatrix< T >::updateNonZeroElements ( )
pure virtual

Implemented in CsrSparseMatrix< T >, and DenseMatrix< T >.

◆ zeroMatrix()

template<typename T >
void GenericMatrix< T >::zeroMatrix ( )

Function that zeros out the matrix.

Member Data Documentation

◆ m_cols

template<typename T >
int GenericMatrix< T >::m_cols {0}
protected

◆ m_matrix

template<typename T >
std::valarray<T> GenericMatrix< T >::m_matrix {}
protected

◆ m_non_zero_elements

template<typename T >
std::vector<std::pair<int, int> > GenericMatrix< T >::m_non_zero_elements
protected

◆ m_rows

template<typename T >
int GenericMatrix< T >::m_rows {0}
protected

The documentation for this class was generated from the following file: