MFEM  v4.5.2
Finite element discretization library
Public Member Functions | List of all members
mfem::TAutoDiffDenseMatrix< dtype > Class Template Reference

Templated dense matrix data type. More...

#include <taddensemat.hpp>

Public Member Functions

int Height () const
 Get the height (size of output) of the Operator. Synonym with NumRows(). More...
 
int NumRows () const
 Get the number of rows (size of output) of the Operator. Synonym with Height(). More...
 
int Width () const
 Get the width (size of input) of the Operator. Synonym with NumCols(). More...
 
int NumCols () const
 Get the number of columns (size of input) of the Operator. Synonym with Width(). More...
 
 TAutoDiffDenseMatrix ()
 
template<typename idtype >
 TAutoDiffDenseMatrix (const TAutoDiffDenseMatrix< idtype > &m)
 Copy constructor. More...
 
 TAutoDiffDenseMatrix (const DenseMatrix &m)
 Copy constructor using standard DenseMatrix. More...
 
 TAutoDiffDenseMatrix (int s)
 Creates square matrix of size s. More...
 
 TAutoDiffDenseMatrix (int m, int n)
 Creates rectangular matrix of size m x n. More...
 
 TAutoDiffDenseMatrix (const TAutoDiffDenseMatrix< dtype > &mat, char ch)
 
void SetSize (int s)
 Change the size of the DenseMatrix to s x s. More...
 
void SetSize (int h, int w)
 Change the size of the DenseMatrix to h x w. More...
 
dtype * Data () const
 Returns the matrix data array. More...
 
dtype * GetData () const
 Returns the matrix data array. More...
 
bool OwnsData () const
 
dtype & operator() (int i, int j)
 Returns reference to a_{ij}. More...
 
const dtype & operator() (int i, int j) const
 
dtype & Elem (int i, int j)
 
const dtype & Elem (int i, int j) const
 
void Mult (const dtype *x, dtype *y) const
 
void Mult (const TAutoDiffVector< dtype > &x, TAutoDiffVector< dtype > &y) const
 
dtype operator* (const TAutoDiffDenseMatrix< dtype > &m) const
 
void MultTranspose (const dtype *x, dtype *y) const
 
void MultTranspose (const TAutoDiffVector< dtype > &x, TAutoDiffVector< dtype > &y) const
 
void Randomize (int seed)
 
void RandomizeDiag (int seed)
 
void Diag (dtype c, int n)
 Creates n x n diagonal matrix with diagonal elements c. More...
 
template<typename itype >
void Diag (itype *diag, int n)
 Creates n x n diagonal matrix with diagonal given by diag. More...
 
void Transpose ()
 (*this) = (*this)^t More...
 
template<typename itype >
void Transpose (const TAutoDiffDenseMatrix< itype > &A)
 (*this) = A^t More...
 
void Symmetrize ()
 (*this) = 1/2 ((*this) + (*this)^t) More...
 
void Lump ()
 

Detailed Description

template<typename dtype>
class mfem::TAutoDiffDenseMatrix< dtype >

Templated dense matrix data type.

The main goal of the TAutoDiffDenseMatrix class is to serve as a data container for representing dense matrices in classes, methods, and functions utilized with automatic differentiation (AD). The functionality/interface is copied from the standard MFEM dense matrix mfem::DenseMatrix. The basic idea is to utilize the templated vector class in combination with AD during the development phase. The AD parts can be replaced with optimized code once the initial development of the application is complete. The common interface between TAutoDiffDenseMatrix and DenseMatrix will ease the transition from AD to hand-optimized code as it does not require a change in the interface or the code structure. TAutoDiffDenseMatrix is intended to be utilized for dense serial matrices. The objects can be combined with TAutoDiffVector or standard Vector.

Definition at line 34 of file taddensemat.hpp.

Constructor & Destructor Documentation

◆ TAutoDiffDenseMatrix() [1/6]

template<typename dtype>
mfem::TAutoDiffDenseMatrix< dtype >::TAutoDiffDenseMatrix ( )
inline

Default constructor for TAutoDiffDenseMatrix. Sets data = NULL and height = width = 0.

Definition at line 57 of file taddensemat.hpp.

◆ TAutoDiffDenseMatrix() [2/6]

template<typename dtype>
template<typename idtype >
mfem::TAutoDiffDenseMatrix< dtype >::TAutoDiffDenseMatrix ( const TAutoDiffDenseMatrix< idtype > &  m)
inline

Copy constructor.

Definition at line 67 of file taddensemat.hpp.

◆ TAutoDiffDenseMatrix() [3/6]

template<typename dtype>
mfem::TAutoDiffDenseMatrix< dtype >::TAutoDiffDenseMatrix ( const DenseMatrix m)
inline

Copy constructor using standard DenseMatrix.

Definition at line 92 of file taddensemat.hpp.

◆ TAutoDiffDenseMatrix() [4/6]

template<typename dtype>
mfem::TAutoDiffDenseMatrix< dtype >::TAutoDiffDenseMatrix ( int  s)
inlineexplicit

Creates square matrix of size s.

Definition at line 118 of file taddensemat.hpp.

◆ TAutoDiffDenseMatrix() [5/6]

template<typename dtype>
mfem::TAutoDiffDenseMatrix< dtype >::TAutoDiffDenseMatrix ( int  m,
int  n 
)
inline

Creates rectangular matrix of size m x n.

Definition at line 135 of file taddensemat.hpp.

◆ TAutoDiffDenseMatrix() [6/6]

template<typename dtype>
mfem::TAutoDiffDenseMatrix< dtype >::TAutoDiffDenseMatrix ( const TAutoDiffDenseMatrix< dtype > &  mat,
char  ch 
)
inline

Definition at line 152 of file taddensemat.hpp.

Member Function Documentation

◆ Data()

template<typename dtype>
dtype* mfem::TAutoDiffDenseMatrix< dtype >::Data ( ) const
inline

Returns the matrix data array.

Definition at line 202 of file taddensemat.hpp.

◆ Diag() [1/2]

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::Diag ( dtype  c,
int  n 
)
inline

Creates n x n diagonal matrix with diagonal elements c.

Definition at line 339 of file taddensemat.hpp.

◆ Diag() [2/2]

template<typename dtype>
template<typename itype >
void mfem::TAutoDiffDenseMatrix< dtype >::Diag ( itype *  diag,
int  n 
)
inline

Creates n x n diagonal matrix with diagonal given by diag.

Definition at line 355 of file taddensemat.hpp.

◆ Elem() [1/2]

template<typename dtype>
dtype& mfem::TAutoDiffDenseMatrix< dtype >::Elem ( int  i,
int  j 
)
inline

Definition at line 221 of file taddensemat.hpp.

◆ Elem() [2/2]

template<typename dtype>
const dtype& mfem::TAutoDiffDenseMatrix< dtype >::Elem ( int  i,
int  j 
) const
inline

Definition at line 223 of file taddensemat.hpp.

◆ GetData()

template<typename dtype>
dtype* mfem::TAutoDiffDenseMatrix< dtype >::GetData ( ) const
inline

Returns the matrix data array.

Definition at line 204 of file taddensemat.hpp.

◆ Height()

template<typename dtype>
int mfem::TAutoDiffDenseMatrix< dtype >::Height ( ) const
inline

Get the height (size of output) of the Operator. Synonym with NumRows().

Definition at line 44 of file taddensemat.hpp.

◆ Lump()

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::Lump ( )
inline

Definition at line 423 of file taddensemat.hpp.

◆ Mult() [1/2]

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::Mult ( const dtype *  x,
dtype *  y 
) const
inline

Definition at line 225 of file taddensemat.hpp.

◆ Mult() [2/2]

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::Mult ( const TAutoDiffVector< dtype > &  x,
TAutoDiffVector< dtype > &  y 
) const
inline

Definition at line 253 of file taddensemat.hpp.

◆ MultTranspose() [1/2]

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::MultTranspose ( const dtype *  x,
dtype *  y 
) const
inline

Definition at line 276 of file taddensemat.hpp.

◆ MultTranspose() [2/2]

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::MultTranspose ( const TAutoDiffVector< dtype > &  x,
TAutoDiffVector< dtype > &  y 
) const
inline

Definition at line 291 of file taddensemat.hpp.

◆ NumCols()

template<typename dtype>
int mfem::TAutoDiffDenseMatrix< dtype >::NumCols ( ) const
inline

Get the number of columns (size of input) of the Operator. Synonym with Width().

Definition at line 53 of file taddensemat.hpp.

◆ NumRows()

template<typename dtype>
int mfem::TAutoDiffDenseMatrix< dtype >::NumRows ( ) const
inline

Get the number of rows (size of output) of the Operator. Synonym with Height().

Definition at line 47 of file taddensemat.hpp.

◆ operator()() [1/2]

template<typename dtype>
dtype& mfem::TAutoDiffDenseMatrix< dtype >::operator() ( int  i,
int  j 
)
inline

Returns reference to a_{ij}.

Definition at line 209 of file taddensemat.hpp.

◆ operator()() [2/2]

template<typename dtype>
const dtype& mfem::TAutoDiffDenseMatrix< dtype >::operator() ( int  i,
int  j 
) const
inline

Definition at line 215 of file taddensemat.hpp.

◆ operator*()

template<typename dtype>
dtype mfem::TAutoDiffDenseMatrix< dtype >::operator* ( const TAutoDiffDenseMatrix< dtype > &  m) const
inline

Definition at line 261 of file taddensemat.hpp.

◆ OwnsData()

template<typename dtype>
bool mfem::TAutoDiffDenseMatrix< dtype >::OwnsData ( ) const
inline

Definition at line 206 of file taddensemat.hpp.

◆ Randomize()

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::Randomize ( int  seed)
inline

Definition at line 300 of file taddensemat.hpp.

◆ RandomizeDiag()

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::RandomizeDiag ( int  seed)
inline

Definition at line 319 of file taddensemat.hpp.

◆ SetSize() [1/2]

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::SetSize ( int  s)
inline

Change the size of the DenseMatrix to s x s.

Definition at line 176 of file taddensemat.hpp.

◆ SetSize() [2/2]

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::SetSize ( int  h,
int  w 
)
inline

Change the size of the DenseMatrix to h x w.

Definition at line 179 of file taddensemat.hpp.

◆ Symmetrize()

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::Symmetrize ( )
inline

(*this) = 1/2 ((*this) + (*this)^t)

Definition at line 406 of file taddensemat.hpp.

◆ Transpose() [1/2]

template<typename dtype>
void mfem::TAutoDiffDenseMatrix< dtype >::Transpose ( )
inline

(*this) = (*this)^t

Definition at line 371 of file taddensemat.hpp.

◆ Transpose() [2/2]

template<typename dtype>
template<typename itype >
void mfem::TAutoDiffDenseMatrix< dtype >::Transpose ( const TAutoDiffDenseMatrix< itype > &  A)
inline

(*this) = A^t

Definition at line 394 of file taddensemat.hpp.

◆ Width()

template<typename dtype>
int mfem::TAutoDiffDenseMatrix< dtype >::Width ( ) const
inline

Get the width (size of input) of the Operator. Synonym with NumCols().

Definition at line 50 of file taddensemat.hpp.


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