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

Concrete implemenatation of a matrix class representing a dense matrix. Offers basic access and element wise arithmetic functionality and mathematical matrix product. More...

#include <DenseMatrix.h>

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

Public Member Functions

 DenseMatrix ()
 Constructor used for buildAtRuntime.
 
 DenseMatrix (int rows, int cols)
 Constructor for an empty DenseMatrix object whose value array holds rows*cols values.
 
 DenseMatrix (int rows, int cols, const std::valarray< T > &values)
 Constructor for a DenseMatrix class 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.
 
Toperator() (int rows, int cols) override
 Parentheses operator to allow access to the matrix values as Matrix(row,column).
 
T operator() (int rows, int cols) const override
 Parentheses operator to allow access to the matrix values as Matrix(row,column) in a constant context.
 
 DenseMatrix (const DenseMatrix &)=default
 
DenseMatrixoperator= (const DenseMatrix &)=default
 
 DenseMatrix (DenseMatrix &&)=default
 
DenseMatrixoperator= (DenseMatrix &&)=default
 
std::valarray< TscalarAdd (T value) const override
 Addition of a scalar to the matrix values element-wise.
 
std::valarray< TmatrixAddElementWise (const DenseMatrix &dense_matrix) const
 Addition of two DenseMatrix objects element-wise.
 
std::valarray< TscalarSubtract (T value) const override
 Subtraction of a scalar from the matrix values element-wise.
 
std::valarray< TmatrixSubtractElementWise (const DenseMatrix &dense_matrix) const
 Subtraction of two DenseMatrix objects element-wise.
 
std::valarray< TscalarMultiply (T value) const override
 Multiplication of a scalar to the matrix values element-wise.
 
std::valarray< TmatrixMultiplyElementWise (const DenseMatrix &dense_matrix) const
 Multiplication of two DenseMatrix objects element-wise.
 
DenseMatrix< TmatrixMultiply (const DenseMatrix &dense_matrix) const
 Mathematical matrix multiplication of two DenseMatrix objects.
 
std::valarray< TscalarDivide (T value) const override
 Division of a scalar from the matrix values element-wise.
 
std::valarray< TmatrixDivideElementWise (const DenseMatrix &dense_matrix) const
 Division of two DenseMatrix objects element-wise.
 
void buildAtRuntime (int rows, int cols) override
 
void updateNonZeroElements () override
 
const std::vector< std::pair< int, int > > & getNonZeroElements () override
 
 ~DenseMatrix () override=default
 
- Public Member Functions inherited from GenericMatrix< T >
 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.
 
void zeroMatrix ()
 Function that zeros out the matrix.
 
virtual ~GenericMatrix ()=default
 

Additional Inherited Members

- Protected Attributes inherited from GenericMatrix< T >
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 DenseMatrix< T >

Concrete implemenatation of a matrix class representing a dense matrix. Offers basic access and element wise arithmetic functionality and mathematical matrix product.

Constructor & Destructor Documentation

◆ DenseMatrix() [1/5]

template<typename T >
DenseMatrix< T >::DenseMatrix ( )

Constructor used for buildAtRuntime.

◆ DenseMatrix() [2/5]

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

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

Parameters
rowsThe number of rows.
colsThe number of columns.

◆ DenseMatrix() [3/5]

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

Constructor for a DenseMatrix class 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.

◆ DenseMatrix() [4/5]

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

◆ DenseMatrix() [5/5]

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

◆ ~DenseMatrix()

template<typename T >
DenseMatrix< T >::~DenseMatrix ( )
overridedefault

Member Function Documentation

◆ buildAtRuntime()

template<typename T >
void DenseMatrix< T >::buildAtRuntime ( int  rows,
int  cols 
)
overridevirtual

Implements GenericMatrix< T >.

◆ getNonZeroElements()

template<typename T >
const std::vector< std::pair< int, int > > & DenseMatrix< T >::getNonZeroElements ( )
inlineoverridevirtual

Implements GenericMatrix< T >.

◆ matrixAddElementWise()

template<typename T >
std::valarray< T > DenseMatrix< T >::matrixAddElementWise ( const DenseMatrix< T > &  dense_matrix) const

Addition of two DenseMatrix objects element-wise.

Parameters
dense_matrixThe DenseMatrix object to be added to the calling object.

◆ matrixDivideElementWise()

template<typename T >
std::valarray< T > DenseMatrix< T >::matrixDivideElementWise ( const DenseMatrix< T > &  dense_matrix) const

Division of two DenseMatrix objects element-wise.

Parameters
dense_matrixThe DenseMatrix object to divide the calling object by.

◆ matrixMultiply()

template<typename T >
DenseMatrix< T > DenseMatrix< T >::matrixMultiply ( const DenseMatrix< T > &  dense_matrix) const

Mathematical matrix multiplication of two DenseMatrix objects.

Parameters
dense_matrixThe DenseMatrix object to be multiplied from the right to the calling object.

◆ matrixMultiplyElementWise()

template<typename T >
std::valarray< T > DenseMatrix< T >::matrixMultiplyElementWise ( const DenseMatrix< T > &  dense_matrix) const

Multiplication of two DenseMatrix objects element-wise.

Parameters
dense_matrixThe DenseMatrix object to be multiplied to the calling object.

◆ matrixSubtractElementWise()

template<typename T >
std::valarray< T > DenseMatrix< T >::matrixSubtractElementWise ( const DenseMatrix< T > &  dense_matrix) const

Subtraction of two DenseMatrix objects element-wise.

Parameters
dense_matrixThe DenseMatrix object to be subtracted from the calling object.

◆ operator()() [1/2]

template<typename T >
T DenseMatrix< T >::operator() ( int  rows,
int  cols 
) const
overridevirtual

Parentheses operator to allow access to the matrix values as Matrix(row,column) in a constant context.

Parameters
rowsthe row to access.
columnthe column to access.

Implements GenericMatrix< T >.

◆ operator()() [2/2]

template<typename T >
T & DenseMatrix< T >::operator() ( int  rows,
int  cols 
)
overridevirtual

Parentheses operator to allow access to the matrix values as Matrix(row,column).

Parameters
rowsthe row to access.
columnthe column to access.

Implements GenericMatrix< T >.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ scalarAdd()

template<typename T >
std::valarray< T > DenseMatrix< T >::scalarAdd ( T  value) const
overridevirtual

Addition of a scalar to the matrix values element-wise.

Parameters
valueThe scalar value to be added to the calling object.

Implements GenericMatrix< T >.

◆ scalarDivide()

template<typename T >
std::valarray< T > DenseMatrix< T >::scalarDivide ( T  value) const
overridevirtual

Division of a scalar from the matrix values element-wise.

Parameters
valueThe scalar value to divide to the calling object by.

Implements GenericMatrix< T >.

◆ scalarMultiply()

template<typename T >
std::valarray< T > DenseMatrix< T >::scalarMultiply ( T  value) const
overridevirtual

Multiplication of a scalar to the matrix values element-wise.

Parameters
valueThe scalar value to be multiplied to the calling object.

Implements GenericMatrix< T >.

◆ scalarSubtract()

template<typename T >
std::valarray< T > DenseMatrix< T >::scalarSubtract ( T  value) const
overridevirtual

Subtraction of a scalar from the matrix values element-wise.

Parameters
valueThe scalar value to be subtracted from the calling object.

Implements GenericMatrix< T >.

◆ updateNonZeroElements()

template<typename T >
void DenseMatrix< T >::updateNonZeroElements ( )
overridevirtual

Implements GenericMatrix< T >.


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