CubbyFlow::Matrix< T, M, N > Class Template Referencefinal

Static-sized M x N matrix class. More...

#include <Core/Matrix/Matrix.h>

Inheritance diagram for CubbyFlow::Matrix< T, M, N >:
CubbyFlow::MatrixExpression< T, Matrix< T, M, N > >

Public Types

using ContainerType = std::array< T, M *N >
 
using Iterator = typename ContainerType::iterator
 
using ConstIterator = typename ContainerType::const_iterator
 

Public Member Functions

 Matrix ()
 
template<typename... Params>
 Matrix (Params... params)
 Constructs matrix instance with parameters. More...
 
 Matrix (const std::initializer_list< std::initializer_list< T >> &list)
 Constructs a matrix with given initializer list list. More...
 
template<typename E >
 Matrix (const MatrixExpression< T, E > &other)
 Constructs a matrix with expression template. More...
 
 Matrix (const Matrix &other)
 Copy constructor. More...
 
void Resize (size_t m, size_t n, const T &s=T(0))
 Resizes to m x n matrix with initial value s. More...
 
void Set (const T &s)
 Sets whole matrix with input scalar. More...
 
void Set (const std::initializer_list< std::initializer_list< T >> &list)
 Sets a matrix with given initializer list list. More...
 
template<typename E >
void Set (const MatrixExpression< T, E > &other)
 Copies from input matrix expression. More...
 
void SetDiagonal (const T &s)
 Sets diagonal elements with input scalar. More...
 
void SetOffDiagonal (const T &s)
 Sets off-diagonal elements with input scalar. More...
 
template<typename E >
void SetRow (size_t i, const VectorExpression< T, E > &row)
 Sets i-th row with input vector. More...
 
template<typename E >
void SetColumn (size_t j, const VectorExpression< T, E > &col)
 Sets j-th column with input vector. More...
 
template<typename E >
bool IsEqual (const MatrixExpression< T, E > &other) const
 
template<typename E >
bool IsSimilar (const MatrixExpression< T, E > &other, double tol=std::numeric_limits< double >::epsilon()) const
 
constexpr bool IsSquare () const
 Returns true if this matrix is a square matrix. More...
 
constexpr Size2 size () const
 Returns the size of this matrix. More...
 
constexpr size_t Rows () const
 Returns number of rows of this matrix. More...
 
constexpr size_t Cols () const
 Returns number of columns of this matrix. More...
 
T * data ()
 Returns data pointer of this matrix. More...
 
const T * data () const
 Returns constant pointer of this matrix. More...
 
Iterator begin ()
 Returns the begin iterator of the matrix. More...
 
ConstIterator begin () const
 Returns the begin const iterator of the matrix. More...
 
Iterator end ()
 Returns the end iterator of the matrix. More...
 
ConstIterator end () const
 Returns the end const iterator of the matrix. More...
 
MatrixScalarAdd< T, MatrixAdd (const T &s) const
 Returns this matrix + input scalar. More...
 
template<typename E >
MatrixAdd< T, Matrix, E > Add (const E &m) const
 Returns this matrix + input matrix (element-wise). More...
 
MatrixScalarSub< T, MatrixSub (const T &s) const
 Returns this matrix - input scalar. More...
 
template<typename E >
MatrixSub< T, Matrix, E > Sub (const E &m) const
 Returns this matrix - input matrix (element-wise). More...
 
MatrixScalarMul< T, MatrixMul (const T &s) const
 Returns this matrix * input scalar. More...
 
template<typename VE >
MatrixVectorMul< T, Matrix, VE > Mul (const VectorExpression< T, VE > &v) const
 Returns this matrix * input vector. More...
 
template<size_t L>
MatrixMul< T, Matrix, Matrix< T, N, L > > Mul (const Matrix< T, N, L > &m) const
 Returns this matrix * input matrix. More...
 
MatrixScalarDiv< T, MatrixDiv (const T &s) const
 Returns this matrix / input scalar. More...
 
MatrixScalarAdd< T, MatrixRAdd (const T &s) const
 Returns input scalar + this matrix. More...
 
template<typename E >
MatrixAdd< T, Matrix, E > RAdd (const E &m) const
 Returns input matrix + this matrix (element-wise). More...
 
MatrixScalarRSub< T, MatrixRSub (const T &s) const
 Returns input scalar - this matrix. More...
 
template<typename E >
MatrixSub< T, Matrix, E > RSub (const E &m) const
 Returns input matrix - this matrix (element-wise). More...
 
MatrixScalarMul< T, MatrixRMul (const T &s) const
 Returns input scalar * this matrix. More...
 
template<size_t L>
MatrixMul< T, Matrix< T, N, L >, MatrixRMul (const Matrix< T, N, L > &m) const
 Returns input matrix * this matrix. More...
 
MatrixScalarRDiv< T, MatrixRDiv (const T &s) const
 Returns input matrix / this scalar. More...
 
void IAdd (const T &s)
 Adds input scalar to this matrix. More...
 
template<typename E >
void IAdd (const E &m)
 Adds input matrix to this matrix (element-wise). More...
 
void ISub (const T &s)
 Subtracts input scalar from this matrix. More...
 
template<typename E >
void ISub (const E &m)
 Subtracts input matrix from this matrix (element-wise). More...
 
void IMul (const T &s)
 Multiplies input scalar to this matrix. More...
 
template<typename E >
void IMul (const E &m)
 Multiplies input matrix to this matrix. More...
 
void IDiv (const T &s)
 Divides this matrix with input scalar. More...
 
void Transpose ()
 Transposes this matrix. More...
 
void Invert ()
 Inverts this matrix. More...
 
Sum () const
 Returns sum of all elements. More...
 
Avg () const
 Returns average of all elements. More...
 
Min () const
 Returns minimum among all elements. More...
 
Max () const
 Returns maximum among all elements. More...
 
AbsMin () const
 Returns absolute minimum among all elements. More...
 
AbsMax () const
 Returns absolute maximum among all elements. More...
 
Trace () const
 
Determinant () const
 Returns determinant of this matrix. More...
 
MatrixDiagonal< T, MatrixDiagonal () const
 Returns diagonal part of this matrix. More...
 
MatrixDiagonal< T, MatrixOffDiagonal () const
 Returns off-diagonal part of this matrix. More...
 
MatrixTriangular< T, MatrixStrictLowerTri () const
 Returns strictly lower triangle part of this matrix. More...
 
MatrixTriangular< T, MatrixStrictUpperTri () const
 Returns strictly upper triangle part of this matrix. More...
 
MatrixTriangular< T, MatrixLowerTri () const
 Returns lower triangle part of this matrix (including the diagonal). More...
 
MatrixTriangular< T, MatrixUpperTri () const
 Returns upper triangle part of this matrix (including the diagonal). More...
 
Matrix< T, N, M > Transposed () const
 Returns transposed matrix. More...
 
Matrix Inverse () const
 Returns inverse matrix. More...
 
template<typename U >
MatrixTypeCast< U, Matrix, T > CastTo () const
 
template<typename E >
Matrixoperator= (const E &m)
 Assigns input matrix. More...
 
Matrixoperator= (const Matrix &other)
 Copies to this matrix. More...
 
Matrixoperator+= (const T &s)
 Addition assignment with input scalar. More...
 
template<typename E >
Matrixoperator+= (const E &m)
 Addition assignment with input matrix (element-wise). More...
 
Matrixoperator-= (const T &s)
 Subtraction assignment with input scalar. More...
 
template<typename E >
Matrixoperator-= (const E &m)
 Subtraction assignment with input matrix (element-wise). More...
 
Matrixoperator*= (const T &s)
 Multiplication assignment with input scalar. More...
 
template<typename E >
Matrixoperator*= (const E &m)
 Multiplication assignment with input matrix. More...
 
Matrixoperator/= (const T &s)
 Division assignment with input scalar. More...
 
T & operator[] (size_t i)
 Returns reference of i-th element. More...
 
const T & operator[] (size_t i) const
 Returns constant reference of i-th element. More...
 
T & operator() (size_t i, size_t j)
 Returns reference of (i,j) element. More...
 
const T & operator() (size_t i, size_t j) const
 Returns constant reference of (i,j) element. More...
 
template<typename E >
bool operator== (const MatrixExpression< T, E > &m) const
 Returns true if is equal to m. More...
 
template<typename E >
bool operator!= (const MatrixExpression< T, E > &m) const
 Returns true if is not equal to m. More...
 
template<typename Callback >
void ForEach (Callback func) const
 Iterates the matrix and invoke given func for each index. More...
 
template<typename Callback >
void ForEachIndex (Callback func) const
 Iterates the matrix and invoke given func for each index. More...
 
template<typename E >
MatrixAdd< T, Matrix< T, M, N >, E > Add (const E &m) const
 
template<typename E >
MatrixSub< T, Matrix< T, M, N >, E > Sub (const E &m) const
 
template<typename VE>
MatrixVectorMul< T, Matrix< T, M, N >, VE > Mul (const VectorExpression< T, VE > &v) const
 
template<size_t L>
MatrixMul< T, Matrix< T, M, N >, Matrix< T, N, L > > Mul (const Matrix< T, N, L > &m) const
 
template<typename E >
MatrixAdd< T, Matrix< T, M, N >, E > RAdd (const E &m) const
 
template<typename E >
MatrixSub< T, Matrix< T, M, N >, E > RSub (const E &m) const
 
template<size_t L>
MatrixMul< T, Matrix< T, N, L >, Matrix< T, M, N > > RMul (const Matrix< T, N, L > &m) const
 
template<typename U >
MatrixTypeCast< U, Matrix< T, M, N >, T > CastTo () const
 
template<typename E >
Matrix< T, M, N > & operator= (const E &m)
 
template<typename E >
Matrix< T, M, N > & operator+= (const E &m)
 
template<typename E >
Matrix< T, M, N > & operator-= (const E &m)
 
template<typename E >
Matrix< T, M, N > & operator*= (const E &m)
 
- Public Member Functions inherited from CubbyFlow::MatrixExpression< T, Matrix< T, M, N > >
Size2 size () const
 Size of the matrix. More...
 
size_t Rows () const
 Number of rows. More...
 
size_t Cols () const
 Number of columns. More...
 
const Matrix< T, M, N > & operator() () const
 Returns actual implementation (the subclass). More...
 

Static Public Member Functions

static MatrixConstant< T > MakeZero ()
 Makes a M x N matrix with zeros. More...
 
static MatrixIdentity< T > MakeIdentity ()
 Makes a M x N matrix with all diagonal elements to 1, and other elements to 0. More...
 

Detailed Description

template<typename T, size_t M, size_t N>
class CubbyFlow::Matrix< T, M, N >

Static-sized M x N matrix class.

This class defines M x N row-major matrix data where its size is determined statically at compile time.

Template Parameters
T- Real number type.
M- Number of rows.
N- Number of columns.

Member Typedef Documentation

◆ ConstIterator

template<typename T, size_t M, size_t N>
using CubbyFlow::Matrix< T, M, N >::ConstIterator = typename ContainerType::const_iterator

◆ ContainerType

template<typename T, size_t M, size_t N>
using CubbyFlow::Matrix< T, M, N >::ContainerType = std::array<T, M * N>

◆ Iterator

template<typename T, size_t M, size_t N>
using CubbyFlow::Matrix< T, M, N >::Iterator = typename ContainerType::iterator

Constructor & Destructor Documentation

◆ Matrix() [1/5]

template<typename T , size_t M, size_t N>
CubbyFlow::Matrix< T, M, N >::Matrix ( )

Default constructor.

Warning
This constructor will create zero matrix.

◆ Matrix() [2/5]

template<typename T , size_t M, size_t N>
template<typename... Params>
CubbyFlow::Matrix< T, M, N >::Matrix ( Params...  params)
explicit

Constructs matrix instance with parameters.

◆ Matrix() [3/5]

template<typename T , size_t M, size_t N>
CubbyFlow::Matrix< T, M, N >::Matrix ( const std::initializer_list< std::initializer_list< T >> &  list)

Constructs a matrix with given initializer list list.

This constructor will build a matrix with given initializer list list such as

Matrix<float, 3, 4> mat =
{
{1.f, 2.f, 4.f, 3.f},
{9.f, 3.f, 5.f, 1.f},
{4.f, 8.f, 1.f, 5.f}
};
Parameters
listInitializer list that should be copy to the new matrix.

◆ Matrix() [4/5]

template<typename T , size_t M, size_t N>
template<typename E>
CubbyFlow::Matrix< T, M, N >::Matrix ( const MatrixExpression< T, E > &  other)

Constructs a matrix with expression template.

◆ Matrix() [5/5]

template<typename T , size_t M, size_t N>
CubbyFlow::Matrix< T, M, N >::Matrix ( const Matrix< T, M, N > &  other)

Copy constructor.

Member Function Documentation

◆ AbsMax()

template<typename T , size_t M, size_t N>
T CubbyFlow::Matrix< T, M, N >::AbsMax ( ) const

Returns absolute maximum among all elements.

◆ AbsMin()

template<typename T , size_t M, size_t N>
T CubbyFlow::Matrix< T, M, N >::AbsMin ( ) const

Returns absolute minimum among all elements.

◆ Add() [1/3]

template<typename T , size_t M, size_t N>
MatrixScalarAdd< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::Add ( const T &  s) const

Returns this matrix + input scalar.

◆ Add() [2/3]

template<typename T, size_t M, size_t N>
template<typename E >
MatrixAdd<T, Matrix, E> CubbyFlow::Matrix< T, M, N >::Add ( const E &  m) const

Returns this matrix + input matrix (element-wise).

◆ Add() [3/3]

template<typename T, size_t M, size_t N>
template<typename E >
MatrixAdd<T, Matrix<T, M, N>, E> CubbyFlow::Matrix< T, M, N >::Add ( const E &  m) const

◆ Avg()

template<typename T , size_t M, size_t N>
T CubbyFlow::Matrix< T, M, N >::Avg ( ) const

Returns average of all elements.

◆ begin() [1/2]

template<typename T , size_t M, size_t N>
Matrix< T, M, N >::Iterator CubbyFlow::Matrix< T, M, N >::begin ( )

Returns the begin iterator of the matrix.

◆ begin() [2/2]

template<typename T , size_t M, size_t N>
Matrix< T, M, N >::ConstIterator CubbyFlow::Matrix< T, M, N >::begin ( ) const

Returns the begin const iterator of the matrix.

◆ CastTo() [1/2]

template<typename T, size_t M, size_t N>
template<typename U >
MatrixTypeCast<U, Matrix, T> CubbyFlow::Matrix< T, M, N >::CastTo ( ) const

◆ CastTo() [2/2]

template<typename T, size_t M, size_t N>
template<typename U >
MatrixTypeCast<U, Matrix<T, M, N>, T> CubbyFlow::Matrix< T, M, N >::CastTo ( ) const

◆ Cols()

template<typename T , size_t M, size_t N>
constexpr size_t CubbyFlow::Matrix< T, M, N >::Cols ( ) const

Returns number of columns of this matrix.

◆ data() [1/2]

template<typename T , size_t M, size_t N>
T * CubbyFlow::Matrix< T, M, N >::data ( )

Returns data pointer of this matrix.

◆ data() [2/2]

template<typename T , size_t M, size_t N>
const T * CubbyFlow::Matrix< T, M, N >::data ( ) const

Returns constant pointer of this matrix.

◆ Determinant()

template<typename T , size_t M, size_t N>
T CubbyFlow::Matrix< T, M, N >::Determinant ( ) const

Returns determinant of this matrix.

◆ Diagonal()

template<typename T , size_t M, size_t N>
MatrixDiagonal< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::Diagonal ( ) const

Returns diagonal part of this matrix.

◆ Div()

template<typename T , size_t M, size_t N>
MatrixScalarDiv< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::Div ( const T &  s) const

Returns this matrix / input scalar.

◆ end() [1/2]

template<typename T , size_t M, size_t N>
Matrix< T, M, N >::Iterator CubbyFlow::Matrix< T, M, N >::end ( )

Returns the end iterator of the matrix.

◆ end() [2/2]

template<typename T , size_t M, size_t N>
Matrix< T, M, N >::ConstIterator CubbyFlow::Matrix< T, M, N >::end ( ) const

Returns the end const iterator of the matrix.

◆ ForEach()

template<typename T , size_t M, size_t N>
template<typename Callback >
void CubbyFlow::Matrix< T, M, N >::ForEach ( Callback  func) const

Iterates the matrix and invoke given func for each index.

This function iterates the matrix elements and invoke the callback function func. The callback function takes matrix's element as its input. The order of execution will be the same as the nested for-loop below:

MatrixMxN<double> mat(100, 200, 4.0);
for (size_t i = 0; i < mat.rows(); ++i)
{
for (size_t j = 0; j < mat.cols(); ++j)
{
func(mat(i, j));
}
}

Below is the sample usage:

MatrixMxN<double> mat(100, 200, 4.0);
mat.forEach([](double elem)
{
printf("%d\n", elem);
});

◆ ForEachIndex()

template<typename T , size_t M, size_t N>
template<typename Callback >
void CubbyFlow::Matrix< T, M, N >::ForEachIndex ( Callback  func) const

Iterates the matrix and invoke given func for each index.

This function iterates the matrix elements and invoke the callback function func. The callback function takes two parameters which are the (i, j) indices of the matrix. The order of execution will be the same as the nested for-loop below:

MatrixMxN<double> mat(100, 200, 4.0);
for (size_t i = 0; i < mat.rows(); ++i)
{
for (size_t j = 0; j < mat.cols(); ++j)
{
func(i, j);
}
}

Below is the sample usage:

MatrixMxN<double> mat(100, 200, 4.0);
mat.forEachIndex([&](size_t i, size_t j)
{
mat(i, j) = 4.0 * i + 7.0 * j + 1.5;
});

◆ IAdd() [1/2]

template<typename T , size_t M, size_t N>
void CubbyFlow::Matrix< T, M, N >::IAdd ( const T &  s)

Adds input scalar to this matrix.

◆ IAdd() [2/2]

template<typename T , size_t M, size_t N>
template<typename E >
void CubbyFlow::Matrix< T, M, N >::IAdd ( const E &  m)

Adds input matrix to this matrix (element-wise).

◆ IDiv()

template<typename T , size_t M, size_t N>
void CubbyFlow::Matrix< T, M, N >::IDiv ( const T &  s)

Divides this matrix with input scalar.

◆ IMul() [1/2]

template<typename T , size_t M, size_t N>
void CubbyFlow::Matrix< T, M, N >::IMul ( const T &  s)

Multiplies input scalar to this matrix.

◆ IMul() [2/2]

template<typename T , size_t M, size_t N>
template<typename E >
void CubbyFlow::Matrix< T, M, N >::IMul ( const E &  m)

Multiplies input matrix to this matrix.

◆ Inverse()

template<typename T , size_t M, size_t N>
Matrix< T, M, N > CubbyFlow::Matrix< T, M, N >::Inverse ( ) const

Returns inverse matrix.

◆ Invert()

template<typename T , size_t M, size_t N>
void CubbyFlow::Matrix< T, M, N >::Invert ( )

Inverts this matrix.

This function computes the inverse using Gaussian elimination method.

◆ IsEqual()

template<typename T , size_t M, size_t N>
template<typename E >
bool CubbyFlow::Matrix< T, M, N >::IsEqual ( const MatrixExpression< T, E > &  other) const

◆ IsSimilar()

template<typename T , size_t M, size_t N>
template<typename E >
bool CubbyFlow::Matrix< T, M, N >::IsSimilar ( const MatrixExpression< T, E > &  other,
double  tol = std::numeric_limits<double>::epsilon() 
) const

Returns true if this matrix is similar to the input matrix within the given tolerance.

◆ IsSquare()

template<typename T , size_t M, size_t N>
constexpr bool CubbyFlow::Matrix< T, M, N >::IsSquare ( ) const

Returns true if this matrix is a square matrix.

◆ ISub() [1/2]

template<typename T , size_t M, size_t N>
void CubbyFlow::Matrix< T, M, N >::ISub ( const T &  s)

Subtracts input scalar from this matrix.

◆ ISub() [2/2]

template<typename T , size_t M, size_t N>
template<typename E >
void CubbyFlow::Matrix< T, M, N >::ISub ( const E &  m)

Subtracts input matrix from this matrix (element-wise).

◆ LowerTri()

template<typename T , size_t M, size_t N>
MatrixTriangular< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::LowerTri ( ) const

Returns lower triangle part of this matrix (including the diagonal).

◆ MakeIdentity()

template<typename T , size_t M, size_t N>
MatrixIdentity< T > CubbyFlow::Matrix< T, M, N >::MakeIdentity ( )
static

Makes a M x N matrix with all diagonal elements to 1, and other elements to 0.

◆ MakeZero()

template<typename T , size_t M, size_t N>
MatrixConstant< T > CubbyFlow::Matrix< T, M, N >::MakeZero ( )
static

Makes a M x N matrix with zeros.

◆ Max()

template<typename T , size_t M, size_t N>
T CubbyFlow::Matrix< T, M, N >::Max ( ) const

Returns maximum among all elements.

◆ Min()

template<typename T , size_t M, size_t N>
T CubbyFlow::Matrix< T, M, N >::Min ( ) const

Returns minimum among all elements.

◆ Mul() [1/5]

template<typename T , size_t M, size_t N>
MatrixScalarMul< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::Mul ( const T &  s) const

Returns this matrix * input scalar.

◆ Mul() [2/5]

template<typename T, size_t M, size_t N>
template<typename VE >
MatrixVectorMul<T, Matrix, VE> CubbyFlow::Matrix< T, M, N >::Mul ( const VectorExpression< T, VE > &  v) const

Returns this matrix * input vector.

◆ Mul() [3/5]

template<typename T, size_t M, size_t N>
template<size_t L>
MatrixMul<T, Matrix, Matrix<T, N, L> > CubbyFlow::Matrix< T, M, N >::Mul ( const Matrix< T, N, L > &  m) const

Returns this matrix * input matrix.

◆ Mul() [4/5]

template<typename T, size_t M, size_t N>
template<typename VE>
MatrixVectorMul<T, Matrix<T, M, N>, VE> CubbyFlow::Matrix< T, M, N >::Mul ( const VectorExpression< T, VE > &  v) const

◆ Mul() [5/5]

template<typename T, size_t M, size_t N>
template<size_t L>
MatrixMul<T, Matrix<T, M, N>, Matrix<T, N, L> > CubbyFlow::Matrix< T, M, N >::Mul ( const Matrix< T, N, L > &  m) const

◆ OffDiagonal()

template<typename T , size_t M, size_t N>
MatrixDiagonal< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::OffDiagonal ( ) const

Returns off-diagonal part of this matrix.

◆ operator!=()

template<typename T , size_t M, size_t N>
template<typename E >
bool CubbyFlow::Matrix< T, M, N >::operator!= ( const MatrixExpression< T, E > &  m) const

Returns true if is not equal to m.

◆ operator()() [1/2]

template<typename T , size_t M, size_t N>
T & CubbyFlow::Matrix< T, M, N >::operator() ( size_t  i,
size_t  j 
)

Returns reference of (i,j) element.

◆ operator()() [2/2]

template<typename T , size_t M, size_t N>
const T & CubbyFlow::Matrix< T, M, N >::operator() ( size_t  i,
size_t  j 
) const

Returns constant reference of (i,j) element.

◆ operator*=() [1/3]

template<typename T , size_t M, size_t N>
Matrix< T, M, N > & CubbyFlow::Matrix< T, M, N >::operator*= ( const T &  s)

Multiplication assignment with input scalar.

◆ operator*=() [2/3]

template<typename T, size_t M, size_t N>
template<typename E >
Matrix& CubbyFlow::Matrix< T, M, N >::operator*= ( const E &  m)

Multiplication assignment with input matrix.

◆ operator*=() [3/3]

template<typename T, size_t M, size_t N>
template<typename E >
Matrix<T, M, N>& CubbyFlow::Matrix< T, M, N >::operator*= ( const E &  m)

◆ operator+=() [1/3]

template<typename T , size_t M, size_t N>
Matrix< T, M, N > & CubbyFlow::Matrix< T, M, N >::operator+= ( const T &  s)

Addition assignment with input scalar.

◆ operator+=() [2/3]

template<typename T, size_t M, size_t N>
template<typename E >
Matrix& CubbyFlow::Matrix< T, M, N >::operator+= ( const E &  m)

Addition assignment with input matrix (element-wise).

◆ operator+=() [3/3]

template<typename T, size_t M, size_t N>
template<typename E >
Matrix<T, M, N>& CubbyFlow::Matrix< T, M, N >::operator+= ( const E &  m)

◆ operator-=() [1/3]

template<typename T , size_t M, size_t N>
Matrix< T, M, N > & CubbyFlow::Matrix< T, M, N >::operator-= ( const T &  s)

Subtraction assignment with input scalar.

◆ operator-=() [2/3]

template<typename T, size_t M, size_t N>
template<typename E >
Matrix& CubbyFlow::Matrix< T, M, N >::operator-= ( const E &  m)

Subtraction assignment with input matrix (element-wise).

◆ operator-=() [3/3]

template<typename T, size_t M, size_t N>
template<typename E >
Matrix<T, M, N>& CubbyFlow::Matrix< T, M, N >::operator-= ( const E &  m)

◆ operator/=()

template<typename T , size_t M, size_t N>
Matrix< T, M, N > & CubbyFlow::Matrix< T, M, N >::operator/= ( const T &  s)

Division assignment with input scalar.

◆ operator=() [1/3]

template<typename T, size_t M, size_t N>
template<typename E >
Matrix& CubbyFlow::Matrix< T, M, N >::operator= ( const E &  m)

Assigns input matrix.

◆ operator=() [2/3]

template<typename T , size_t M, size_t N>
Matrix< T, M, N > & CubbyFlow::Matrix< T, M, N >::operator= ( const Matrix< T, M, N > &  other)

Copies to this matrix.

◆ operator=() [3/3]

template<typename T, size_t M, size_t N>
template<typename E >
Matrix<T, M, N>& CubbyFlow::Matrix< T, M, N >::operator= ( const E &  m)

◆ operator==()

template<typename T , size_t M, size_t N>
template<typename E >
bool CubbyFlow::Matrix< T, M, N >::operator== ( const MatrixExpression< T, E > &  m) const

Returns true if is equal to m.

◆ operator[]() [1/2]

template<typename T , size_t M, size_t N>
T & CubbyFlow::Matrix< T, M, N >::operator[] ( size_t  i)

Returns reference of i-th element.

◆ operator[]() [2/2]

template<typename T , size_t M, size_t N>
const T & CubbyFlow::Matrix< T, M, N >::operator[] ( size_t  i) const

Returns constant reference of i-th element.

◆ RAdd() [1/3]

template<typename T , size_t M, size_t N>
MatrixScalarAdd< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::RAdd ( const T &  s) const

Returns input scalar + this matrix.

◆ RAdd() [2/3]

template<typename T, size_t M, size_t N>
template<typename E >
MatrixAdd<T, Matrix, E> CubbyFlow::Matrix< T, M, N >::RAdd ( const E &  m) const

Returns input matrix + this matrix (element-wise).

◆ RAdd() [3/3]

template<typename T, size_t M, size_t N>
template<typename E >
MatrixAdd<T, Matrix<T, M, N>, E> CubbyFlow::Matrix< T, M, N >::RAdd ( const E &  m) const

◆ RDiv()

template<typename T , size_t M, size_t N>
MatrixScalarRDiv< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::RDiv ( const T &  s) const

Returns input matrix / this scalar.

◆ Resize()

template<typename T, size_t M, size_t N>
void CubbyFlow::Matrix< T, M, N >::Resize ( size_t  m,
size_t  n,
const T &  s = T(0) 
)

Resizes to m x n matrix with initial value s.

◆ RMul() [1/3]

template<typename T , size_t M, size_t N>
MatrixScalarMul< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::RMul ( const T &  s) const

Returns input scalar * this matrix.

◆ RMul() [2/3]

template<typename T, size_t M, size_t N>
template<size_t L>
MatrixMul<T, Matrix<T, N, L>, Matrix> CubbyFlow::Matrix< T, M, N >::RMul ( const Matrix< T, N, L > &  m) const

Returns input matrix * this matrix.

◆ RMul() [3/3]

template<typename T, size_t M, size_t N>
template<size_t L>
MatrixMul<T, Matrix<T, N, L>, Matrix<T, M, N> > CubbyFlow::Matrix< T, M, N >::RMul ( const Matrix< T, N, L > &  m) const

◆ Rows()

template<typename T , size_t M, size_t N>
constexpr size_t CubbyFlow::Matrix< T, M, N >::Rows ( ) const

Returns number of rows of this matrix.

◆ RSub() [1/3]

template<typename T , size_t M, size_t N>
MatrixScalarRSub< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::RSub ( const T &  s) const

Returns input scalar - this matrix.

◆ RSub() [2/3]

template<typename T, size_t M, size_t N>
template<typename E >
MatrixSub<T, Matrix, E> CubbyFlow::Matrix< T, M, N >::RSub ( const E &  m) const

Returns input matrix - this matrix (element-wise).

◆ RSub() [3/3]

template<typename T, size_t M, size_t N>
template<typename E >
MatrixSub<T, Matrix<T, M, N>, E> CubbyFlow::Matrix< T, M, N >::RSub ( const E &  m) const

◆ Set() [1/3]

template<typename T , size_t M, size_t N>
void CubbyFlow::Matrix< T, M, N >::Set ( const T &  s)

Sets whole matrix with input scalar.

◆ Set() [2/3]

template<typename T , size_t M, size_t N>
void CubbyFlow::Matrix< T, M, N >::Set ( const std::initializer_list< std::initializer_list< T >> &  list)

Sets a matrix with given initializer list list.

This function will fill the matrix with given initializer list list such as

Matrix<float, 3, 4> mat;
mat.set(
{
{1.f, 2.f, 4.f, 3.f},
{9.f, 3.f, 5.f, 1.f},
{4.f, 8.f, 1.f, 5.f}
});
Parameters
listInitializer list that should be copy to the new matrix.

◆ Set() [3/3]

template<typename T , size_t M, size_t N>
template<typename E >
void CubbyFlow::Matrix< T, M, N >::Set ( const MatrixExpression< T, E > &  other)

Copies from input matrix expression.

◆ SetColumn()

template<typename T , size_t M, size_t N>
template<typename E >
void CubbyFlow::Matrix< T, M, N >::SetColumn ( size_t  j,
const VectorExpression< T, E > &  col 
)

Sets j-th column with input vector.

◆ SetDiagonal()

template<typename T , size_t M, size_t N>
void CubbyFlow::Matrix< T, M, N >::SetDiagonal ( const T &  s)

Sets diagonal elements with input scalar.

◆ SetOffDiagonal()

template<typename T , size_t M, size_t N>
void CubbyFlow::Matrix< T, M, N >::SetOffDiagonal ( const T &  s)

Sets off-diagonal elements with input scalar.

◆ SetRow()

template<typename T , size_t M, size_t N>
template<typename E >
void CubbyFlow::Matrix< T, M, N >::SetRow ( size_t  i,
const VectorExpression< T, E > &  row 
)

Sets i-th row with input vector.

◆ size()

template<typename T , size_t M, size_t N>
constexpr Size2 CubbyFlow::Matrix< T, M, N >::size ( ) const

Returns the size of this matrix.

◆ StrictLowerTri()

template<typename T , size_t M, size_t N>
MatrixTriangular< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::StrictLowerTri ( ) const

Returns strictly lower triangle part of this matrix.

◆ StrictUpperTri()

template<typename T , size_t M, size_t N>
MatrixTriangular< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::StrictUpperTri ( ) const

Returns strictly upper triangle part of this matrix.

◆ Sub() [1/3]

template<typename T , size_t M, size_t N>
MatrixScalarSub< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::Sub ( const T &  s) const

Returns this matrix - input scalar.

◆ Sub() [2/3]

template<typename T, size_t M, size_t N>
template<typename E >
MatrixSub<T, Matrix, E> CubbyFlow::Matrix< T, M, N >::Sub ( const E &  m) const

Returns this matrix - input matrix (element-wise).

◆ Sub() [3/3]

template<typename T, size_t M, size_t N>
template<typename E >
MatrixSub<T, Matrix<T, M, N>, E> CubbyFlow::Matrix< T, M, N >::Sub ( const E &  m) const

◆ Sum()

template<typename T , size_t M, size_t N>
T CubbyFlow::Matrix< T, M, N >::Sum ( ) const

Returns sum of all elements.

◆ Trace()

template<typename T , size_t M, size_t N>
T CubbyFlow::Matrix< T, M, N >::Trace ( ) const

Returns sum of all diagonal elements.

Warning
Should be a square matrix.

◆ Transpose()

template<typename T , size_t M, size_t N>
void CubbyFlow::Matrix< T, M, N >::Transpose ( )

Transposes this matrix.

◆ Transposed()

template<typename T , size_t M, size_t N>
Matrix< T, N, M > CubbyFlow::Matrix< T, M, N >::Transposed ( ) const

Returns transposed matrix.

◆ UpperTri()

template<typename T , size_t M, size_t N>
MatrixTriangular< T, Matrix< T, M, N > > CubbyFlow::Matrix< T, M, N >::UpperTri ( ) const

Returns upper triangle part of this matrix (including the diagonal).


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