HyperHDG
Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
SmallMat< n_rowsT, n_colsT, mat_entry_t > Class Template Reference

This class implements a small/dense matrix. More...

#include <dense_la.hxx>

Public Types

typedef mat_entry_t value_type
 Define value_type of SmallMat as the typename of its entries! More...
 

Public Member Functions

 SmallMat ()
 Empty constructor for a SmallMat. More...
 
 SmallMat (const mat_entry_t entry_value)
 Construct SmallMat that contains specified value. More...
 
 SmallMat (const std::array< mat_entry_t, size()> &entries)
 Construct SmallMat from array of entries. More...
 
 SmallMat (std::array< mat_entry_t, size()> &&entries) noexcept
 Move constructor from array. More...
 
 SmallMat (const std::vector< mat_entry_t > &entries)
 Construct SmallMat from std::vector of entries. More...
 
 SmallMat (const SmallMat< n_rowsT, n_colsT, mat_entry_t > &other)
 Copy constructor. More...
 
template<typename other_entry_t >
 SmallMat (const SmallMat< n_rowsT, n_colsT, other_entry_t > &other)
 Conversion between different floating points artithmetics. More...
 
 SmallMat (SmallMat< n_rowsT, n_colsT, mat_entry_t > &&other) noexcept
 Move constructor. More...
 
SmallMat< n_rowsT, n_colsT, mat_entry_t > & operator= (const SmallMat< n_rowsT, n_colsT, mat_entry_t > &other)
 Copy assignment. More...
 
SmallMat< n_rowsT, n_colsT, mat_entry_t > & operator= (SmallMat< n_rowsT, n_colsT, mat_entry_t > &&other) noexcept
 Move assignment. More...
 
std::array< mat_entry_t, size()> & data ()
 Return data array that allows to manipulate the SmallMat. More...
 
const std::array< mat_entry_t, size()> & data () const
 Return data array of a constant SmallMat. More...
 
SmallMat< n_rowsT, 1, mat_entry_t > get_column (const unsigned int col) const
 Return a column of a SmallMat. More...
 
void set_column (const unsigned int col, const SmallMat< n_rowsT, 1, mat_entry_t > col_vec)
 Set column of a SmallMat. More...
 
mat_entry_t operator() (const unsigned int row, const unsigned int column) const
 Return single entry of a constant SmallMat. More...
 
mat_entry_t & operator() (const unsigned int row, const unsigned int column)
 Return reference to single entry of a SmallMat. More...
 
mat_entry_t operator[] (const unsigned int index) const
 Return single entry of a constant SmallMat. More...
 
mat_entry_t & operator[] (const unsigned int index)
 Return reference to single entry of a SmallMat. More...
 
bool operator== (const SmallMat< n_rowsT, n_colsT, mat_entry_t > &other) const
 Find out whether two SmallMats have (exactly) the same entries. More...
 
bool operator!= (const SmallMat< n_rowsT, n_colsT, mat_entry_t > &other) const
 Find out whether two SmallMats do not have (exactly) the same entries. More...
 
bool operator< (const SmallMat< n_rowsT, n_colsT, mat_entry_t > &other) const
 Find out whether the SmallMat is "smaller than" another SmallMat. More...
 
SmallMat< n_rowsT, n_colsT, mat_entry_t > & operator+= (const mat_entry_t scalar)
 Add scalar to a given SmallMat. More...
 
SmallMat< n_rowsT, n_colsT, mat_entry_t > & operator-= (const mat_entry_t scalar)
 Subtract scalar from a given SmallMat. More...
 
SmallMat< n_rowsT, n_colsT, mat_entry_t > & operator*= (const mat_entry_t scalar)
 Multiply SmallMat by a given scalar. More...
 
SmallMat< n_rowsT, n_colsT, mat_entry_t > & operator/= (const mat_entry_t scalar)
 Divide given SmallMat by a scalar. More...
 
template<unsigned int n_cols_other>
SmallMat< n_rowsT, n_colsT, mat_entry_t > & operator+= (const SmallMat< n_rowsT, n_cols_other, mat_entry_t > &other)
 Add SmallMat to given SmallMat. More...
 
template<unsigned int n_cols_other>
SmallMat< n_rowsT, n_colsT, mat_entry_t > & operator-= (const SmallMat< n_rowsT, n_cols_other, mat_entry_t > &other)
 Subtract other SmallMat from SmallMat. More...
 
SmallMat< n_rowsT, n_colsT, mat_entry_t > & operator*= (const SmallMat< n_rowsT, n_colsT, mat_entry_t > &other)
 Hadamard product with given SmallMat. More...
 
SmallMat< n_rowsT, n_colsT, mat_entry_t > & operator/= (const SmallMat< n_rowsT, n_colsT, mat_entry_t > &other)
 Hadamard division by given SmallMat. More...
 

Static Public Member Functions

static constexpr unsigned int n_rows ()
 Return number of rows of the matrix. More...
 
static constexpr unsigned int n_cols ()
 Return number of columns of the matrix. More...
 
static constexpr unsigned int size ()
 Return size a SmallMat. More...
 
static constexpr std::array< unsigned int, 2 > dimensions ()
 Return dimensions a SmallMat. More...
 

Static Private Member Functions

static unsigned int loc_matrix_index (const unsigned int row, const unsigned int column)
 Translate row and column indices to local index of entry in matrix' array entries_. More...
 

Private Attributes

std::array< mat_entry_t, size()> entries_
 Array containing the entries of the SmallMat. More...
 

Detailed Description

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
class SmallMat< n_rowsT, n_colsT, mat_entry_t >

This class implements a small/dense matrix.


Template Parameters
n_rowsTNumber of rows of the matrix.
n_colsTNumber of columns of the matrix. Defaults to create square matrix.
mat_entry_tFloating point type specification. Default is double.
Authors
Guido Kanschat, Heidelberg University, 2019–2020.
Andreas Rupp, Heidelberg University, 2019–2020.

Member Typedef Documentation

◆ value_type

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
typedef mat_entry_t SmallMat< n_rowsT, n_colsT, mat_entry_t >::value_type

Define value_type of SmallMat as the typename of its entries!


Constructor & Destructor Documentation

◆ SmallMat() [1/8]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat< n_rowsT, n_colsT, mat_entry_t >::SmallMat ( )
inline

Empty constructor for a SmallMat.


Fills entries of the SmallMat with zeros.

◆ SmallMat() [2/8]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat< n_rowsT, n_colsT, mat_entry_t >::SmallMat ( const mat_entry_t  entry_value)
inline

Construct SmallMat that contains specified value.


Fills entries of the SmallMat with given value.

◆ SmallMat() [3/8]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat< n_rowsT, n_colsT, mat_entry_t >::SmallMat ( const std::array< mat_entry_t, size()> &  entries)
inline

Construct SmallMat from array of entries.


Fills the SmallMat's array of entries with the input parameter.

Parameters
entriesA std::array containing the entries of the SmallMat.

◆ SmallMat() [4/8]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat< n_rowsT, n_colsT, mat_entry_t >::SmallMat ( std::array< mat_entry_t, size()> &&  entries)
inlinenoexcept

Move constructor from array.


◆ SmallMat() [5/8]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat< n_rowsT, n_colsT, mat_entry_t >::SmallMat ( const std::vector< mat_entry_t > &  entries)
inline

Construct SmallMat from std::vector of entries.


Fills the SmallMat's array of entries with the input parameter.

Parameters
entriesA std::array containing the entries of the SmallMat.

◆ SmallMat() [6/8]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat< n_rowsT, n_colsT, mat_entry_t >::SmallMat ( const SmallMat< n_rowsT, n_colsT, mat_entry_t > &  other)
inline

Copy constructor.


◆ SmallMat() [7/8]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
template<typename other_entry_t >
SmallMat< n_rowsT, n_colsT, mat_entry_t >::SmallMat ( const SmallMat< n_rowsT, n_colsT, other_entry_t > &  other)
inlineexplicit

Conversion between different floating points artithmetics.


◆ SmallMat() [8/8]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat< n_rowsT, n_colsT, mat_entry_t >::SmallMat ( SmallMat< n_rowsT, n_colsT, mat_entry_t > &&  other)
inlinenoexcept

Move constructor.


Member Function Documentation

◆ data() [1/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
std::array<mat_entry_t, size()>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::data ( )
inline

Return data array that allows to manipulate the SmallMat.


◆ data() [2/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
const std::array<mat_entry_t, size()>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::data ( ) const
inline

Return data array of a constant SmallMat.


◆ dimensions()

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
static constexpr std::array<unsigned int, 2> SmallMat< n_rowsT, n_colsT, mat_entry_t >::dimensions ( )
inlinestaticconstexpr

Return dimensions a SmallMat.


Return values
dimsNumber of rows and number of columns of the matrix.

◆ get_column()

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat<n_rowsT, 1, mat_entry_t> SmallMat< n_rowsT, n_colsT, mat_entry_t >::get_column ( const unsigned int  col) const
inline

Return a column of a SmallMat.


Parameters
colAn unsigned int referring to the column's index.
Return values
columnSmallMat that consists of the column.

◆ loc_matrix_index()

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
static unsigned int SmallMat< n_rowsT, n_colsT, mat_entry_t >::loc_matrix_index ( const unsigned int  row,
const unsigned int  column 
)
inlinestaticprivate

Translate row and column indices to local index of entry in matrix' array entries_.


Local \( m \times n \) matrices are encoded as arrays of size \(mn\). This function translates a row and a column index into the index of the long array, where the corresponding entry is located. Note that this is done column-wise (not row-wise as usually), to have the correct format for LAPACK.

The function is static inline, since it is used in the constructor's initializer list.

Parameters
rowRow index of local mtatrix entry.
columnColumn index of local matrix entry.
Return values
indexOverall index of local matrix entry.

◆ n_cols()

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
static constexpr unsigned int SmallMat< n_rowsT, n_colsT, mat_entry_t >::n_cols ( )
inlinestaticconstexpr

Return number of columns of the matrix.


Return values
n_colsNumber of columns of the matrix.

◆ n_rows()

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
static constexpr unsigned int SmallMat< n_rowsT, n_colsT, mat_entry_t >::n_rows ( )
inlinestaticconstexpr

Return number of rows of the matrix.


Return values
n_rowsNumber of rows of the matrix.

◆ operator!=()

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
bool SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator!= ( const SmallMat< n_rowsT, n_colsT, mat_entry_t > &  other) const
inline

Find out whether two SmallMats do not have (exactly) the same entries.


This function compares the SmallMat to another SmallMat and returns false if and only if both SmallMats have exactly (that is not only with respect to some rounding errors) the same entries.

Parameters
otherAnother SmallMat<n_rows,n_cols> that is to be dicriminated from.
Return values
isEqualA boolean which is false if both SmallMats have the same entries.

◆ operator()() [1/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
mat_entry_t& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator() ( const unsigned int  row,
const unsigned int  column 
)
inline

Return reference to single entry of a SmallMat.


Parameters
rowRow index of the matrix entry to be returned.
columnColumn index of the matrix entry to be returned.
Return values
entryA reference to a mat_entry_t describing the matrix entry.

◆ operator()() [2/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
mat_entry_t SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator() ( const unsigned int  row,
const unsigned int  column 
) const
inline

Return single entry of a constant SmallMat.


Parameters
rowRow index of the matrix entry to be returned.
columnColumn index of the matrix entry to be returned.
Return values
entryMatrix entry at given position.

◆ operator*=() [1/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat<n_rowsT, n_colsT, mat_entry_t>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator*= ( const mat_entry_t  scalar)
inline

Multiply SmallMat by a given scalar.


Parameters
scalarFloating point that is multiplied with all of the SmallMat's entries.
Return values
thisThe updated SmallMat.

◆ operator*=() [2/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat<n_rowsT, n_colsT, mat_entry_t>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator*= ( const SmallMat< n_rowsT, n_colsT, mat_entry_t > &  other)
inline

Hadamard product with given SmallMat.


Parameters
otherSmallMat whose entries are multiplied by the respective ones of this.
Return values
thisThe updated SmallMat.

◆ operator+=() [1/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat<n_rowsT, n_colsT, mat_entry_t>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator+= ( const mat_entry_t  scalar)
inline

Add scalar to a given SmallMat.


Parameters
scalarFloating point that is added to all of the SmallMat's entries.
Return values
thisThe updated SmallMat.

◆ operator+=() [2/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
template<unsigned int n_cols_other>
SmallMat<n_rowsT, n_colsT, mat_entry_t>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator+= ( const SmallMat< n_rowsT, n_cols_other, mat_entry_t > &  other)
inline

Add SmallMat to given SmallMat.


Parameters
otherSmallMat whose entries are added to respective ones of this.
Return values
thisThe updated SmallMat.

◆ operator-=() [1/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat<n_rowsT, n_colsT, mat_entry_t>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator-= ( const mat_entry_t  scalar)
inline

Subtract scalar from a given SmallMat.


Parameters
scalarFloating point that is subtracted from all of the SmallMat's entries.
Return values
thisThe updated SmallMat.

◆ operator-=() [2/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
template<unsigned int n_cols_other>
SmallMat<n_rowsT, n_colsT, mat_entry_t>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator-= ( const SmallMat< n_rowsT, n_cols_other, mat_entry_t > &  other)
inline

Subtract other SmallMat from SmallMat.


Parameters
otherSmallMat whose entries are subtracted from the respective ones of this.
Return values
thisThe updated SmallMat.

◆ operator/=() [1/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat<n_rowsT, n_colsT, mat_entry_t>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator/= ( const mat_entry_t  scalar)
inline

Divide given SmallMat by a scalar.


Parameters
scalarFloating SmallMat ( \(\neq 0\)) all entries are divided by.
Return values
thisThe updated SmallMat.

◆ operator/=() [2/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat<n_rowsT, n_colsT, mat_entry_t>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator/= ( const SmallMat< n_rowsT, n_colsT, mat_entry_t > &  other)
inline

Hadamard division by given SmallMat.


Parameters
otherSmallMat whose respective entries of this are divided by.
Return values
thisThe updated SmallMat.

◆ operator<()

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
bool SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator< ( const SmallMat< n_rowsT, n_colsT, mat_entry_t > &  other) const
inline

Find out whether the SmallMat is "smaller than" another SmallMat.


This function compares the SmallMat to another SmallMat and returns true if and only if the lowest ranked entry (according to the entry index) where the both SmallMats are not equal of the given SmallMat is smaller than that of the other SmallMat. It is false, if both SmallMats are equal.

Parameters
otherAnother SmallMat<n_rows,n_cols> that is to be dicriminated from.
Return values
smalllerA boolean which is true if \ยข this is strictly smaller than other.

◆ operator=() [1/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat<n_rowsT, n_colsT, mat_entry_t>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator= ( const SmallMat< n_rowsT, n_colsT, mat_entry_t > &  other)
inline

Copy assignment.


◆ operator=() [2/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
SmallMat<n_rowsT, n_colsT, mat_entry_t>& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator= ( SmallMat< n_rowsT, n_colsT, mat_entry_t > &&  other)
inlinenoexcept

Move assignment.


◆ operator==()

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
bool SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator== ( const SmallMat< n_rowsT, n_colsT, mat_entry_t > &  other) const
inline

Find out whether two SmallMats have (exactly) the same entries.


This function compares the SmallMat to another SmallMat and returns true if and only if both SmallMats have exactly (that is not only with respect to some rounding errors) the same entries.

Parameters
otherAnother SmallMat<n_rows,n_cols> that is to be dicriminated from.
Return values
isEqualA boolean which is true if both SmallMats have the same entries.

◆ operator[]() [1/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
mat_entry_t& SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator[] ( const unsigned int  index)
inline

Return reference to single entry of a SmallMat.


Parameters
indexAn unsigned int referring to the entry that is to be returned.
Return values
entryReference to mat_entry_t being the entry at given index.

◆ operator[]() [2/2]

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
mat_entry_t SmallMat< n_rowsT, n_colsT, mat_entry_t >::operator[] ( const unsigned int  index) const
inline

Return single entry of a constant SmallMat.


Parameters
indexAn unsigned int referring to the entry that is to be returned.
Return values
entrymat_entry_t being the entry at given index.

◆ set_column()

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
void SmallMat< n_rowsT, n_colsT, mat_entry_t >::set_column ( const unsigned int  col,
const SmallMat< n_rowsT, 1, mat_entry_t >  col_vec 
)
inline

Set column of a SmallMat.


Parameters
colAn unsigned int referring to the column's index.
col_vecThe column that should be located at the position col.

◆ size()

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
static constexpr unsigned int SmallMat< n_rowsT, n_colsT, mat_entry_t >::size ( )
inlinestaticconstexpr

Return size a SmallMat.


Return values
sizeAmount of entries that can be stored within the matrix

Member Data Documentation

◆ entries_

template<unsigned int n_rowsT, unsigned int n_colsT = n_rowsT, typename mat_entry_t = double>
std::array<mat_entry_t, size()> SmallMat< n_rowsT, n_colsT, mat_entry_t >::entries_
private

Array containing the entries of the SmallMat.



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