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 BasicMatrix & | operator= (T rhs) |
Sets all entries in the matrix equal to the specified constant. More... | |
constexpr BasicMatrix & | operator= (const BasicMatrix< T, N, M > &rhs) |
Sets this matrix equal to the specified matrix. More... | |
constexpr BasicMatrix & | operator+= (T rhs) |
Adds a constant to every entry of the matrix. More... | |
template<typename U > | |
constexpr BasicMatrix & | operator+= (const BasicMatrix< U, N, M > &rhs) |
Adds the specified matrix elementwise to this matrix. More... | |
constexpr BasicMatrix & | operator-= (T rhs) |
Subtracts a constant from every entry of the matrix. More... | |
template<typename U > | |
constexpr BasicMatrix & | operator-= (const BasicMatrix< U, N, M > &rhs) |
Subtracts the specified matrix elementwise to this matrix. More... | |
constexpr BasicMatrix & | operator*= (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 BasicMatrix & | operator*= (const BasicMatrix< U, D, D > &rhs) |
Performs matrix-matrix multiplication and stores the result directly in this matrix. More... | |
constexpr BasicMatrix & | operator/= (T rhs) |
Divides every entry in this matrix by a constant. More... | |
template<typename U > | |
constexpr BasicMatrix & | ElementalMultiply (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 BasicMatrix & | ElementalDivide (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>>> | |
BasicMatrix & | ConjugateOverwrite () |
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 BasicMatrix & | TransposeOverwrite () |
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)>> | |
BasicMatrix & | HermitianOverwrite () |
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... | |
A class for representing a small NxM matrix (generally matrix of dimension of the domain)
T | Type of the matrix entries |
N | The number of rows in the matrix |
M | The number of columns in the matrix |
typedef MatrixVectorView<T, N, M, false, true> ptems::BasicMatrix< T, N, M >::ColumnView |
A "view" object for accessing, and modifying, a matrix column.
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>.
typedef MatrixVectorView<T, N, M, true, true> ptems::BasicMatrix< T, N, M >::ConstColumnView |
A "view" object for const access to a matrix column.
typedef MatrixVectorView<T, M, 1, true, false> ptems::BasicMatrix< T, N, M >::ConstRowView |
A "view" object for const access to a matrix row.
typedef MatrixVectorView<T, M, 1, false, false> ptems::BasicMatrix< T, N, M >::RowView |
A "view" object for accessing, and modifying, a matrix row.
|
inlineconstexpr |
Constructs a matrix filled with zeros.
|
inlineexplicitconstexpr |
Constructs a matrix filled with with the specified value.
value | The value to fill the matrix with |
|
inlineexplicitconstexpr |
Constructs a matrix by explicitly casting from a compatible matrix type.
V | The type of the matrix entries, must be convertible to T by explicit cast |
value | The value to fill the matrix with |
|
constexprdefault |
Copy constructor.
|
constexprdefault |
Move constructor.
|
inlineexplicitconstexpr |
Constructs a matrix representing a row/column vector from the specified vector.
N
or M
is one, and the other is equal to DIM
.V | The type of the vector entries, must be convertible to T by explicit cast |
DIM | The dimension of the vector |
vec | Vector to set as the matrix entries |
|
inlineexplicitconstexpr |
Constructs a matrix by specifying each row as a vector.
V | The type of the vector entries, must be convertible to T by explicit cast |
vec | Vectors to set as the matrix rows |
|
inlineconstexpr |
Construct a matrix by specifying all entries in Row-Major order.
V | The type of the entries, must be convertible to T by explicit cast |
v | The entries of the matrix. Must be exactly N*M values |
|
inlineconstexpr |
Construct a matrix by specifying all entries in specified ordering.
V | The type of the entries, must be convertible to T by explicit cast |
ordering | Specifies if the values are in row-major or column-major order |
v | The entries of the matrix. Must be exactly N*M 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.
std::invalid_argument | If values.size() != N, or if the size of any inner initializer list != M. |
V | The type of the entries, must be convertible to T by explicit cast |
values | The entries of the matrix. |
|
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).
std::invalid_argument | If 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) |
V | The type of the entries, must be convertible to T by explicit cast |
ordering | Specifies if the values are in row-major or column-major order |
values | The entries of the matrix. |
|
inlineconstexpr |
Gets a mutable reference to a column of the matrix.
Can be used to set the entry of a complete column:
std::out_of_range | If j >= M |
j | The (zero-based) index of the column to get |
|
inlineconstexpr |
Gets a const reference to a column of the matrix.
std::out_of_range | If j >= M |
j | The (zero-based) index of the column to get |
|
inline |
Computes the complex conjugate of a square matrix.
|
inline |
Performs complex conjugate of a matrix "in-place" (overwrites the entries of this matrix)
|
inlineconstexpr |
Computes the determinant of a square matrix.
|
inlineconstexpr |
Divides every entry in this matrix by the corresponding entry in the passed matrix (elementwise division)
U | The type of the entries of the right hand matrix |
rhs | Matrix to elementwise multiple with this matrix |
|
inlineconstexpr |
Multiplies every entry in this matrix by the corresponding entry in the passed matrix (elementwise multiplication)
U | The type of the entries of the right hand matrix |
rhs | Matrix to elementwise multiple with this matrix |
|
inlineconstexpr |
Computes the Frobenius norm of the matrix.
|
inlineconstexpr |
Computes the square of the Frobenius norm of the matrix.
|
inline |
Computes the conjugate transpose of a square matrix.
|
inline |
Performs conjugate transpose of a square matrix "in-place" (overwrites the entries of this matrix)
|
inlineconstexpr |
Computes the Frobenius inner product of this matrix with the specified right hand matrix.
U | Type of the components of the vector to inner product with |
rhs | Matrix to inner product with this matrix |
|
inlineconstexpr |
Computes the inverse of a square matrix.
std::out_of_range | If the matrix is singular (Determinant() <= tolerance) |
std::invalid_argument | If tolerance < 0 |
tolerance | Specifies tolerance for detecting zero determinant (default = 0) |
|
inlineconstexpr |
Computes the inverse of a square matrix "in-place" (overwrites the entries of this matrix)
std::out_of_range | If the matrix is singular (Determinant() <= tolerance) |
std::invalid_argument | If tolerance < 0 |
tolerance | Specifies tolerance for detecting zero determinant (default zero) |
|
inlineconstexpr |
Computes the inverse of the transpose of a square matrix.
std::out_of_range | If the matrix is singular (Determinant() <= tolerance) |
std::invalid_argument | If tolerance < 0 |
tolerance | Specifies tolerance for detecting zero determinant (default = 0) |
|
inlineconstexpr |
Computes the inverse of the transpose of a square matrix "in-place" (overwrites the entries of this matrix)
std::out_of_range | If the matrix is singular (Determinant() <= tolerance) |
std::invalid_argument | If tolerance < 0 |
tolerance | Specifies tolerance for detecting zero determinant (default zero) |
|
inlineconstexpr |
Implicitly converted a matrix representing a column vector into a vector.
|
inlineconstexpr |
Gets a mutable reference to the specified entry of the matrix.
Can be used to set an entry.
std::out_of_range | If i >= N or j >= M |
i | The (zero-based) row index of the entry to get |
j | The (zero-based) column index of the entry to get |
|
inlineconstexpr |
Gets the value in the specified entry of the matrix.
std::out_of_range | If i >= N or j >= M |
i | The (zero-based) row index of the entry to get |
j | The (zero-based) column index of the entry to get |
|
inlineconstexpr |
Performs matrix-matrix multiplication and stores the result directly in this matrix.
U | The type of the entries of the right hand matrix |
D | The size of the matrix to multiply by. Must be square, and equal to M |
rhs | The matrix to multiply by this matrix |
|
inlineconstexpr |
Multiplies every entry in this matrix by a constant.
rhs | Value to multiple every entry by |
|
inlineconstexpr |
Adds the specified matrix elementwise to this matrix.
U | The type of the entries of the right hand matrix |
rhs | Matrix to add |
|
inlineconstexpr |
Adds a constant to every entry of the matrix.
rhs | Value to add to entries |
|
inlineconstexpr |
Gets a matrix containing the negation of this matrix.
|
inlineconstexpr |
Subtracts the specified matrix elementwise to this matrix.
U | The type of the entries of the right hand matrix |
rhs | Matrix to subtract |
|
inlineconstexpr |
Subtracts a constant from every entry of the matrix.
rhs | Value to subtract from every entry |
|
inlineconstexpr |
Divides every entry in this matrix by a constant.
rhs | Value to divide every entry by |
|
inlineconstexpr |
Sets this matrix equal to the specified matrix.
rhs | Value to add to entries |
|
inlineconstexpr |
Sets all entries in the matrix equal to the specified constant.
rhs | Value to set all entries to |
|
inlineconstexpr |
Gets a mutable reference to a row of the matrix.
Can be used to set the entry of a complete row:
std::out_of_range | If i >= N |
i | The (zero-based) index of the row to get |
|
inlineconstexpr |
Gets a const reference to a row of the matrix.
std::out_of_range | If i >= N |
i | The (zero-based) index of the row to get |
|
inlineconstexpr |
Convert a matrix representing a column or row vector into a vector.
|
inlineconstexpr |
Computes the trace of a square matrix.
|
inlineconstexpr |
Computes the transpose of a square matrix.
|
inlineconstexpr |
Transposes a square matrix "in-place" (overwrites the entries of this matrix)
|
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.
T | The type of the entries of the matrix |
N | The size of the input vector and size (rows and columns) of the resulting matrix) |
diagonal | Vector to place on the 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.
1.0
instead of 1
for a matrix of doubles) or pass the type at call time: N | The size (rows and columns) of the resulting matrix). MUST be specified |
T | The type of the entries of the matrix |
diagonal | Constant to place on every entry of main diagonal |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Performs elementwise addition of two matrices of the same size.
T | The type of the entries of the left hand matrix |
U | The type of the entries of the right hand matrix |
N | The number of rows in the matrices |
M | The number of columns in the matrices |
lhs | The first matrix to add |
rhs | The second matrix to add |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Performs division of every entry in the first matrix matrix by the corresponding entry in the second matrix (elementwise multiplication).
T | The type of the entries of the left hand matrix |
U | The type of the entries of the right hand matrix |
N | The number of rows in the matrices |
M | The number of columns in matrices |
lhs | The first matrix |
rhs | The second matrix |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Performs multiplication of the entries in the first matrix matrix by the corresponding entry in the second matrix (elementwise multiplication).
T | The type of the entries of the left hand matrix |
U | The type of the entries of the right hand matrix |
N | The number of rows in the matrices |
M | The number of columns in matrices |
lhs | The first matrix |
rhs | The second matrix |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Performs a binary operation between the corresponding elements of each matrix.
T | The type of the entries of the left hand matrix |
U | The type of the entries of the right hand matrix |
N | The number of rows in the matrices |
M | The number of columns in the matrices |
Op | Type 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 |
lhs | The first matrix to perform the binary operation on |
rhs | The second matrix to perform the binary operation on |
|
related |
Performs a binary operation between the corresponding elements of each matrix.
T | The type of the entries of the left hand matrix |
U | The type of the entries of the right hand matrix |
N | The number of rows in the matrices |
M | The number of columns in the matrices |
Op | The type of the binary operation to perform |
lhs | The first matrix to perform the binary operation on |
rhs | The second matrix to perform the binary operation on |
op | The 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 |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Performs elementwise subtraction of two matrices of the same size.
T | The type of the entries of the left hand matrix |
U | The type of the entries of the right hand matrix |
N | The number of rows in the matrices |
M | The number of columns in the matrices |
lhs | The matrix to subtract from |
rhs | The matrix to subtract |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Performs matrix-matrix multiplication.
T | The type of the entries of the left hand matrix |
U | The type of the entries of the right hand matrix |
N | The number of rows in the first matrix |
M | The number of columns in the second matrix |
L | The number of columns in the first matrix, and rows in the second matrix |
lhs | The matrix to multiply |
rhs | The matrix to multiply by |
|
related |
Performs right multiplication of a matrix and vector; i.e.
\(Av\), where \(A\) is the matrix and \(v\) is the (column) vector.
T | The type of the entries of the left hand matrix |
U | The type of the entries of the right hand vector |
N | The number of rows in the matrix |
M | The number of columns in the matrix and entries in the vector |
lhs | The matrix to multiply |
rhs | The vector to multiply |
|
related |
Performs (right) multiplication of every entry in a matrix by a constant.
T | The type of the entries of the left hand matrix |
N | The number of rows in the matrix |
M | The number of columns in the matrix |
lhs | The matrix to multiply by the constant |
rhs | The constant to multiply the matrix by |
|
related |
Performs multiplication of a column vector and row vector (represented as a matrix)
T | The type of the entries of the left hand vector |
U | The type of the entries of the right hand matrix |
N | The number of rows in entries in the vector (and rows in resulting matrix) |
M | The number of columns in the matrix (and columns in resulting matrix) |
lhs | The vector to multiply |
rhs | The matrix to multiply |
|
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.
T | The type of the entries of the left hand vector |
U | The type of the entries of the right hand matrix |
N | The number of rows in the matrix and entries in the vector |
M | The number of columns in the matrix |
lhs | The vector to multiply |
rhs | The matrix to multiply |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Performs (left) multiplication of every entry in a matrix by a constant.
T | The type of the entries of the right hand matrix |
N | The number of rows in the matrix |
M | The number of columns in the matrix |
lhs | The constant to multiply the matrix by |
rhs | The matrix to multiply by the constant |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Performs elementwise addition of two matrices of the same size.
T | The type of the entries of the left hand matrix |
U | The type of the entries of the right hand matrix |
N | The number of rows in the matrices |
M | The number of columns in the matrices |
lhs | The first matrix to add |
rhs | The second matrix to add |
|
related |
Performs addition between a constant and a matrix.
T | The type of the entries of the left hand matrix |
N | The number of rows in the matrix |
M | The number of columns in the matrix |
lhs | The matrix to add the constant to |
rhs | The constant to add to the matrix |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Performs addition between a constant and a matrix.
T | The type of the entries of the right hand matrix |
N | The number of rows in the matrix |
M | The number of columns in the matrix |
lhs | The constant to add to the matrix |
rhs | The matrix to add the constant to |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Performs elementwise subtraction of two matrices of the same size.
T | The type of the entries of the left hand matrix |
U | The type of the entries of the right hand matrix |
N | The number of rows in the matrices |
M | The number of columns in the matrices |
lhs | The matrix to subtract from |
rhs | The matrix to subtract |
|
related |
Performs subtraction of a constant from every entry in a matrix.
T | The type of the entries of the left hand matrix |
N | The number of rows in the matrix |
M | The number of columns in the matrix |
lhs | The matrix to subtract the constant from |
rhs | The constant to subtract from the matrix |
|
related |
Performs subtraction of every entry in a matrix from a constant.
T | The type of the entries of the right hand matrix |
N | The number of rows in the matrix |
M | The number of columns in the matrix |
lhs | The constant to subtract from |
rhs | The matrix to subtract from the constant |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Divides every entry in a matrix by a constant.
T | The type of the entries of the left hand matrix |
N | The number of rows in the matrix |
M | The number of columns in the matrix |
lhs | The matrix to divide by the constant |
rhs | The constant to divide the matrix by |
|
related |
Creates a matrix by outer product of two vectors.
lhs*Transpose(rhs)
T | The type of the entries of the left hand vector |
U | The type of the entries of the right hand vector |
N | The number of entries in the left hand vector (and rows in resulting matrix) |
N | The number of entries in the right hand vector (and columns in resulting matrix) |
M | The number of columns in the matrix |
lhs | The left hand vector |
rhs | The right hand vector |
|
related |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
related |
Computes the transpose of a matrix.
T | The type of the entries of the matrix |
N | The number of rows in the matrix |
M | The number of columns in the matrix |
|
related |
Computes the matrix resulting from transposing a (column) vector.
T | The type of the entries of the matrix |
N | The number of entries in the vector |