FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ > Class Template Reference

Tiny Matrix class template. More...

#include <tiny_algebra.hpp>

Public Types

typedef Intern::DataTypeExtractor< ValueType >::MyDataType DataType
 The basic data type buried in the lowest level of the vector. More...
 
typedef Vector< T_, n_, sn_ > RowType
 the type of a single matrix row More...
 
typedef T_ ValueType
 the data type of the matrix More...
 

Public Member Functions

CUDA_HOST_DEVICE Matrix ()
 default constructor More...
 
template<typename T2_ , int sma_, int sna_>
CUDA_HOST_DEVICE Matrix (const Matrix< T2_, m_, n_, sma_, sna_ > &a)
 copy constructor More...
 
template<typename Tx_ >
CUDA_HOST_DEVICE Matrix (const std::initializer_list< std::initializer_list< Tx_ > > &x)
 Initializer list constructor. More...
 
template<typename Tx_ >
CUDA_HOST_DEVICE Matrix (const std::initializer_list< Tx_ > &x)
 Initializer list of Tiny::Vector constructor. More...
 
CUDA_HOST_DEVICE Matrix (DataType value)
 value-assignment constructor More...
 
template<int k_, int l_, int sma_, int sna_, int smb_, int snb_, int smd_, int snd_>
CUDA_HOST_DEVICE Matrixadd_double_mat_mult (const Matrix< T_, k_, l_, sma_, sna_ > &a, const Matrix< T_, k_, m_, smb_, snb_ > &b, const Matrix< T_, l_, n_, smd_, snd_ > &d, DataType alpha=DataType(1))
 Adds the algebraic matrix double-product of three other matrices onto this matrix. More...
 
template<int la_, int lb_, int sma_, int sna_, int smb_, int snb_>
CUDA_HOST_DEVICE Matrixadd_mat_mat_mult (const Matrix< T_, m_, la_, sma_, sna_ > &a, const Matrix< T_, lb_, n_, smb_, snb_ > &b, DataType alpha=DataType(1))
 Adds the algebraic matrix-product of two other matrices onto this matrix. More...
 
template<int snx_, int sny_>
CUDA_HOST_DEVICE Matrixadd_outer_product (const Vector< T_, m_, snx_ > &x, const Vector< T_, n_, sny_ > &y, const DataType alpha=DataType(1))
 Adds the outer product of two vectors onto the matrix. More...
 
CUDA_HOST_DEVICE Matrixadd_scalar_main_diag (DataType alpha)
 Adds a value onto the matrix's main diagonal. More...
 
template<int l_, int snv_, int slt_, int smt_, int snt_>
CUDA_HOST_DEVICE Matrixadd_vec_tensor_mult (const Vector< T_, l_, snv_ > &x, const Tensor3< T_, l_, m_, n_, slt_, smt_, snt_ > &t, DataType alpha=DataType(1))
 Adds the result of a vector-tensor left-product onto this matrix. More...
 
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrixaxpy (DataType alpha, const Matrix< T_, m_, n_, sma_, sna_ > &a)
 Adds another scaled matrix onto this matrix. More...
 
template<typename Tx_ , int sma_, int sna_>
CUDA_HOST_DEVICE void convert (const Matrix< Tx_, m_, n_, sma_, sna_ > &a)
 conversion operator More...
 
template<int sma_, int sna_>
CUDA_HOST_DEVICE void copy (const Matrix< T_, m_, n_, sma_, sna_ > &a)
 Copies a matrix. More...
 
template<int mm_, int nn_, int ma_, int na_, int sma_, int sna_>
CUDA_HOST_DEVICE void copy_n (const Matrix< T_, ma_, na_, sma_, sna_ > &a)
 Copies the upper left mm_ x nn_ entries of a matrix. More...
 
CUDA_HOST_DEVICE DataType det () const
 Returns the determinant of the matrix. More...
 
CUDA_HOST_DEVICE void format (DataType alpha=DataType(0))
 Formats the matrix. More...
 
CUDA_HOST_DEVICE DataType norm_frobenius () const
 Returns the Frobenius norm of the matrix. More...
 
CUDA_HOST_DEVICE DataType norm_frobenius_sqr () const
 Returns the Frobenius norm squared of the matrix. More...
 
CUDA_HOST_DEVICE DataType norm_hessian_sqr () const
 Returns the Hessian norm square. More...
 
CUDA_HOST_DEVICE DataType norm_sub_id_frobenius () const
 Returns the Frobenius norm of the difference of this matrix and the identity matrix. More...
 
CUDA_HOST_DEVICE T_ & operator() (int i, int j)
 Access operator. More...
 
CUDA_HOST_DEVICE const T_ & operator() (int i, int j) const
 Access operator. More...
 
CUDA_HOST_DEVICE Matrixoperator*= (DataType alpha)
 scalar-right-multiply-by operator More...
 
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrixoperator+= (const Matrix< T_, m_, n_, sma_, sna_ > &a)
 matrix component-wise addition operator More...
 
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrixoperator-= (const Matrix< T_, m_, n_, sma_, sna_ > &a)
 matrix component-wise subtraction operator More...
 
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrixoperator= (const Matrix< T_, m_, n_, sma_, sna_ > &a)
 assignment operator More...
 
template<typename Tx_ >
CUDA_HOST_DEVICE Matrixoperator= (const std::initializer_list< std::initializer_list< Tx_ > > &x)
 Initializer list assignment operator. More...
 
template<typename Tx_ >
CUDA_HOST_DEVICE Matrixoperator= (const std::initializer_list< Tx_ > &x)
 Initializer list assignment operator. More...
 
CUDA_HOST_DEVICE Matrixoperator= (DataType value)
 value-assignment operator More...
 
CUDA_HOST_DEVICE RowTypeoperator[] (int i)
 Row-Access operator. More...
 
CUDA_HOST_DEVICE const RowTypeoperator[] (int i) const
 Row-Access operator. More...
 
template<int snx_, int sny_>
CUDA_HOST_DEVICE DataType scalar_product (const Vector< T_, m_, snx_ > &x, const Vector< T_, n_, sny_ > &y) const
 Computes the scalar product of two vectors with this matrix. More...
 
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrixset_cofactor (const Matrix< T_, m_, n_, sma_, sna_ > &a)
 Sets this matrix to the cofactor matrix of another matrix. More...
 
template<int k_, int l_, int sma_, int sna_, int smb_, int snb_, int smd_, int snd_>
CUDA_HOST_DEVICE Matrixset_double_mat_mult (const Matrix< T_, k_, l_, sma_, sna_ > &a, const Matrix< T_, k_, m_, smb_, snb_ > &b, const Matrix< T_, l_, n_, smd_, snd_ > &d, T_ alpha=T_(1))
 Sets this matrix to the algebraic matrix double-product of three other matrices. More...
 
template<int l_, int sla_, int sna_>
CUDA_HOST_DEVICE Matrixset_gram (const Matrix< T_, l_, n_, sla_, sna_ > &a)
 Sets this matrix to the Gram matrix of another matrix. More...
 
CUDA_HOST_DEVICE Matrixset_identity ()
 Sets this matrix to the identity matrix. More...
 
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrixset_inverse (const Matrix< T_, m_, n_, sma_, sna_ > &a)
 Sets this matrix to the inverse of another matrix. More...
 
template<int la_, int lb_, int sma_, int sna_, int smb_, int snb_>
CUDA_HOST_DEVICE Matrixset_mat_mat_mult (const Matrix< T_, m_, la_, sma_, sna_ > &a, const Matrix< T_, lb_, n_, smb_, snb_ > &b)
 Sets this matrix to the algebraic matrix-product of two other matrices. More...
 
template<int snx_, int sny_>
CUDA_HOST_DEVICE Matrixset_outer_product (const Vector< T_, m_, snx_ > &x, const Vector< T_, n_, sny_ > &y)
 Sets this matrix to the outer product of two vectors. More...
 
CUDA_HOST_DEVICE Matrixset_rotation_2d (T_ angle)
 Sets this matrix to a 2D rotation matrix. More...
 
CUDA_HOST_DEVICE Matrixset_rotation_3d (T_ yaw, T_ pitch, T_ roll)
 Sets this matrix to a 3D yaw-pitch-roll rotation matrix. More...
 
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrixset_transpose (const Matrix< T_, n_, m_, sma_, sna_ > &a)
 Sets this matrix to the transpose of another matrix. More...
 
template<int l_, int snv_, int slt_, int smt_, int snt_>
CUDA_HOST_DEVICE Matrixset_vec_tensor_mult (const Vector< T_, l_, snv_ > &x, const Tensor3< T_, l_, m_, n_, slt_, smt_, snt_ > &t, DataType alpha=DataType(1))
 Sets this matrix to the result of a vector-tensor left-product. More...
 
CUDA_HOST_DEVICE DataType trace () const
 Returns the trace of the matrix. More...
 
CUDA_HOST_DEVICE DataType vol () const
 Returns the volume of the matrix. More...
 

Static Public Member Functions

static CUDA_HOST_DEVICE Matrix null ()
 Returns a null-matrix. More...
 

Public Attributes

RowType v [sm_]
 actual matrix data; that's an array of vectors More...
 

Static Public Attributes

static constexpr int m = m_
 the row count of the matrix More...
 
static constexpr int n = n_
 the column count of the matrix More...
 
static constexpr int sm = sm_
 the row stride of the matrix More...
 
static constexpr int sn = sn_
 the column stride of the matrix More...
 

Friends

CUDA_HOST friend std::ostream & operator<< (std::ostream &lhs, const Matrix &A)
 Tiny::Matrix streaming operator. More...
 

Detailed Description

template<typename T_, int m_, int n_, int sm_ = m_, int sn_ = n_>
class FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >

Tiny Matrix class template.

This class template implements a matrix whose value type and size is given at compile-time. The value type can be a primitive type, or some other object like a Vector.

Template Parameters
T_The datatype that the vector shall contain.
m_,n_The number rows and columns of the matrix. Must be > 0.
sm_The row stride of the matrix. Must be >= m_.
sn_The column stride of the matrix. Must be >= n_.
Author
Peter Zajac

Definition at line 80 of file tiny_algebra.hpp.

Member Typedef Documentation

◆ DataType

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
typedef Intern::DataTypeExtractor<ValueType>::MyDataType FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::DataType

The basic data type buried in the lowest level of the vector.

Definition at line 1306 of file tiny_algebra.hpp.

◆ RowType

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
typedef Vector<T_, n_, sn_> FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::RowType

the type of a single matrix row

Definition at line 1309 of file tiny_algebra.hpp.

◆ ValueType

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
typedef T_ FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::ValueType

the data type of the matrix

Definition at line 1304 of file tiny_algebra.hpp.

Constructor & Destructor Documentation

◆ Matrix() [1/5]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::Matrix ( )
inline

default constructor

Definition at line 1314 of file tiny_algebra.hpp.

◆ Matrix() [2/5]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::Matrix ( DataType  value)
inlineexplicit

value-assignment constructor

Definition at line 1319 of file tiny_algebra.hpp.

References FEAT::value.

◆ Matrix() [3/5]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<typename T2_ , int sma_, int sna_>
CUDA_HOST_DEVICE FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::Matrix ( const Matrix< T2_, m_, n_, sma_, sna_ > &  a)
inline

copy constructor

Definition at line 1329 of file tiny_algebra.hpp.

References FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::v.

◆ Matrix() [4/5]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<typename Tx_ >
CUDA_HOST_DEVICE FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::Matrix ( const std::initializer_list< Tx_ > &  x)
inlineexplicit

Initializer list of Tiny::Vector constructor.

Tiny Matrix class template.
static constexpr int m
the row count of the matrix
RowType v[sm_]
actual matrix data; that's an array of vectors
Tiny Vector class template.
Parameters
[in]xThe initializer list whose elements are to be assigned.

Definition at line 1352 of file tiny_algebra.hpp.

References XASSERTM.

◆ Matrix() [5/5]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<typename Tx_ >
CUDA_HOST_DEVICE FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::Matrix ( const std::initializer_list< std::initializer_list< Tx_ > > &  x)
inlineexplicit

Initializer list constructor.

Note
This overload seems to be necessary, because the example code below does not compile otherwise for some reason that I do not understand...
Tiny::Matrix<double, 2, 2> v{{0.0, 1.0}, {2.0, 3.0}};
Parameters
[in]xThe initializer list whose elements are to be assigned.

Definition at line 1374 of file tiny_algebra.hpp.

References XASSERTM.

Member Function Documentation

◆ add_double_mat_mult()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int k_, int l_, int sma_, int sna_, int smb_, int snb_, int smd_, int snd_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::add_double_mat_mult ( const Matrix< T_, k_, l_, sma_, sna_ > &  a,
const Matrix< T_, k_, m_, smb_, snb_ > &  b,
const Matrix< T_, l_, n_, smd_, snd_ > &  d,
DataType  alpha = DataType(1) 
)
inline

Adds the algebraic matrix double-product of three other matrices onto this matrix.

Let C denote this m-by-n matrix, B the left k-by-m input matrix, D the right l-by-n input matrix and A the inner k-by-l input matrix, then this operation computes:

\[ C \leftarrow C + \alpha B^\top\cdot A\cdot D\]

Parameters
[in]aThe inner k-by-l multiplicand matrix.
[in]bThe left k-by-m multiplicand matrix.
[in]dThe right l-by-n multiplicand matrix.
[in]alphaA scaling factor for the product.
Returns
*this

Definition at line 2083 of file tiny_algebra.hpp.

References ASSERTM.

◆ add_mat_mat_mult()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int la_, int lb_, int sma_, int sna_, int smb_, int snb_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::add_mat_mat_mult ( const Matrix< T_, m_, la_, sma_, sna_ > &  a,
const Matrix< T_, lb_, n_, smb_, snb_ > &  b,
DataType  alpha = DataType(1) 
)
inline

Adds the algebraic matrix-product of two other matrices onto this matrix.

Let C denote this matrix, and let A denote the left m-by-l matrix and B the right l-by-n matrix, then this function computes:

\[ C\leftarrow C + \alpha A\cdot B \]

Parameters
[in]aThe left m-by-l multiplicand matrix.
[in]bThe right l-by-n multiplicand matrix.
[in]alphaA scaling factor for the product.
Returns
*this

Definition at line 2009 of file tiny_algebra.hpp.

References ASSERTM.

◆ add_outer_product()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int snx_, int sny_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::add_outer_product ( const Vector< T_, m_, snx_ > &  x,
const Vector< T_, n_, sny_ > &  y,
const DataType  alpha = DataType(1) 
)
inline

◆ add_scalar_main_diag()

◆ add_vec_tensor_mult()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int l_, int snv_, int slt_, int smt_, int snt_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::add_vec_tensor_mult ( const Vector< T_, l_, snv_ > &  x,
const Tensor3< T_, l_, m_, n_, slt_, smt_, snt_ > &  t,
DataType  alpha = DataType(1) 
)
inline

Adds the result of a vector-tensor left-product onto this matrix.

Let A denote this m-by-n matrix, v the l-size input vector and T the l-by-m-by-b input tensor, then this operation computes:

\[ \forall i\in\{0,...,m-1\},j\in\{0,...,n-1\}:~ A_{ij} \leftarrow A_{ij} + \alpha \sum_{k=0}^{l-1} v_k\cdot T_{kij}\]

Note
This function is used for the computation of second-order derivatives by the chain rule.
Parameters
[in]xThe l-size vector that serves as a left multiplicand.
[in]tThe l-by-m-by-n tensor that serves as a right multiplicand.
[in]alphaA scaling factor for the product.
Returns
*this

Definition at line 2172 of file tiny_algebra.hpp.

◆ axpy()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::axpy ( DataType  alpha,
const Matrix< T_, m_, n_, sma_, sna_ > &  a 
)
inline

◆ convert()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<typename Tx_ , int sma_, int sna_>
CUDA_HOST_DEVICE void FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::convert ( const Matrix< Tx_, m_, n_, sma_, sna_ > &  a)
inline

conversion operator

Definition at line 1448 of file tiny_algebra.hpp.

References FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::v.

◆ copy()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int sma_, int sna_>
CUDA_HOST_DEVICE void FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::copy ( const Matrix< T_, m_, n_, sma_, sna_ > &  a)
inline

Copies a matrix.

Parameters
[in]aThe source matrix to copy

Definition at line 1539 of file tiny_algebra.hpp.

References FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::v.

◆ copy_n()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int mm_, int nn_, int ma_, int na_, int sma_, int sna_>
CUDA_HOST_DEVICE void FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::copy_n ( const Matrix< T_, ma_, na_, sma_, sna_ > &  a)
inline

Copies the upper left mm_ x nn_ entries of a matrix.

Template Parameters
mm_The number of matrix rows to copy; must be mm_ <= min(m_, ma_)
nn_The number of matrix columns to copy; must be nn_ <= min(n_, na_)
Parameters
[in]xThe source vector to copy the elements from

Definition at line 1559 of file tiny_algebra.hpp.

References FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::v.

◆ det()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE DataType FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::det ( ) const
inline

Returns the determinant of the matrix.

Warning
This function only works for m_ = n_ and will intentionally fail to compile in any other case.
Returns
The determinant of the matrix.

Definition at line 1716 of file tiny_algebra.hpp.

◆ format()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE void FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::format ( DataType  alpha = DataType(0))
inline

Formats the matrix.

Parameters
[in]alphaThe value that the matrix is to be set to.

Definition at line 1576 of file tiny_algebra.hpp.

References FEAT::Tiny::Vector< T_, n_, s_ >::format().

Referenced by FEAT::Assembly::TraceAssemblyStokesBodyForceAssemblyJob< VectorVelo_, VectorPres_, SpaceVelo_, SpacePres_ >::TraceAssemblyStokesBodyForceAssemblyJob(), FEAT::Assembly::BurgersBlockedAssemblyTaskBase< Job_, DataType_, block_size_ >::assemble(), FEAT::Assembly::BurgersScalarAssemblyTaskBase< Job_, DataType_ >::assemble(), FEAT::Assembly::BurgersCarreauBlockedAssemblyTaskBase< Job_, DataType_, block_size_ >::assemble(), FEAT::Assembly::BurgersCarreauScalarAssemblyTaskBase< Job_, DataType_ >::assemble(), FEAT::Assembly::TraceAssemblyJumpMatrixTaskCRTP1< Derived_, Matrix_, Space_, trafo_config_, facet_trafo_config_, space_config_ >::assemble(), FEAT::Assembly::GradPresDivVeloAssembler::assemble(), FEAT::Assembly::GradOperatorAssembler::assemble(), FEAT::Assembly::BurgersAssembler< DataType_, IndexType_, dim_ >::assemble_matrix(), FEAT::Assembly::OldroydAssembler::assemble_matrix(), FEAT::Assembly::GridTransfer::assemble_prolongation(), FEAT::Assembly::SpaceTransfer::assemble_transfer(), FEAT::Assembly::GridTransfer::assemble_truncation(), FEAT::Assembly::BurgersAssemblerCarreau< DataType_, IndexType_, dim_ >::assemble_vector(), FEAT::Assembly::VelocityAnalyser::compute(), FEAT::Meshopt::MeshConcentrationFunction< ElementalFunction_, Trafo_, RefCellTrafo_ >::compute_grad_h(), FEAT::Assembly::DiscreteEvaluator::eval_fe_gradient(), FEAT::Assembly::MatrixDiscreteEvalData< DT_, dim_i_, dim_j_ >::mean_value(), FEAT::Assembly::MatrixDiscreteEvalData< DT_, dim_i_, dim_j_ >::mean_value_dist(), FEAT::Space::Argyris::Evaluator< Space_, TrafoEvaluator_, SpaceEvalTraits_, Shape::Simplex< 2 > >::prepare(), FEAT::Assembly::BurgersAssemblyTaskBase< Job_, DataType_ >::prepare_point(), FEAT::Assembly::BurgersCarreauAssemblyTaskBase< Job_, DataType_ >::prepare_point(), FEAT::Assembly::GridTransfer::prolongate_vector(), and FEAT::Assembly::SpaceTransfer::transfer_vector().

◆ norm_frobenius()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE DataType FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::norm_frobenius ( ) const
inline

◆ norm_frobenius_sqr()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE DataType FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::norm_frobenius_sqr ( ) const
inline

Returns the Frobenius norm squared of the matrix.

This function computes and returns

\[ \sum_{i=0}^{m-1}\sum_{j=0}^{n-1} (A_{ij})^2\]

Returns
The Frobenius norm of the matrix.

Definition at line 1642 of file tiny_algebra.hpp.

References FEAT::Math::sqr().

◆ norm_hessian_sqr()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE DataType FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::norm_hessian_sqr ( ) const
inline

Returns the Hessian norm square.

This function computes and returns

\[ \sum_{i=0}^{m-1}\sum_{j=0}^{n-1} K_{ij}\cdot (A_{ij})^2 \]

where K_ij is 1 for i=j and 1/2 otherwise.

Note
This function is used for the computation of the H^2 semi-norm of a function.
Returns
The Hessian norm square of the matrix.

Definition at line 1595 of file tiny_algebra.hpp.

References FEAT::Math::sqr().

Referenced by FEAT::Assembly::FunctionIntegralInfo< DataType_, ValueType_, GradientType_, HessianType_ >::add_hess().

◆ norm_sub_id_frobenius()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE DataType FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::norm_sub_id_frobenius ( ) const
inline

Returns the Frobenius norm of the difference of this matrix and the identity matrix.

Returns
The Frobenius norm of the difference of this matrix and the identity matrix.

Definition at line 1664 of file tiny_algebra.hpp.

References FEAT::Math::sqr(), and FEAT::Math::sqrt().

Referenced by FEAT::Geometry::Atlas::Extrude< Mesh_, SubChart_ >::write().

◆ null()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
static CUDA_HOST_DEVICE Matrix FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::null ( )
inlinestatic

Returns a null-matrix.

Definition at line 2303 of file tiny_algebra.hpp.

◆ operator()() [1/2]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE T_ & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator() ( int  i,
int  j 
)
inline

Access operator.

Parameters
[in]i,jThe indices of the matrix entry that is to be returned.
Returns
A (const) reference to the matrix entry at position (i,j).

Definition at line 1463 of file tiny_algebra.hpp.

References ASSERTM.

◆ operator()() [2/2]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE const T_ & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator() ( int  i,
int  j 
) const
inline

Access operator.

Parameters
[in]i,jThe indices of the matrix entry that is to be returned.
Returns
A (const) reference to the matrix entry at position (i,j).

Definition at line 1471 of file tiny_algebra.hpp.

References ASSERTM.

◆ operator*=()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator*= ( DataType  alpha)
inline

scalar-right-multiply-by operator

Definition at line 1501 of file tiny_algebra.hpp.

◆ operator+=()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator+= ( const Matrix< T_, m_, n_, sma_, sna_ > &  a)
inline

matrix component-wise addition operator

Definition at line 1512 of file tiny_algebra.hpp.

References FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::v.

◆ operator-=()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator-= ( const Matrix< T_, m_, n_, sma_, sna_ > &  a)
inline

matrix component-wise subtraction operator

Definition at line 1523 of file tiny_algebra.hpp.

References FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::v.

◆ operator=() [1/4]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator= ( const Matrix< T_, m_, n_, sma_, sna_ > &  a)
inline

assignment operator

Definition at line 1394 of file tiny_algebra.hpp.

References FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::v.

◆ operator=() [2/4]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<typename Tx_ >
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator= ( const std::initializer_list< std::initializer_list< Tx_ > > &  x)
inline

Initializer list assignment operator.

m = {{0.0, 1.0}, {2.0, 3.0}};
Parameters
[in]xThe initializer list whose elements are to be assigned.

Definition at line 1437 of file tiny_algebra.hpp.

References XASSERTM.

◆ operator=() [3/4]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<typename Tx_ >
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator= ( const std::initializer_list< Tx_ > &  x)
inline

Initializer list assignment operator.

Tiny::Vector<double, 2> v{1.0, 2.0}, w{3.0, 4.0};
m = {v, w};
Parameters
[in]xThe initializer list whose elements are to be assigned.

Definition at line 1416 of file tiny_algebra.hpp.

References XASSERTM.

◆ operator=() [4/4]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator= ( DataType  value)
inline

value-assignment operator

Definition at line 1383 of file tiny_algebra.hpp.

References FEAT::value.

◆ operator[]() [1/2]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE RowType & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator[] ( int  i)
inline

Row-Access operator.

Parameters
[in]iThe index of the row that is to be returned.
Returns
A (const) reference to the i-th row of the matrix.S

Definition at line 1487 of file tiny_algebra.hpp.

References ASSERTM.

◆ operator[]() [2/2]

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE const RowType & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator[] ( int  i) const
inline

Row-Access operator.

Parameters
[in]iThe index of the row that is to be returned.
Returns
A (const) reference to the i-th row of the matrix.S

Definition at line 1494 of file tiny_algebra.hpp.

References ASSERTM.

◆ scalar_product()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int snx_, int sny_>
CUDA_HOST_DEVICE DataType FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::scalar_product ( const Vector< T_, m_, snx_ > &  x,
const Vector< T_, n_, sny_ > &  y 
) const
inline

Computes the scalar product of two vectors with this matrix.

This function returns

\[ x^\top\cdot A\cdot y = \sum_{i=0}^{m-1}\sum_{j=0}^{n-1} x_i\cdot A_{ij}\cdot y_j\]

Parameters
[in]xThe left muliplicant vector of size m_.
[in]yThe right multiplicand vector of size n_.
Returns
The scalar product of x and y with this matrix.

Definition at line 1881 of file tiny_algebra.hpp.

References FEAT::Tiny::dot().

Referenced by FEAT::Assembly::Common::LaplaceBeltramiOperator::Evaluator< AsmTraits_ >::eval().

◆ set_cofactor()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_cofactor ( const Matrix< T_, m_, n_, sma_, sna_ > &  a)
inline

Sets this matrix to the cofactor matrix of another matrix.

\( \mathrm{Cof}(A) \) is the cofactor matrix of \( A \). If \(A \in \mathbb{R}^{n \times n}\), define \(A^{(i,j)} \in \mathbb{R}^{n-1 \times n-1}\) as the matrix obtained by deleting the \( i \)th column and \( j \)th row of \( A \). Then

\[ \mathrm{Cof}(A)_{i,j} = (-1)^{i+j} \det(A^{(i,j)}) \]

and if \( A \in \mathrm{GL}_n\), \( \mathrm{Cof}(A) = \det(A) A^{-T} \).

Warning
This function only works for m_ = n_ and will intentionally fail to compile in any other case.
Parameters
[in]aThe matrix whose cofactor matrix is to be stored in this matrix.
Returns
*this

Definition at line 1800 of file tiny_algebra.hpp.

References ASSERTM.

◆ set_double_mat_mult()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int k_, int l_, int sma_, int sna_, int smb_, int snb_, int smd_, int snd_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_double_mat_mult ( const Matrix< T_, k_, l_, sma_, sna_ > &  a,
const Matrix< T_, k_, m_, smb_, snb_ > &  b,
const Matrix< T_, l_, n_, smd_, snd_ > &  d,
T_  alpha = T_(1) 
)
inline

Sets this matrix to the algebraic matrix double-product of three other matrices.

Let C denote this m-by-n matrix, B the left k-by-m input matrix, D the right l-by-n input matrix and A the inner k-by-l input matrix, then this operation computes:

\[ C \leftarrow B^\top\cdot A\cdot D\]

Parameters
[in]aThe inner k-by-l multiplicand matrix.
[in]bThe left k-by-m multiplicand matrix.
[in]dThe right l-by-n multiplicand matrix.
[in]alphaA scaling factor for the product.
Returns
*this

Definition at line 2136 of file tiny_algebra.hpp.

References ASSERTM.

◆ set_gram()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int l_, int sla_, int sna_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_gram ( const Matrix< T_, l_, n_, sla_, sna_ > &  a)
inline

Sets this matrix to the Gram matrix of another matrix.

Let C denote this n-by-n matrix, and let A denote the l-by-n input matrix, then this function computes:

\[ C\leftarrow A^\top\cdot A \]

Parameters
[in]aThe matrix whose Gram matrix is to be stored in this matrix.
Returns
*this

Definition at line 1845 of file tiny_algebra.hpp.

References FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::v.

◆ set_identity()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_identity ( )
inline

Sets this matrix to the identity matrix.

Returns
*this

Definition at line 2227 of file tiny_algebra.hpp.

Referenced by FEAT::Geometry::Intern::AdaptiveMeshStorage< MeshShape_, TemplateSet_, VertexType_ >::_aux_rot_mat().

◆ set_inverse()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_inverse ( const Matrix< T_, m_, n_, sma_, sna_ > &  a)
inline

◆ set_mat_mat_mult()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int la_, int lb_, int sma_, int sna_, int smb_, int snb_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_mat_mat_mult ( const Matrix< T_, m_, la_, sma_, sna_ > &  a,
const Matrix< T_, lb_, n_, smb_, snb_ > &  b 
)
inline

Sets this matrix to the algebraic matrix-product of two other matrices.

Let C denote this matrix, and let A denote the left m-by-l matrix and B the right l-by-n matrix, then this function computes:

\[ C\leftarrow A\cdot B \]

Parameters
[in]aThe left m-by-l multiplicand matrix.
[in]bThe right l-by-n multiplicand matrix.
Returns
*this

Definition at line 2050 of file tiny_algebra.hpp.

References ASSERTM.

Referenced by FEAT::LAFEM::SparseMatrixBCSR< DT_, IT_, BlockHeight_, BlockWidth_ >::add_double_mat_product(), FEAT::Assembly::GridTransfer::assemble_prolongation(), FEAT::Assembly::SpaceTransfer::assemble_transfer(), FEAT::Assembly::GridTransfer::assemble_truncation(), FEAT::Tiny::operator*(), FEAT::Assembly::GridTransfer::prolongate_vector(), and FEAT::Assembly::SpaceTransfer::transfer_vector().

◆ set_outer_product()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int snx_, int sny_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_outer_product ( const Vector< T_, m_, snx_ > &  x,
const Vector< T_, n_, sny_ > &  y 
)
inline

Sets this matrix to the outer product of two vectors.

This function performs:

\[ a_{ij} \leftarrow x_i y_j \]

Parameters
[in]xThe left multiplicand vector of size m_.
[in]yThe right multiplicand vector of size n_.
Returns
*this

Definition at line 1939 of file tiny_algebra.hpp.

Referenced by FEAT::Assembly::Common::DuDvOperatorBlocked< dimension_ >::Evaluator< AsmTraits_ >::eval().

◆ set_rotation_2d()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_rotation_2d ( T_  angle)
inline

◆ set_rotation_3d()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_rotation_3d ( T_  yaw,
T_  pitch,
T_  roll 
)
inline

◆ set_transpose()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int sma_, int sna_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_transpose ( const Matrix< T_, n_, m_, sma_, sna_ > &  a)
inline

◆ set_vec_tensor_mult()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
template<int l_, int snv_, int slt_, int smt_, int snt_>
CUDA_HOST_DEVICE Matrix & FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_vec_tensor_mult ( const Vector< T_, l_, snv_ > &  x,
const Tensor3< T_, l_, m_, n_, slt_, smt_, snt_ > &  t,
DataType  alpha = DataType(1) 
)
inline

Sets this matrix to the result of a vector-tensor left-product.

Let A denote this m-by-n matrix, v the l-size input vector and T the l-by-m-by-b input tensor, then this operation computes:

\[ \forall i\in\{0,...,m-1\},j\in\{0,...,n-1\}:~ A_{ij} \leftarrow \alpha \sum_{k=0}^{l-1} v_k\cdot T_{kij}\]

Note
This function is used for the computation of second-order derivatives by the chain rule.
Parameters
[in]xThe l-size vector that serves as a left multiplicand.
[in]tThe l-by-m-by-n tensor that serves as a right multiplicand.
[in]alphaA scaling factor for the product.
Returns
*this

Definition at line 2213 of file tiny_algebra.hpp.

◆ trace()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE DataType FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::trace ( ) const
inline

Returns the trace of the matrix.

This function computes and returns

\[ \sum_{i=0}^{\min(m,n)} A_{ii}\]

i.e. the sum of all main diagonal elements.

Returns
The trace of the matrix.

Definition at line 1694 of file tiny_algebra.hpp.

References FEAT::Math::min().

Referenced by FEAT::Assembly::FunctionIntegralInfo< DataType_, ValueType_, GradientType_, HessianType_ >::add_grad(), and FEAT::Assembly::VelocityAnalyser::compute().

◆ vol()

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST_DEVICE DataType FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::vol ( ) const
inline

Returns the volume of the matrix.

The volume of a matrix A is defined as:

\[ \textnormal{vol}(A) := \sqrt{\textnormal{det}(A^\top\cdot A)} \]

Note
For m_ = n_, the volume of the matrix equals the absolute of its determinant.
For m_ < n_, the volume of the matrix is always zero.
Returns
The volume of the matrix.

Definition at line 1732 of file tiny_algebra.hpp.

Friends And Related Function Documentation

◆ operator<<

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
CUDA_HOST friend std::ostream & operator<< ( std::ostream &  lhs,
const Matrix< T_, m_, n_, sm_, sn_ > &  A 
)
friend

Tiny::Matrix streaming operator.

Parameters
[in]lhsThe target stream.
[in]AThe matrix to be streamed.

Definition at line 2314 of file tiny_algebra.hpp.

Member Data Documentation

◆ m

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
constexpr int FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::m = m_
staticconstexpr

the row count of the matrix

Definition at line 1295 of file tiny_algebra.hpp.

Referenced by FEAT::Geometry::Atlas::SurfaceMesh< Mesh_ >::get_normal_on_tria().

◆ n

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
constexpr int FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::n = n_
staticconstexpr

the column count of the matrix

Definition at line 1297 of file tiny_algebra.hpp.

Referenced by FEAT::Geometry::Atlas::SurfaceMesh< Mesh_ >::get_normal_on_tria().

◆ sm

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
constexpr int FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::sm = sm_
staticconstexpr

the row stride of the matrix

Definition at line 1299 of file tiny_algebra.hpp.

◆ sn

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
constexpr int FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::sn = sn_
staticconstexpr

◆ v

template<typename T_ , int m_, int n_, int sm_ = m_, int sn_ = n_>
RowType FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::v[sm_]

actual matrix data; that's an array of vectors

Definition at line 1311 of file tiny_algebra.hpp.

Referenced by FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::Matrix(), FEAT::Tiny::Vector< T_, n_, s_ >::add_mat_vec_mult(), FEAT::Tiny::Vector< T_, n_, s_ >::add_mat_vec_mult_n(), FEAT::Tiny::Vector< T_, n_, s_ >::add_vec_mat_mult(), FEAT::Tiny::Vector< T_, n_, s_ >::add_vec_mat_mult_n(), FEAT::Assembly::GridTransfer::assemble_prolongation(), FEAT::Assembly::SpaceTransfer::assemble_transfer(), FEAT::Assembly::GridTransfer::assemble_truncation(), FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::axpy(), FEAT::Tiny::axpy(), FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::convert(), FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::copy(), FEAT::Tiny::Tensor3< T_, l_, m_, n_, sl_, sm_, sn_ >::copy(), FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::copy_n(), FEAT::Tiny::Tensor3< T_, l_, m_, n_, sl_, sm_, sn_ >::copy_n(), FEAT::Tiny::dot(), FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator+=(), FEAT::Tiny::Tensor3< T_, l_, m_, n_, sl_, sm_, sn_ >::operator+=(), FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator-=(), FEAT::Tiny::Tensor3< T_, l_, m_, n_, sl_, sm_, sn_ >::operator-=(), FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::operator=(), FEAT::Tiny::Tensor3< T_, l_, m_, n_, sl_, sm_, sn_ >::operator=(), FEAT::Assembly::GridTransfer::prolongate_vector(), FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_gram(), FEAT::Tiny::Vector< T_, n_, s_ >::set_mat_vec_mult(), FEAT::Tiny::Vector< T_, n_, s_ >::set_mat_vec_mult_n(), FEAT::Tiny::Matrix< T_, m_, n_, sm_, sn_ >::set_transpose(), FEAT::Tiny::Vector< T_, n_, s_ >::set_vec_mat_mult(), FEAT::Tiny::Vector< T_, n_, s_ >::set_vec_mat_mult_n(), FEAT::Assembly::TraceAssemblyStokesBodyForceAssemblyJob< VectorVelo_, VectorPres_, SpaceVelo_, SpacePres_ >::sync(), and FEAT::Assembly::SpaceTransfer::transfer_vector().


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