PTEMS  0.1.0-dev+git.81fd0e4
PolyTopic Element Method Solver
ptems::BasicMatrix< T, N, M > Class Template Reference

A class for representing a small NxM matrix (generally matrix of dimension of the domain) More...

#include <ptems/matrix.hpp>

Public Types

typedef MatrixVectorView< T, N, M, false, true > ColumnView
 A "view" object for accessing, and modifying, a matrix column. More...
 
typedef MatrixVectorView< T, N, M, true, true > ConstColumnView
 A "view" object for const access to a matrix column. More...
 
typedef MatrixVectorView< T, M, 1, false, false > RowView
 A "view" object for accessing, and modifying, a matrix row. More...
 
typedef MatrixVectorView< T, M, 1, true, false > ConstRowView
 A "view" object for const access to a matrix row. More...
 
using ConjugateType = BasicMatrix< typename std::conditional_t< is_complex_v< T >, T, std::complex< T > >, M, N >
 The type of the complex conjugate of the matrix. More...
 

Public Member Functions

constexpr BasicMatrix ()
 Constructs a matrix filled with zeros. More...
 
constexpr BasicMatrix (T value)
 Constructs a matrix filled with with the specified value. More...
 
template<typename V >
constexpr BasicMatrix (const BasicMatrix< V, N, M > &value)
 Constructs a matrix by explicitly casting from a compatible matrix type. More...
 
constexpr BasicMatrix (const BasicMatrix< T, N, M > &)=default
 Copy constructor. More...
 
constexpr BasicMatrix (BasicMatrix< T, N, M > &&)=default
 Move constructor. More...
 
template<typename V , std::size_t DIM, typename = std::enable_if_t<((DIM == N) && (M == 1)) || ((DIM == M) && (N == 1))>>
constexpr BasicMatrix (const BasicVector< V, DIM > &vec)
 Constructs a matrix representing a row/column vector from the specified vector. More...
 
template<typename... V, typename = std::enable_if_t<(sizeof...(V) == N) && (sizeof...(V) > 1)>>
constexpr BasicMatrix (const BasicVector< V, M > &... vec)
 Constructs a matrix by specifying each row as a vector. More...
 
template<typename... V, typename = std::enable_if_t<((sizeof...(V) == N*M) && ... && std::is_convertible_v<V,T>)>>
constexpr BasicMatrix (V... v)
 Construct a matrix by specifying all entries in Row-Major order. More...
 
template<typename... V, typename = std::enable_if_t<((sizeof...(V) == N*M) && ... && std::is_convertible_v<V,T>)>>
constexpr BasicMatrix (MatrixOrdering ordering, V... v)
 Construct a matrix by specifying all entries in specified ordering. More...
 
template<typename V >
constexpr BasicMatrix (const std::initializer_list< std::initializer_list< V >> &values)
 Construct a matrix by specifying all entries in Row-Major order via nested initialiser lists. More...
 
template<typename V >
constexpr BasicMatrix (MatrixOrdering ordering, const std::initializer_list< std::initializer_list< V >> &values)
 Construct a matrix by specifying all entries in specified order via nested initialiser lists. More...
 
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (M == 1)>>
constexpr operator BasicVector< T, D > ()
 Implicitly converted a matrix representing a column vector into a vector. More...
 
template<std::size_t D = std::max(N,M), typename = std::enable_if_t<((D == N) && (M == 1)) || ((D == M) && (N == 1))>>
constexpr BasicVector< T, D > ToVector ()
 Convert a matrix representing a column or row vector into a vector. More...
 
constexpr BasicMatrixoperator= (T rhs)
 Sets all entries in the matrix equal to the specified constant. More...
 
constexpr BasicMatrixoperator= (const BasicMatrix< T, N, M > &rhs)
 Sets this matrix equal to the specified matrix. More...
 
constexpr BasicMatrixoperator+= (T rhs)
 Adds a constant to every entry of the matrix. More...
 
template<typename U >
constexpr BasicMatrixoperator+= (const BasicMatrix< U, N, M > &rhs)
 Adds the specified matrix elementwise to this matrix. More...
 
constexpr BasicMatrixoperator-= (T rhs)
 Subtracts a constant from every entry of the matrix. More...
 
template<typename U >
constexpr BasicMatrixoperator-= (const BasicMatrix< U, N, M > &rhs)
 Subtracts the specified matrix elementwise to this matrix. More...
 
constexpr BasicMatrixoperator*= (T rhs)
 Multiplies every entry in this matrix by a constant. More...
 
template<typename U , std::size_t D, typename = std::enable_if_t<D == M>>
constexpr BasicMatrixoperator*= (const BasicMatrix< U, D, D > &rhs)
 Performs matrix-matrix multiplication and stores the result directly in this matrix. More...
 
constexpr BasicMatrixoperator/= (T rhs)
 Divides every entry in this matrix by a constant. More...
 
template<typename U >
constexpr BasicMatrixElementalMultiply (const BasicMatrix< U, N, M > &rhs)
 Multiplies every entry in this matrix by the corresponding entry in the passed matrix (elementwise multiplication) More...
 
template<typename U >
constexpr BasicMatrixElementalDivide (const BasicMatrix< U, N, M > &rhs)
 Divides every entry in this matrix by the corresponding entry in the passed matrix (elementwise division) More...
 
constexpr BasicMatrix operator- () const
 Gets a matrix containing the negation of this matrix. More...
 
constexpr T operator() (std::size_t i, std::size_t j) const
 Gets the value in the specified entry of the matrix. More...
 
constexpr T & operator() (std::size_t i, std::size_t j)
 Gets a mutable reference to the specified entry of the matrix. More...
 
constexpr ConstColumnView Column (std::size_t j) const
 Gets a const reference to a column of the matrix. More...
 
constexpr ColumnView Column (std::size_t j)
 Gets a mutable reference to a column of the matrix. More...
 
constexpr ConstRowView Row (std::size_t i) const
 Gets a const reference to a row of the matrix. More...
 
constexpr RowView Row (std::size_t i)
 Gets a mutable reference to a row of the matrix. More...
 
template<typename V = T, typename = std::enable_if_t<std::is_same_v<T,V>>>
BasicMatrixConjugateOverwrite ()
 Performs complex conjugate of a matrix "in-place" (overwrites the entries of this matrix) More...
 
ConjugateType Conjugate () const
 Computes the complex conjugate of a square matrix. More...
 
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr BasicMatrixTransposeOverwrite ()
 Transposes a square matrix "in-place" (overwrites the entries of this matrix) More...
 
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
BasicMatrixHermitianOverwrite ()
 Performs conjugate transpose of a square matrix "in-place" (overwrites the entries of this matrix) More...
 
constexpr BasicMatrix< T, M, N > Transpose () const
 Computes the transpose of a square matrix. More...
 
ConjugateType Hermitian () const
 Computes the conjugate transpose of a square matrix. More...
 
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr T Determinant () const
 Computes the determinant of a square matrix. More...
 
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr BasicMatrix< T, N, N > Inverse (double tolerance=0) const
 Computes the inverse of a square matrix. More...
 
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr BasicMatrix< T, N, N > InverseTranspose (double tolerance=0) const
 Computes the inverse of the transpose of a square matrix. More...
 
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr BasicMatrix< T, N, N > & InverseOverwrite (double tolerance=0)
 Computes the inverse of a square matrix "in-place" (overwrites the entries of this matrix) More...
 
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr BasicMatrix< T, N, N > & InverseTransposeOverwrite (double tolerance=0)
 Computes the inverse of the transpose of a square matrix "in-place" (overwrites the entries of this matrix) More...
 
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr T Trace () const
 Computes the trace of a square matrix. More...
 
template<typename U >
constexpr std::common_type_t< T, U > InnerProduct (const BasicMatrix< U, N, M > &rhs) const
 Computes the Frobenius inner product of this matrix with the specified right hand matrix. More...
 
constexpr remove_complex_t< T > Frobenius () const
 Computes the Frobenius norm of the matrix. More...
 
constexpr remove_complex_t< T > FrobeniusSquared () const
 Computes the square of the Frobenius norm of the matrix. More...
 

Friends

template<typename U , typename V , std::size_t N1, std::size_t M1, std::size_t L1>
constexpr friend BasicMatrix< std::common_type_t< U, V >, N1, M1 > operator* (const BasicMatrix< U, N1, L1 > &lhs, const BasicMatrix< V, L1, M1 > &rhs)
 
template<typename U , typename V , std::size_t N1, std::size_t M1>
constexpr friend BasicVector< std::common_type_t< U, V >, N1 > operator* (const BasicMatrix< U, N1, M1 > &lhs, const BasicVector< V, M1 > &rhs)
 
template<typename U , typename V , std::size_t N1, std::size_t M1, typename >
constexpr friend BasicMatrix< std::common_type_t< U, V >, 1, M1 > operator* (const BasicVector< U, N1 > &lhs, const BasicMatrix< V, N1, M1 > &rhs)
 
template<typename U , typename V , std::size_t N1, std::size_t M1>
constexpr friend BasicMatrix< std::common_type_t< U, V >, N1, M1 > operator+ (const BasicMatrix< U, N1, M1 > &lhs, const BasicMatrix< V, N1, M1 > &rhs)
 
template<typename U , typename V , std::size_t N1, std::size_t M1>
constexpr friend BasicMatrix< std::common_type_t< U, V >, N1, M1 > operator- (const BasicMatrix< U, N1, M1 > &lhs, const BasicMatrix< V, N1, M1 > &rhs)
 

Related Functions

(Note that these are not member functions.)

template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > operator+ (const BasicMatrix< T, N, M > &lhs, const BasicMatrix< U, N, M > &rhs)
 Performs elementwise addition of two matrices of the same size. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > operator+ (BasicMatrix< T, N, M > &&lhs, const BasicMatrix< U, N, M > &rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, U>>>
constexpr BasicMatrix< U, N, M > operator+ (const BasicMatrix< T, N, M > &lhs, BasicMatrix< U, N, M > &&rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator+ (BasicMatrix< T, N, M > &&lhs, BasicMatrix< T, N, M > &&rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator+ (T lhs, const BasicMatrix< T, N, M > &rhs)
 Performs addition between a constant and a matrix. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator+ (T lhs, BasicMatrix< T, N, M > &&rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator+ (const BasicMatrix< T, N, M > &lhs, T rhs)
 Performs addition between a constant and a matrix. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator+ (BasicMatrix< T, N, M > &&lhs, T rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > operator- (const BasicMatrix< T, N, M > &lhs, const BasicMatrix< U, N, M > &rhs)
 Performs elementwise subtraction of two matrices of the same size. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > operator- (BasicMatrix< T, N, M > &&lhs, const BasicMatrix< U, N, M > &rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator- (const BasicMatrix< T, N, M > &lhs, T rhs)
 Performs subtraction of a constant from every entry in a matrix. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator- (BasicMatrix< T, N, M > &&lhs, T rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator- (T lhs, const BasicMatrix< T, N, M > &rhs)
 Performs subtraction of every entry in a matrix from a constant. More...
 
template<typename T , typename U , std::size_t N, std::size_t M, std::size_t L>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > operator* (const BasicMatrix< T, N, L > &lhs, const BasicMatrix< U, L, M > &rhs)
 Performs matrix-matrix multiplication. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > operator* (BasicMatrix< T, N, M > &&lhs, const BasicMatrix< U, M, M > &rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator* (const BasicMatrix< T, N, M > &lhs, T rhs)
 Performs (right) multiplication of every entry in a matrix by a constant. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator* (BasicMatrix< T, N, M > &&lhs, T rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator* (T lhs, const BasicMatrix< T, N, M > &rhs)
 Performs (left) multiplication of every entry in a matrix by a constant. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator* (T lhs, BasicMatrix< T, N, M > &&rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicVector< std::common_type_t< T, U >, N > operator* (const BasicMatrix< T, N, M > &lhs, const BasicVector< U, M > &rhs)
 Performs right multiplication of a matrix and vector; i.e. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<N!=1>>
constexpr BasicMatrix< std::common_type_t< T, U >, 1, M > operator* (const BasicVector< T, N > &lhs, const BasicMatrix< U, N, M > &rhs)
 Performs left multiplication of a matrix and vector; i.e. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > operator* (const BasicVector< T, N > &lhs, const BasicMatrix< U, 1, M > &rhs)
 Performs multiplication of a column vector and row vector (represented as a matrix) More...
 
template<typename T , typename U , std::size_t N, std::size_t M>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > OuterProduct (const BasicVector< T, N > &lhs, const BasicVector< U, M > &rhs)
 Creates a matrix by outer product of two vectors. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator/ (const BasicMatrix< T, N, M > &lhs, T rhs)
 Divides every entry in a matrix by a constant. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator/ (BasicMatrix< T, N, M > &&lhs, T rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > ElementalMultiply (const BasicMatrix< T, N, M > &lhs, const BasicMatrix< U, N, M > &rhs)
 Performs multiplication of the entries in the first matrix matrix by the corresponding entry in the second matrix (elementwise multiplication). More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > ElementalMultiply (BasicMatrix< T, N, M > &&lhs, const BasicMatrix< U, N, M > &rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, U>>>
constexpr BasicMatrix< U, N, M > ElementalMultiply (const BasicMatrix< T, N, M > &lhs, BasicMatrix< U, N, M > &&rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > ElementalMultiply (BasicMatrix< T, N, M > &&lhs, BasicMatrix< T, N, M > &&rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > ElementalDivide (const BasicMatrix< T, N, M > &lhs, const BasicMatrix< U, N, M > &rhs)
 Performs division of every entry in the first matrix matrix by the corresponding entry in the second matrix (elementwise multiplication). More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > ElementalDivide (BasicMatrix< T, N, M > &&lhs, const BasicMatrix< U, N, M > &rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > ElementalAdd (const BasicMatrix< T, N, M > &lhs, const BasicMatrix< U, N, M > &rhs)
 Performs elementwise addition of two matrices of the same size. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, U>>>
constexpr BasicMatrix< T, N, M > ElementalAdd (BasicMatrix< T, N, M > &&lhs, const BasicMatrix< U, N, M > &rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, U>>>
constexpr BasicMatrix< U, N, M > ElementalAdd (const BasicMatrix< T, N, M > &lhs, BasicMatrix< U, N, M > &&rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > ElementalAdd (BasicMatrix< T, N, M > &&lhs, BasicMatrix< T, N, M > &rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > ElementalSubtract (const BasicMatrix< T, N, M > &lhs, const BasicMatrix< U, N, M > &rhs)
 Performs elementwise subtraction of two matrices of the same size. More...
 
template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > ElementalSubtract (BasicMatrix< T, N, M > &&lhs, const BasicMatrix< U, N, M > &rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , typename Op , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< decltype(Op(T, U)), N, M > ElementalOp (const BasicMatrix< T, N, M > &lhs, const BasicMatrix< U, N, M > &rhs, Op op)
 Performs a binary operation between the corresponding elements of each matrix. More...
 
template<typename T , typename U , typename Op , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<decltype( Op ( T , U )), T>>>
constexpr BasicMatrix< T, N, M > ElementalOp (BasicMatrix< T, N, M > &&lhs, const BasicMatrix< U, N, M > &rhs, Op op)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , typename U , typename Op , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< decltype(Op(T, U)), N, M > ElementalOp (const BasicMatrix< T, N, M > &lhs, const BasicMatrix< U, N, M > &rhs)
 Performs a binary operation between the corresponding elements of each matrix. More...
 
template<typename T , typename U , typename Op , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<decltype( Op ( T , U )), T>>>
constexpr BasicMatrix< T, N, M > ElementalOp (BasicMatrix< T, N, M > &&lhs, const BasicMatrix< U, N, M > &rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, M, N > Transpose (const BasicMatrix< T, N, M > &matrix)
 Computes the transpose of a matrix. More...
 
template<typename T , std::size_t N>
constexpr BasicMatrix< T, N, N > && Transpose (BasicMatrix< T, N, N > &&matrix)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T , std::size_t N>
constexpr BasicMatrix< T, 1, N > Transpose (const BasicVector< T, N > &matrix)
 Computes the matrix resulting from transposing a (column) vector. More...
 
template<typename T , std::size_t N>
constexpr BasicMatrix< T, N, N > DiagonalMatrix (const BasicVector< T, N > &diagonal)
 Creates a square matrix by place a vector on the main diagonal entries of the matrix, and filling the rest of the entries with zero. More...
 
template<std::size_t N, typename T >
constexpr BasicMatrix< T, N, N > DiagonalMatrix (T diagonal)
 Creates a square matrix by place a constant on every entry of the main diagonal of the matrix, and filling the rest of the entries with zero. More...
 

Detailed Description

template<typename T, std::size_t N, std::size_t M = N>
class ptems::BasicMatrix< T, N, M >

A class for representing a small NxM matrix (generally matrix of dimension of the domain)

Warning
Although technically can be used for any size matrix, the methods are optimised only for small ( \(N,M\leq 3\)) matrices. Notably, for example, Determinant() and Inverse() which are implemented in the "simplist" (and most expensive) way (Determinant uses Leibniz, Inverse computes adjugate matrix).
Some of the computations (such as Determinant()) are expanded at compile time, (to try to optimise), but that can result in large compilation time if the matrix is too large. For example, the compiler needs to compute ALL permutations of \(N\) indices for the determinant (Leibniz formula)), which is done in a naive way (only way that compile time it could work) and hence is \(O(N!)\).
Note
To solve a linear system \(Ax=b\) for small matrices calling Inverse may be OK, for larger matrices consider using the LUFactorisation functor.
Template Parameters
TType of the matrix entries
NThe number of rows in the matrix
MThe number of columns in the matrix

Member Typedef Documentation

◆ ColumnView

template<typename T , std::size_t N, std::size_t M = N>
typedef MatrixVectorView<T, N, M, false, true> ptems::BasicMatrix< T, N, M >::ColumnView

A "view" object for accessing, and modifying, a matrix column.

◆ ConjugateType

template<typename T , std::size_t N, std::size_t M = N>
using ptems::BasicMatrix< T, N, M >::ConjugateType = BasicMatrix<typename std::conditional_t<is_complex_v<T>, T, std::complex<T> >,M,N>

The type of the complex conjugate of the matrix.

Will either be the same type if T is complex, otherwise a N*M matrix of std::complex<T>.

◆ ConstColumnView

template<typename T , std::size_t N, std::size_t M = N>
typedef MatrixVectorView<T, N, M, true, true> ptems::BasicMatrix< T, N, M >::ConstColumnView

A "view" object for const access to a matrix column.

◆ ConstRowView

template<typename T , std::size_t N, std::size_t M = N>
typedef MatrixVectorView<T, M, 1, true, false> ptems::BasicMatrix< T, N, M >::ConstRowView

A "view" object for const access to a matrix row.

◆ RowView

template<typename T , std::size_t N, std::size_t M = N>
typedef MatrixVectorView<T, M, 1, false, false> ptems::BasicMatrix< T, N, M >::RowView

A "view" object for accessing, and modifying, a matrix row.

Constructor & Destructor Documentation

◆ BasicMatrix() [1/11]

template<typename T , std::size_t N, std::size_t M = N>
constexpr ptems::BasicMatrix< T, N, M >::BasicMatrix ( )
inlineconstexpr

Constructs a matrix filled with zeros.

◆ BasicMatrix() [2/11]

template<typename T , std::size_t N, std::size_t M = N>
constexpr ptems::BasicMatrix< T, N, M >::BasicMatrix ( value)
inlineexplicitconstexpr

Constructs a matrix filled with with the specified value.

Parameters
valueThe value to fill the matrix with

◆ BasicMatrix() [3/11]

template<typename T , std::size_t N, std::size_t M = N>
template<typename V >
constexpr ptems::BasicMatrix< T, N, M >::BasicMatrix ( const BasicMatrix< V, N, M > &  value)
inlineexplicitconstexpr

Constructs a matrix by explicitly casting from a compatible matrix type.

Template Parameters
VThe type of the matrix entries, must be convertible to T by explicit cast
Parameters
valueThe value to fill the matrix with

◆ BasicMatrix() [4/11]

template<typename T , std::size_t N, std::size_t M = N>
constexpr ptems::BasicMatrix< T, N, M >::BasicMatrix ( const BasicMatrix< T, N, M > &  )
constexprdefault

Copy constructor.

◆ BasicMatrix() [5/11]

template<typename T , std::size_t N, std::size_t M = N>
constexpr ptems::BasicMatrix< T, N, M >::BasicMatrix ( BasicMatrix< T, N, M > &&  )
constexprdefault

Move constructor.

◆ BasicMatrix() [6/11]

template<typename T , std::size_t N, std::size_t M = N>
template<typename V , std::size_t DIM, typename = std::enable_if_t<((DIM == N) && (M == 1)) || ((DIM == M) && (N == 1))>>
constexpr ptems::BasicMatrix< T, N, M >::BasicMatrix ( const BasicVector< V, DIM > &  vec)
inlineexplicitconstexpr

Constructs a matrix representing a row/column vector from the specified vector.

Note
This constructor is only available if N or M is one, and the other is equal to DIM.
Template Parameters
VThe type of the vector entries, must be convertible to T by explicit cast
DIMThe dimension of the vector
Parameters
vecVector to set as the matrix entries

◆ BasicMatrix() [7/11]

template<typename T , std::size_t N, std::size_t M = N>
template<typename... V, typename = std::enable_if_t<(sizeof...(V) == N) && (sizeof...(V) > 1)>>
constexpr ptems::BasicMatrix< T, N, M >::BasicMatrix ( const BasicVector< V, M > &...  vec)
inlineexplicitconstexpr

Constructs a matrix by specifying each row as a vector.

Template Parameters
VThe type of the vector entries, must be convertible to T by explicit cast
Parameters
vecVectors to set as the matrix rows

◆ BasicMatrix() [8/11]

template<typename T , std::size_t N, std::size_t M = N>
template<typename... V, typename = std::enable_if_t<((sizeof...(V) == N*M) && ... && std::is_convertible_v<V,T>)>>
constexpr ptems::BasicMatrix< T, N, M >::BasicMatrix ( V...  v)
inlineconstexpr

Construct a matrix by specifying all entries in Row-Major order.

See also
MatrixOrdering::RowMajor
Template Parameters
VThe type of the entries, must be convertible to T by explicit cast
Parameters
vThe entries of the matrix. Must be exactly N*M values

◆ BasicMatrix() [9/11]

template<typename T , std::size_t N, std::size_t M = N>
template<typename... V, typename = std::enable_if_t<((sizeof...(V) == N*M) && ... && std::is_convertible_v<V,T>)>>
constexpr ptems::BasicMatrix< T, N, M >::BasicMatrix ( MatrixOrdering  ordering,
V...  v 
)
inlineconstexpr

Construct a matrix by specifying all entries in specified ordering.

See also
MatrixOrdering
Template Parameters
VThe type of the entries, must be convertible to T by explicit cast
Parameters
orderingSpecifies if the values are in row-major or column-major order
vThe entries of the matrix. Must be exactly N*M values

◆ BasicMatrix() [10/11]

template<typename T , std::size_t N, std::size_t M = N>
template<typename V >
constexpr ptems::BasicMatrix< T, N, M >::BasicMatrix ( const std::initializer_list< std::initializer_list< V >> &  values)
inlineconstexpr

Construct a matrix by specifying all entries in Row-Major order via nested initialiser lists.

Each "inner" list denotes the entries of one row.

See also
MatrixOrdering::RowMajor
Exceptions
std::invalid_argumentIf values.size() != N, or if the size of any inner initializer list != M.
Template Parameters
VThe type of the entries, must be convertible to T by explicit cast
Parameters
valuesThe entries of the matrix.

◆ BasicMatrix() [11/11]

template<typename T , std::size_t N, std::size_t M = N>
template<typename V >
constexpr ptems::BasicMatrix< T, N, M >::BasicMatrix ( MatrixOrdering  ordering,
const std::initializer_list< std::initializer_list< V >> &  values 
)
inlineconstexpr

Construct a matrix by specifying all entries in specified order via nested initialiser lists.

Each "inner" list denotes the entries of one row (MatrixOrdering::RowMajor) or one column (MatrixOrdering::ColumnMajor).

See also
MatrixOrdering
Exceptions
std::invalid_argumentIf values.size() != N (for row major) or M (for column major), or if the size of any inner initializer list != M (for row major) or N (for column major)
Template Parameters
VThe type of the entries, must be convertible to T by explicit cast
Parameters
orderingSpecifies if the values are in row-major or column-major order
valuesThe entries of the matrix.

Member Function Documentation

◆ Column() [1/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr ColumnView ptems::BasicMatrix< T, N, M >::Column ( std::size_t  j)
inlineconstexpr

Gets a mutable reference to a column of the matrix.

Can be used to set the entry of a complete column:

Matrix<3> mat;
mat.Column(0) = 1;
mat.Column(1) = Vector{1, 2, 3};
BasicVector< double, DIM > Vector
Vector of double precision floating point components.
Definition: vector.hpp:2637
Exceptions
std::out_of_rangeIf j >= M
Warning
The returned view is only valid while the matrix is valid. Accessing entries in the view after the matrix is out of scope is undefined behaviour.
Parameters
jThe (zero-based) index of the column to get
Returns
A view (reference) to the column allowing modification of the entries

◆ Column() [2/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr ConstColumnView ptems::BasicMatrix< T, N, M >::Column ( std::size_t  j) const
inlineconstexpr

Gets a const reference to a column of the matrix.

Exceptions
std::out_of_rangeIf j >= M
Warning
The returned view is only valid while the matrix is valid. Accessing entries in the view after the matrix is out of scope is undefined behaviour.
Parameters
jThe (zero-based) index of the column to get
Returns
A const view (reference) to the column

◆ Conjugate()

template<typename T , std::size_t N, std::size_t M = N>
ConjugateType ptems::BasicMatrix< T, N, M >::Conjugate ( ) const
inline

Computes the complex conjugate of a square matrix.

Note
If the entries of this matrix are not a complex type the result is a complex type (just with zero imaginary part)
Todo:
Cannot be constexpr as std::conj is not constexpr
Returns
The conjugated matrix

◆ ConjugateOverwrite()

template<typename T , std::size_t N, std::size_t M = N>
template<typename V = T, typename = std::enable_if_t<std::is_same_v<T,V>>>
BasicMatrix& ptems::BasicMatrix< T, N, M >::ConjugateOverwrite ( )
inline

Performs complex conjugate of a matrix "in-place" (overwrites the entries of this matrix)

Note
If the entries of this matrix are not complex this is a no-op function
Todo:
Cannot be constexpr as std::conj is not constexpr
Returns
this

◆ Determinant()

template<typename T , std::size_t N, std::size_t M = N>
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr T ptems::BasicMatrix< T, N, M >::Determinant ( ) const
inlineconstexpr

Computes the determinant of a square matrix.

Note
This method only exists if N=M
Warning
For \(N\times N\), \(N \leq 3\) the determinant is computed explicitly. For \(N > 3\) the determinant is computed via the Leibniz formula, which requires computation for all permutations. As such this method is advised to ONLY be used for small matrices.
Returns
The determinant of the matrix

◆ ElementalDivide()

template<typename T , std::size_t N, std::size_t M = N>
template<typename U >
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::ElementalDivide ( const BasicMatrix< U, N, M > &  rhs)
inlineconstexpr

Divides every entry in this matrix by the corresponding entry in the passed matrix (elementwise division)

Template Parameters
UThe type of the entries of the right hand matrix
Parameters
rhsMatrix to elementwise multiple with this matrix
Returns
this

◆ ElementalMultiply()

template<typename T , std::size_t N, std::size_t M = N>
template<typename U >
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::ElementalMultiply ( const BasicMatrix< U, N, M > &  rhs)
inlineconstexpr

Multiplies every entry in this matrix by the corresponding entry in the passed matrix (elementwise multiplication)

Template Parameters
UThe type of the entries of the right hand matrix
Parameters
rhsMatrix to elementwise multiple with this matrix
Returns
this

◆ Frobenius()

template<typename T , std::size_t N, std::size_t M = N>
constexpr remove_complex_t<T> ptems::BasicMatrix< T, N, M >::Frobenius ( ) const
inlineconstexpr

Computes the Frobenius norm of the matrix.

Returns
The Frobenius norm of the matrix

◆ FrobeniusSquared()

template<typename T , std::size_t N, std::size_t M = N>
constexpr remove_complex_t<T> ptems::BasicMatrix< T, N, M >::FrobeniusSquared ( ) const
inlineconstexpr

Computes the square of the Frobenius norm of the matrix.

Returns
The square of the Frobenius norm of the matrix

◆ Hermitian()

template<typename T , std::size_t N, std::size_t M = N>
ConjugateType ptems::BasicMatrix< T, N, M >::Hermitian ( ) const
inline

Computes the conjugate transpose of a square matrix.

Todo:
Cannot be constexpr as std::conj is not constexpr
Returns
The conjugate transposed matrix

◆ HermitianOverwrite()

template<typename T , std::size_t N, std::size_t M = N>
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
BasicMatrix& ptems::BasicMatrix< T, N, M >::HermitianOverwrite ( )
inline

Performs conjugate transpose of a square matrix "in-place" (overwrites the entries of this matrix)

Note
This method only exists if N=M
Todo:
Cannot be constexpr as std::conj is not constexpr
Returns
this

◆ InnerProduct()

template<typename T , std::size_t N, std::size_t M = N>
template<typename U >
constexpr std::common_type_t<T,U> ptems::BasicMatrix< T, N, M >::InnerProduct ( const BasicMatrix< U, N, M > &  rhs) const
inlineconstexpr

Computes the Frobenius inner product of this matrix with the specified right hand matrix.

Template Parameters
UType of the components of the vector to inner product with
Parameters
rhsMatrix to inner product with this matrix
Returns
The Frobenius inner product of the matrices

◆ Inverse()

template<typename T , std::size_t N, std::size_t M = N>
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr BasicMatrix<T,N,N> ptems::BasicMatrix< T, N, M >::Inverse ( double  tolerance = 0) const
inlineconstexpr

Computes the inverse of a square matrix.

Note
This method only exists if N=M
Warning
For \(N\times N\), \(N \leq 3\) the inverse is computed explicitly. For \(N > 3\) the inverse is computed via the matrix of adjugate, which is extremely expensive (and in fact uses Determinant()). As such this method is advised to ONLY be used for small matrices.
Note
To solve a linear system \(Ax=b\) for small matrices calling Inverse may be OK, for larger matrices consider using the LUFactorisation functor.
Exceptions
std::out_of_rangeIf the matrix is singular (Determinant() <= tolerance)
std::invalid_argumentIf tolerance < 0
Parameters
toleranceSpecifies tolerance for detecting zero determinant (default = 0)
Returns
The inverse matrix

◆ InverseOverwrite()

template<typename T , std::size_t N, std::size_t M = N>
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr BasicMatrix<T,N,N>& ptems::BasicMatrix< T, N, M >::InverseOverwrite ( double  tolerance = 0)
inlineconstexpr

Computes the inverse of a square matrix "in-place" (overwrites the entries of this matrix)

Note
This method only exists if N=M
Warning
For \(N\times N\), \(N \leq 3\) the inverse is computed explicitly. For \(N > 3\) the inverse is computed via the matrix of adjugate, which is extremely expensive (and in fact uses Determinant()). As such this method is advised to ONLY be used for small matrices.
Note
To solve a linear system \(Ax=b\) for small matrices calling Inverse may be OK, for larger matrices consider using the LUFactorisation functor.
Exceptions
std::out_of_rangeIf the matrix is singular (Determinant() <= tolerance)
std::invalid_argumentIf tolerance < 0
Parameters
toleranceSpecifies tolerance for detecting zero determinant (default zero)
Returns
this

◆ InverseTranspose()

template<typename T , std::size_t N, std::size_t M = N>
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr BasicMatrix<T,N,N> ptems::BasicMatrix< T, N, M >::InverseTranspose ( double  tolerance = 0) const
inlineconstexpr

Computes the inverse of the transpose of a square matrix.

Note
This method only exists if N=M
Warning
For \(N\times N\), \(N \leq 3\) the inverse is computed explicitly. For \(N > 3\) the inverse is computed via the matrix of adjugate, which is extremely expensive (and in fact uses Determinant()). As such this method is advised to ONLY be used for small matrices.
Note
To solve a linear system \(Ax=b\) for small matrices calling Inverse may be OK, for larger matrices consider using the LUFactorisation functor.
Exceptions
std::out_of_rangeIf the matrix is singular (Determinant() <= tolerance)
std::invalid_argumentIf tolerance < 0
Parameters
toleranceSpecifies tolerance for detecting zero determinant (default = 0)
Returns
The inverse transpose matrix

◆ InverseTransposeOverwrite()

template<typename T , std::size_t N, std::size_t M = N>
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr BasicMatrix<T,N,N>& ptems::BasicMatrix< T, N, M >::InverseTransposeOverwrite ( double  tolerance = 0)
inlineconstexpr

Computes the inverse of the transpose of a square matrix "in-place" (overwrites the entries of this matrix)

Note
This method only exists if N=M
Warning
For \(N\times N\), \(N \leq 3\) the inverse is computed explicitly. For \(N > 3\) the inverse is computed via the matrix of adjugate, which is extremely expensive (and in fact uses Determinant()). As such this method is advised to ONLY be used for small matrices.
Note
To solve a linear system \(Ax=b\) for small matrices calling Inverse may be OK, for larger matrices consider using the LUFactorisation functor.
Exceptions
std::out_of_rangeIf the matrix is singular (Determinant() <= tolerance)
std::invalid_argumentIf tolerance < 0
Parameters
toleranceSpecifies tolerance for detecting zero determinant (default zero)
Returns
this

◆ operator BasicVector< T, D >()

template<typename T , std::size_t N, std::size_t M = N>
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (M == 1)>>
constexpr ptems::BasicMatrix< T, N, M >::operator BasicVector< T, D > ( )
inlineconstexpr

Implicitly converted a matrix representing a column vector into a vector.

Note
This implicit conversion is ONLY available for matrices representing a column vector (M=1), and results in vectors of size N.
Returns
The vector constructed by implicit conversion, Size of Vector = N.

◆ operator()() [1/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr T& ptems::BasicMatrix< T, N, M >::operator() ( std::size_t  i,
std::size_t  j 
)
inlineconstexpr

Gets a mutable reference to the specified entry of the matrix.

Can be used to set an entry.

Matrix<3> mat;
mat(0,0) = 0;
Exceptions
std::out_of_rangeIf i >= N or j >= M
Parameters
iThe (zero-based) row index of the entry to get
jThe (zero-based) column index of the entry to get
Returns
The value in the specified entry of the matrix

◆ operator()() [2/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr T ptems::BasicMatrix< T, N, M >::operator() ( std::size_t  i,
std::size_t  j 
) const
inlineconstexpr

Gets the value in the specified entry of the matrix.

Exceptions
std::out_of_rangeIf i >= N or j >= M
Parameters
iThe (zero-based) row index of the entry to get
jThe (zero-based) column index of the entry to get
Returns
The value in the specified entry of the matrix

◆ operator*=() [1/2]

template<typename T , std::size_t N, std::size_t M = N>
template<typename U , std::size_t D, typename = std::enable_if_t<D == M>>
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::operator*= ( const BasicMatrix< U, D, D > &  rhs)
inlineconstexpr

Performs matrix-matrix multiplication and stores the result directly in this matrix.

Note
This function is only available if the matrix being multiplies is a SQUARE matrix of compatible size (size = M).
Warning
This is MATRIX multiplication, not elementwise multiplication
See also
ElementalMultiply
Template Parameters
UThe type of the entries of the right hand matrix
DThe size of the matrix to multiply by. Must be square, and equal to M
Parameters
rhsThe matrix to multiply by this matrix
Returns
this

◆ operator*=() [2/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::operator*= ( rhs)
inlineconstexpr

Multiplies every entry in this matrix by a constant.

Parameters
rhsValue to multiple every entry by
Returns
this

◆ operator+=() [1/2]

template<typename T , std::size_t N, std::size_t M = N>
template<typename U >
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::operator+= ( const BasicMatrix< U, N, M > &  rhs)
inlineconstexpr

Adds the specified matrix elementwise to this matrix.

Template Parameters
UThe type of the entries of the right hand matrix
Parameters
rhsMatrix to add
Returns
this

◆ operator+=() [2/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::operator+= ( rhs)
inlineconstexpr

Adds a constant to every entry of the matrix.

Parameters
rhsValue to add to entries
Returns
this

◆ operator-()

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix ptems::BasicMatrix< T, N, M >::operator- ( ) const
inlineconstexpr

Gets a matrix containing the negation of this matrix.

Returns
Matrix containing the negation of every entry of this matrix

◆ operator-=() [1/2]

template<typename T , std::size_t N, std::size_t M = N>
template<typename U >
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::operator-= ( const BasicMatrix< U, N, M > &  rhs)
inlineconstexpr

Subtracts the specified matrix elementwise to this matrix.

Template Parameters
UThe type of the entries of the right hand matrix
Parameters
rhsMatrix to subtract
Returns
this

◆ operator-=() [2/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::operator-= ( rhs)
inlineconstexpr

Subtracts a constant from every entry of the matrix.

Parameters
rhsValue to subtract from every entry
Returns
this

◆ operator/=()

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::operator/= ( rhs)
inlineconstexpr

Divides every entry in this matrix by a constant.

Parameters
rhsValue to divide every entry by
Returns
this

◆ operator=() [1/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::operator= ( const BasicMatrix< T, N, M > &  rhs)
inlineconstexpr

Sets this matrix equal to the specified matrix.

Parameters
rhsValue to add to entries
Returns
this

◆ operator=() [2/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::operator= ( rhs)
inlineconstexpr

Sets all entries in the matrix equal to the specified constant.

Parameters
rhsValue to set all entries to
Returns
this

◆ Row() [1/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr RowView ptems::BasicMatrix< T, N, M >::Row ( std::size_t  i)
inlineconstexpr

Gets a mutable reference to a row of the matrix.

Can be used to set the entry of a complete row:

Matrix<3> mat;
mat.Row(0) = 1;
mat.Row(1) = Vector{1, 2, 3};
Exceptions
std::out_of_rangeIf i >= N
Warning
The returned view is only valid while the matrix is valid. Accessing entries in the view after the matrix is out of scope is undefined behaviour.
Parameters
iThe (zero-based) index of the row to get
Returns
A view (reference) to the row allowing modification of the entries

◆ Row() [2/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr ConstRowView ptems::BasicMatrix< T, N, M >::Row ( std::size_t  i) const
inlineconstexpr

Gets a const reference to a row of the matrix.

Exceptions
std::out_of_rangeIf i >= N
Warning
The returned view is only valid while the matrix is valid. Accessing entries in the view after the matrix is out of scope is undefined behaviour.
Parameters
iThe (zero-based) index of the row to get
Returns
A const view (reference) to the row

◆ ToVector()

template<typename T , std::size_t N, std::size_t M = N>
template<std::size_t D = std::max(N,M), typename = std::enable_if_t<((D == N) && (M == 1)) || ((D == M) && (N == 1))>>
constexpr BasicVector<T,D> ptems::BasicMatrix< T, N, M >::ToVector ( )
inlineconstexpr

Convert a matrix representing a column or row vector into a vector.

Note
This function is ONLY available for matrices representing a column vector (M=1) or row (N=1) and results in vectors of size N or M, respectively.
Returns
The vector constructed by implicit conversion, Size of Vector = N or M.

◆ Trace()

template<typename T , std::size_t N, std::size_t M = N>
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr T ptems::BasicMatrix< T, N, M >::Trace ( ) const
inlineconstexpr

Computes the trace of a square matrix.

Note
This method only exists if N=M
Returns
The trace (sum of diagonal entries)

◆ Transpose()

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix<T,M,N> ptems::BasicMatrix< T, N, M >::Transpose ( ) const
inlineconstexpr

Computes the transpose of a square matrix.

Returns
The transposed matrix

◆ TransposeOverwrite()

template<typename T , std::size_t N, std::size_t M = N>
template<std::size_t D = N, typename = std::enable_if_t<(D == N) && (D == M)>>
constexpr BasicMatrix& ptems::BasicMatrix< T, N, M >::TransposeOverwrite ( )
inlineconstexpr

Transposes a square matrix "in-place" (overwrites the entries of this matrix)

Note
This method only exists if N=M
Returns
this

Friends And Related Function Documentation

◆ DiagonalMatrix() [1/2]

template<typename T , std::size_t N>
constexpr BasicMatrix< T, N, N > DiagonalMatrix ( const BasicVector< T, N > &  diagonal)
related

Creates a square matrix by place a vector on the main diagonal entries of the matrix, and filling the rest of the entries with zero.

Note
The type and size of the resulting matrix can be deduced from the vector
Template Parameters
TThe type of the entries of the matrix
NThe size of the input vector and size (rows and columns) of the resulting matrix)
Parameters
diagonalVector to place on the diagonal
Returns
The diagonal matrix

◆ DiagonalMatrix() [2/2]

template<std::size_t N, typename T >
constexpr BasicMatrix< T, N, N > DiagonalMatrix ( diagonal)
related

Creates a square matrix by place a constant on every entry of the main diagonal of the matrix, and filling the rest of the entries with zero.

Warning
The size of the resulting matrix cannot be deduced from the inputs. Therefore the required size MUST be specified at call time:
Matrix<3> mat = DiagonalMatrix<3>(1.0);
The type of the matrix is deduced from the argument - either ensure the passed argument is of the correct type (e.g. use 1.0 instead of 1 for a matrix of doubles) or pass the type at call time:
Matrix<3> mat = DiagonalMatrix<3,double>(1);
Template Parameters
NThe size (rows and columns) of the resulting matrix). MUST be specified
TThe type of the entries of the matrix
Parameters
diagonalConstant to place on every entry of main diagonal
Returns
The diagonal matrix

◆ ElementalAdd() [1/4]

template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > ElementalAdd ( BasicMatrix< T, N, M > &&  lhs,
BasicMatrix< T, N, M > &  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ElementalAdd() [2/4]

template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, U>>>
constexpr BasicMatrix< T, N, M > ElementalAdd ( BasicMatrix< T, N, M > &&  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ElementalAdd() [3/4]

template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, U>>>
constexpr BasicMatrix< U, N, M > ElementalAdd ( const BasicMatrix< T, N, M > &  lhs,
BasicMatrix< U, N, M > &&  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ElementalAdd() [4/4]

template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > ElementalAdd ( const BasicMatrix< T, N, M > &  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

Performs elementwise addition of two matrices of the same size.

Template Parameters
TThe type of the entries of the left hand matrix
UThe type of the entries of the right hand matrix
NThe number of rows in the matrices
MThe number of columns in the matrices
Parameters
lhsThe first matrix to add
rhsThe second matrix to add
Returns
The matrix containing the sum of the two specified matrices
See also
operator+(BasicMatrix<T, N, M>, const BasicMatrix<U, N, M>&)

◆ ElementalDivide() [1/2]

template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > ElementalDivide ( BasicMatrix< T, N, M > &&  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ElementalDivide() [2/2]

template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > ElementalDivide ( const BasicMatrix< T, N, M > &  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

Performs division of every entry in the first matrix matrix by the corresponding entry in the second matrix (elementwise multiplication).

Template Parameters
TThe type of the entries of the left hand matrix
UThe type of the entries of the right hand matrix
NThe number of rows in the matrices
MThe number of columns in matrices
Parameters
lhsThe first matrix
rhsThe second matrix
Returns
Matrix containing the elementwise division of the first matrix by the second

◆ ElementalMultiply() [1/4]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > ElementalMultiply ( BasicMatrix< T, N, M > &&  lhs,
BasicMatrix< T, N, M > &&  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ElementalMultiply() [2/4]

template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > ElementalMultiply ( BasicMatrix< T, N, M > &&  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ElementalMultiply() [3/4]

template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, U>>>
constexpr BasicMatrix< U, N, M > ElementalMultiply ( const BasicMatrix< T, N, M > &  lhs,
BasicMatrix< U, N, M > &&  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ElementalMultiply() [4/4]

template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > ElementalMultiply ( const BasicMatrix< T, N, M > &  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

Performs multiplication of the entries in the first matrix matrix by the corresponding entry in the second matrix (elementwise multiplication).

Template Parameters
TThe type of the entries of the left hand matrix
UThe type of the entries of the right hand matrix
NThe number of rows in the matrices
MThe number of columns in matrices
Parameters
lhsThe first matrix
rhsThe second matrix
Returns
Matrix containing the elementwise multiplication of the two passed matrices

◆ ElementalOp() [1/4]

template<typename T , typename U , typename Op , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<decltype( Op ( T , U )), T>>>
constexpr BasicMatrix< T, N, M > ElementalOp ( BasicMatrix< T, N, M > &&  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ElementalOp() [2/4]

template<typename T , typename U , typename Op , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<decltype( Op ( T , U )), T>>>
constexpr BasicMatrix< T, N, M > ElementalOp ( BasicMatrix< T, N, M > &&  lhs,
const BasicMatrix< U, N, M > &  rhs,
Op  op 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ElementalOp() [3/4]

template<typename T , typename U , typename Op , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< decltype(Op(T, U)), N, M > ElementalOp ( const BasicMatrix< T, N, M > &  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

Performs a binary operation between the corresponding elements of each matrix.

Template Parameters
TThe type of the entries of the left hand matrix
UThe type of the entries of the right hand matrix
NThe number of rows in the matrices
MThe number of columns in the matrices
OpType of a functor object with default constructor and operator() of the form R operator()(const T& lhs, const U& rhs) const where R is the return type
Parameters
lhsThe first matrix to perform the binary operation on
rhsThe second matrix to perform the binary operation on
Returns
The matrix containing the result of applying the specified binary operation elementwise to the two matrices.

◆ ElementalOp() [4/4]

template<typename T , typename U , typename Op , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< decltype(Op(T, U)), N, M > ElementalOp ( const BasicMatrix< T, N, M > &  lhs,
const BasicMatrix< U, N, M > &  rhs,
Op  op 
)
related

Performs a binary operation between the corresponding elements of each matrix.

Template Parameters
TThe type of the entries of the left hand matrix
UThe type of the entries of the right hand matrix
NThe number of rows in the matrices
MThe number of columns in the matrices
OpThe type of the binary operation to perform
Parameters
lhsThe first matrix to perform the binary operation on
rhsThe second matrix to perform the binary operation on
opThe binary operation to perform. Should be a functor of the form R operator()(const T& lhs, const U& rhs) const where R is the return type
Returns
The matrix containing the result of applying the specified binary operation elementwise to the two matrices.

◆ ElementalSubtract() [1/2]

template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > ElementalSubtract ( BasicMatrix< T, N, M > &&  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ElementalSubtract() [2/2]

template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > ElementalSubtract ( const BasicMatrix< T, N, M > &  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

Performs elementwise subtraction of two matrices of the same size.

Template Parameters
TThe type of the entries of the left hand matrix
UThe type of the entries of the right hand matrix
NThe number of rows in the matrices
MThe number of columns in the matrices
Parameters
lhsThe matrix to subtract from
rhsThe matrix to subtract
Returns
The matrix containing the elementwise subtraction of the second matrix from the first
See also
operator-(BasicMatrix<U, N, M>, const BasicMatrix<U, N, M>&)

◆ operator*() [1/9]

template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > operator* ( BasicMatrix< T, N, M > &&  lhs,
const BasicMatrix< U, M, M > &  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator*() [2/9]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator* ( BasicMatrix< T, N, M > &&  lhs,
rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator*() [3/9]

template<typename T , typename U , std::size_t N, std::size_t M, std::size_t L>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > operator* ( const BasicMatrix< T, N, L > &  lhs,
const BasicMatrix< U, L, M > &  rhs 
)
related

Performs matrix-matrix multiplication.

Warning
This is MATRIX multiplication, not elementwise multiplication
See also
ElementalMultiply
Template Parameters
TThe type of the entries of the left hand matrix
UThe type of the entries of the right hand matrix
NThe number of rows in the first matrix
MThe number of columns in the second matrix
LThe number of columns in the first matrix, and rows in the second matrix
Parameters
lhsThe matrix to multiply
rhsThe matrix to multiply by
Returns
Matrix containing the matrix multiplication of the two matrices

◆ operator*() [4/9]

template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicVector< std::common_type_t< T, U >, N > operator* ( const BasicMatrix< T, N, M > &  lhs,
const BasicVector< U, M > &  rhs 
)
related

Performs right multiplication of a matrix and vector; i.e.

\(Av\), where \(A\) is the matrix and \(v\) is the (column) vector.

Template Parameters
TThe type of the entries of the left hand matrix
UThe type of the entries of the right hand vector
NThe number of rows in the matrix
MThe number of columns in the matrix and entries in the vector
Parameters
lhsThe matrix to multiply
rhsThe vector to multiply
Returns
A matrix containing the matrix-vector product

◆ operator*() [5/9]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator* ( const BasicMatrix< T, N, M > &  lhs,
rhs 
)
related

Performs (right) multiplication of every entry in a matrix by a constant.

Template Parameters
TThe type of the entries of the left hand matrix
NThe number of rows in the matrix
MThe number of columns in the matrix
Parameters
lhsThe matrix to multiply by the constant
rhsThe constant to multiply the matrix by
Returns
A matrix containing the constant multiplied with every entry of the passed matrix

◆ operator*() [6/9]

template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > operator* ( const BasicVector< T, N > &  lhs,
const BasicMatrix< U, 1, M > &  rhs 
)
related

Performs multiplication of a column vector and row vector (represented as a matrix)

Note
Use OuterProduct if both vectors are actual vectors (rather than matrices), as this method requires that the right hand vector is converted to a matrix via Transpose or explicit construction/cast
Template Parameters
TThe type of the entries of the left hand vector
UThe type of the entries of the right hand matrix
NThe number of rows in entries in the vector (and rows in resulting matrix)
MThe number of columns in the matrix (and columns in resulting matrix)
Parameters
lhsThe vector to multiply
rhsThe matrix to multiply
Returns
A matrix containing the vector-matrix product

◆ operator*() [7/9]

template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<N!=1>>
constexpr BasicMatrix< std::common_type_t< T, U >, 1, M > operator* ( const BasicVector< T, N > &  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

Performs left multiplication of a matrix and vector; i.e.

\(v^T A\), where \(A\) is the matrix and \(v\) is the (column) vector.

Template Parameters
TThe type of the entries of the left hand vector
UThe type of the entries of the right hand matrix
NThe number of rows in the matrix and entries in the vector
MThe number of columns in the matrix
Parameters
lhsThe vector to multiply
rhsThe matrix to multiply
Returns
A matrix containing the vector-matrix product

◆ operator*() [8/9]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator* ( lhs,
BasicMatrix< T, N, M > &&  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator*() [9/9]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator* ( lhs,
const BasicMatrix< T, N, M > &  rhs 
)
related

Performs (left) multiplication of every entry in a matrix by a constant.

Template Parameters
TThe type of the entries of the right hand matrix
NThe number of rows in the matrix
MThe number of columns in the matrix
Parameters
lhsThe constant to multiply the matrix by
rhsThe matrix to multiply by the constant
Returns
A matrix containing the constant multiplied with every entry of the passed matrix

◆ operator+() [1/8]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator+ ( BasicMatrix< T, N, M > &&  lhs,
BasicMatrix< T, N, M > &&  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator+() [2/8]

template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > operator+ ( BasicMatrix< T, N, M > &&  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator+() [3/8]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator+ ( BasicMatrix< T, N, M > &&  lhs,
rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator+() [4/8]

template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, U>>>
constexpr BasicMatrix< U, N, M > operator+ ( const BasicMatrix< T, N, M > &  lhs,
BasicMatrix< U, N, M > &&  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator+() [5/8]

template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > operator+ ( const BasicMatrix< T, N, M > &  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

Performs elementwise addition of two matrices of the same size.

Template Parameters
TThe type of the entries of the left hand matrix
UThe type of the entries of the right hand matrix
NThe number of rows in the matrices
MThe number of columns in the matrices
Parameters
lhsThe first matrix to add
rhsThe second matrix to add
Returns
The matrix containing the sum of the two specified matrices

◆ operator+() [6/8]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator+ ( const BasicMatrix< T, N, M > &  lhs,
rhs 
)
related

Performs addition between a constant and a matrix.

Template Parameters
TThe type of the entries of the left hand matrix
NThe number of rows in the matrix
MThe number of columns in the matrix
Parameters
lhsThe matrix to add the constant to
rhsThe constant to add to the matrix
Returns
A matrix containing the constant added to every entry of the passed matrix

◆ operator+() [7/8]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator+ ( lhs,
BasicMatrix< T, N, M > &&  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator+() [8/8]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator+ ( lhs,
const BasicMatrix< T, N, M > &  rhs 
)
related

Performs addition between a constant and a matrix.

Template Parameters
TThe type of the entries of the right hand matrix
NThe number of rows in the matrix
MThe number of columns in the matrix
Parameters
lhsThe constant to add to the matrix
rhsThe matrix to add the constant to
Returns
A matrix containing the constant added to every entry of the passed matrix

◆ operator-() [1/5]

template<typename T , typename U , std::size_t N, std::size_t M = N, typename = std::enable_if_t<std::is_same_v<std::common_type_t<T, U>, T>>>
constexpr BasicMatrix< T, N, M > operator- ( BasicMatrix< T, N, M > &&  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator-() [2/5]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator- ( BasicMatrix< T, N, M > &&  lhs,
rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator-() [3/5]

template<typename T , typename U , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > operator- ( const BasicMatrix< T, N, M > &  lhs,
const BasicMatrix< U, N, M > &  rhs 
)
related

Performs elementwise subtraction of two matrices of the same size.

Template Parameters
TThe type of the entries of the left hand matrix
UThe type of the entries of the right hand matrix
NThe number of rows in the matrices
MThe number of columns in the matrices
Parameters
lhsThe matrix to subtract from
rhsThe matrix to subtract
Returns
The matrix containing the elementwise subtraction of the second matrix from the first

◆ operator-() [4/5]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator- ( const BasicMatrix< T, N, M > &  lhs,
rhs 
)
related

Performs subtraction of a constant from every entry in a matrix.

Template Parameters
TThe type of the entries of the left hand matrix
NThe number of rows in the matrix
MThe number of columns in the matrix
Parameters
lhsThe matrix to subtract the constant from
rhsThe constant to subtract from the matrix
Returns
A matrix containing the constant subtracted from every entry of the passed matrix

◆ operator-() [5/5]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator- ( lhs,
const BasicMatrix< T, N, M > &  rhs 
)
related

Performs subtraction of every entry in a matrix from a constant.

Template Parameters
TThe type of the entries of the right hand matrix
NThe number of rows in the matrix
MThe number of columns in the matrix
Parameters
lhsThe constant to subtract from
rhsThe matrix to subtract from the constant
Returns
A matrix containing every matrix entry in the passed matrix subtracted from the constant

◆ operator/() [1/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator/ ( BasicMatrix< T, N, M > &&  lhs,
rhs 
)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator/() [2/2]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, N, M > operator/ ( const BasicMatrix< T, N, M > &  lhs,
rhs 
)
related

Divides every entry in a matrix by a constant.

Template Parameters
TThe type of the entries of the left hand matrix
NThe number of rows in the matrix
MThe number of columns in the matrix
Parameters
lhsThe matrix to divide by the constant
rhsThe constant to divide the matrix by
Returns
A matrix containing the every entry of the passed matrix divided by the constant

◆ OuterProduct()

template<typename T , typename U , std::size_t N, std::size_t M>
constexpr BasicMatrix< std::common_type_t< T, U >, N, M > OuterProduct ( const BasicVector< T, N > &  lhs,
const BasicVector< U, M > &  rhs 
)
related

Creates a matrix by outer product of two vectors.

Note
This is equivalent to lhs*Transpose(rhs)
Template Parameters
TThe type of the entries of the left hand vector
UThe type of the entries of the right hand vector
NThe number of entries in the left hand vector (and rows in resulting matrix)
NThe number of entries in the right hand vector (and columns in resulting matrix)
MThe number of columns in the matrix
Parameters
lhsThe left hand vector
rhsThe right hand vector
Returns
A matrix containing the tensor product of the vectors

◆ Transpose() [1/3]

template<typename T , std::size_t N>
constexpr BasicMatrix< T, N, N > && Transpose ( BasicMatrix< T, N, N > &&  matrix)
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Transpose() [2/3]

template<typename T , std::size_t N, std::size_t M = N>
constexpr BasicMatrix< T, M, N > Transpose ( const BasicMatrix< T, N, M > &  matrix)
related

Computes the transpose of a matrix.

Template Parameters
TThe type of the entries of the matrix
NThe number of rows in the matrix
MThe number of columns in the matrix
Returns
The transposed matrix

◆ Transpose() [3/3]

template<typename T , std::size_t N>
constexpr BasicMatrix< T, 1, N > Transpose ( const BasicVector< T, N > &  matrix)
related

Computes the matrix resulting from transposing a (column) vector.

Template Parameters
TThe type of the entries of the matrix
NThe number of entries in the vector
Returns
Matrix for a row vector containing the transpose of the column vector,

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