Peanut
Peanut is a header-only matrix library using C++20 without any external dependencies, (except unit test), following a expression templates concept. It first constructs matrix expression as a user provides, and evaluates it using an automatically generated code in a compile-time.
Matrix<int, 4, 4> mat1{1,2,3,4,
1,2,3,4,
1,2,3,4,
1,2,3,4};
Matrix<int, 3, 5> mat2{1,2,3,4,5,
1,2,3,4,5,
1,2,3,4,5};
// Peanut first build expression tree,
// `result` type is `MatrixMult<MatrixSubtract<MatrixSum<Matrix<int, 4, 4>, MatrixInverse<Matrix<int, 4, 4>>>, MatrixMinor<Matrix<int, 4, 4>>>, MatrixSub<2, 1, MatrixMult<MatrixTranspose<Matrix<int, 3, 5>>, Matrix<int, 3, 5>>>>`.
auto result = (mat1 + Inverse(mat1) - Minor(mat1)) * SubMat<2, 1>(T(mat2) * mat2);
// then evaluate it when `eval()` is called or assigned to `Matrix` type variable.
/* Matrix<int, 4, 4> */ auto e1 = result.eval();
Matrix<int, 4, 4> e2 = result;
Features
Arbitrary size matrix expression
Lazy evaluation
Unit test
Usage
Copy Peanut directory to your project, and add and its path to the include path. If you’re using CMake, add :
add_subdirectory(ext/peanut)
include_directories(ext/peanut/include)
Then include as below :
#include <Peanut/Peanut.h>
Refer documentation for more information.
Indices and tables
Public Interface
-
using Peanut::Index = unsigned int
-
using Peanut::Float = float
-
template<Index start, Index var, Index end>
bool Peanut::is_between_v = is_between<start, var, end>::value Helper variable template for
is_between<start, var, end>.
-
template<typename E>
bool Peanut::is_matrix_v = is_matrix<E>::value Helper variable template for
is_matrix<E>.
-
template<typename E1, typename E2>
bool Peanut::is_equal_size_mat_v = is_equal_size_mat<E1, E2>::value Helper variable template for
is_equal_size_mat<E1, E2>.
-
template<typename E>
bool Peanut::is_square_v = is_square<E>::value Helper variable template for
is_square<E>.
-
template<typename E1, typename E2>
bool Peanut::is_equal_type_v = is_equal_type<E1, E2>::value Helper variable template for
is_equal_type<E1, E2>.
-
template<typename E1, typename E2>
bool Peanut::is_equal_type_size_v = is_equal_type_size<E1, E2>::value Helper variable template for
is_equal_type_size<E1, E2>.
-
template<typename E, typename T>
Impl::MatrixDivScalar<E, T> Peanut::operator/(const MatrixExpr<E> &x, const T &y) Element-wise division of matrix and scalar. See
Impl::MatrixDivScalar.- Template Parameters:
E – Left hand side matrix expression type.
T – Right hand side scalar type.
- Returns:
Constructed
Impl::MatrixDivScalarinstance
-
template<typename E1, typename E2>
Impl::MatrixEDiv<E1, E2> Peanut::EDiv(const MatrixExpr<E1> &x, const MatrixExpr<E2> &y) Element-wise division of matrix. See
Impl::MatrixEDiv- Template Parameters:
E1 – Left hand side matrix expression type.
E2 – Right hand side matrix expression type.
- Returns:
Constructed
Impl::MatrixEDivinstance
-
template<typename E1, typename E2>
Impl::MatrixEMult<E1, E2> Peanut::operator%(const MatrixExpr<E1> &x, const MatrixExpr<E2> &y) Element-wise multiplication of matrix. See
Impl::MatrixEMult- Template Parameters:
E1 – Left hand side matrix expression type.
E2 – Right hand side matrix expression type.
- Returns:
Constructed
Impl::MatrixEMultinstance
-
template<typename E1, typename E2>
Impl::MatrixMult<E1, E2> Peanut::operator*(const MatrixExpr<E1> &x, const MatrixExpr<E2> &y) Multiplication between matrices. See
Impl::MatrixMult.- Template Parameters:
E1 – Left hand side matrix expression type.
E2 – Right hand side matrix expression type.
- Returns:
Constructed
Impl::MatrixMultinstance
-
template<typename E, typename T>
Impl::MatrixMultScalar<E, T> Peanut::operator*(const MatrixExpr<E> &x, const T &y) Element-wise multiplication of matrix and scalar. See
Impl::MatrixMultScalar.- Template Parameters:
E – Left hand side matrix expression type.
T – Right hand side scalar type.
- Returns:
Constructed
Impl::MatrixMultScalarinstance
-
template<typename E, typename T>
Impl::MatrixMultScalar<E, T> Peanut::operator*(const T x, const MatrixExpr<E> &y) Element-wise multiplication of matrix and scalar. See
Impl::MatrixMultScalar.- Template Parameters:
T – Left hand side scalar type.
E – Right hand side matrix expression type.
- Returns:
Constructed
Impl::MatrixMultScalarinstance
-
template<typename E1, typename E2>
Impl::MatrixSubtract<E1, E2> Peanut::operator-(const MatrixExpr<E1> &x, const MatrixExpr<E2> &y) Subtraction operation of matrix. See
Impl::MatrixSubtract- Template Parameters:
E1 – Left hand side matrix expression type.
E2 – Right hand side matrix expression type.
- Returns:
Constructed
Impl::MatrixSubtractinstance
-
template<typename E1, typename E2>
Impl::MatrixSum<E1, E2> Peanut::operator+(const MatrixExpr<E1> &x, const MatrixExpr<E2> &y) Addition operation of matrix. See
Impl::MatrixSum- Template Parameters:
E1 – Left hand side matrix expression type.
E2 – Right hand side matrix expression type.
- Returns:
Constructed
Impl::MatrixSuminstance
-
template<typename T>
bool Peanut::is_zero(T val) Check if given
valis zero or not.- Parameters:
val – [in] Arithmetic type value which will be checked.
- Template Parameters:
T – A arithmetic type of parameter
val.- Returns:
If
Tis floating point type, returns true ifvalis close to zero, false if not. IfTis not a floating point type, returns true ifvalis zero, false if not.
-
template<class F, std::size_t... Is>
void Peanut::for_(F func, std::index_sequence<Is...>) Function which imitates for loop with a compile-time variable.
- Parameters:
func – [in] Callable object which will be called with loop variable.
- Template Parameters:
N – Compile time loop variable value.
F – Arbitrary type, intended to be callable types (std::function, lambda, etc)
-
template<typename E>
Impl::MatrixAdjugate<E> Peanut::Adjugate(const MatrixExpr<E> &x) Adjugate operation of matrix. See
Impl::MatrixAdjugateand https://en.wikipedia.org/wiki/Adjugate_matrix for details.- Template Parameters:
E – Matrix expression type.
- Returns:
Constructed
Impl::MatrixAdjugateinstance
-
template<Index row_start, Index col_start, Index row_size, Index col_size, typename E>
Impl::MatrixBlock<row_start, col_start, row_size, col_size, E> Peanut::Block(const MatrixExpr<E> &x) Get a submatrix matrix. See
Impl::MatrixBlock- Template Parameters:
row_start – Lower row index of the block
col_start – Lower column index of the block
row_size – Row size of the block
col_size – Column size of the block
E – Matrix expression type.
- Returns:
Constructed
Impl::MatrixBlockinstanceMatrix<int, 4, 4> mat{1,2,3,4, 5,6,7,8, 9,0,1,2, 3,4,5,6}; Matrix<int, 3, 2> ev = Block<0, 1, 3, 2>(mat11); // 2 3 // 6 7 // 0 1
-
template<typename T, typename E>
Impl::MatrixCastType<T, E> Peanut::Cast(const MatrixExpr<E> &x) Type casting of a matrix expression.
- Template Parameters:
T – Target data type.
E – Matrix expression type.
- Returns:
Constructed
Impl::MatrixCastTypeinstance.Matrix<int, 2, 2> mat{1,2, 3,4}; Matrix<float, 2, 2> ev = Cast<float>(mat);
-
template<typename E>
Impl::MatrixCofactor<E> Peanut::Cofactor(const MatrixExpr<E> &x) Cofactor operation (i.e., signed minor) of a matrix. See
Impl::MatrixCofactorand https://en.wikipedia.org/wiki/Cofactor_(linear_algebra)- Template Parameters:
E – Matrix expression type.
- Returns:
Constructed
Impl::MatrixCofactorinstance
-
template<typename E>
Impl::MatrixInverse<E> Peanut::Inverse(const MatrixExpr<E> &x) Inverse operation of matrix. See
Impl::MatrixInverseand https://en.wikipedia.org/wiki/Invertible_matrix for details.- Template Parameters:
E – Matrix expression type.
- Returns:
Constructed
Impl::MatrixInverseinstance
-
template<typename E>
const E &Peanut::Inverse(const Impl::MatrixInverse<E> &x) Template specialization of
Inverse()which represents an inverse of an inverse of a matrix. It is equivalent to a input of the given parameter (i.e., Inv(Inv(x)) = x), so it does not construct aMatrixInverseinstance.- Template Parameters:
E – Matrix expression type.
- Parameters:
x –
MatrixInverse<E>type matrix expression.- Returns:
Input of the given parameter
x
-
template<typename E>
Impl::MatrixMinor<E> Peanut::Minor(const MatrixExpr<E> &x) Minor operation of a matrix. See
Impl::MatrixMinorand https://en.wikipedia.org/wiki/Minor_(linear_algebra).- Template Parameters:
E – Matrix expression type.
- Returns:
Constructed
Impl::MatrixMinorinstance
-
template<typename E>
Impl::MatrixNegation<E> Peanut::operator-(const MatrixExpr<E> &x) Negation operation of matrix.
- Template Parameters:
E – Matrix expression type.
- Returns:
Constructed
Impl::MatrixNegationinstance
-
template<typename E>
const E &Peanut::operator-(const Impl::MatrixNegation<E> &x) Template specialization of
operator-which represents a negation of a negation of a matrix. It is equivalent to a input of the given parameter (i.e., -(-x) = x), so it does not construct aMatrixNegationinstance.- Template Parameters:
E – Matrix expression type.
- Parameters:
x –
MatrixInverse<E>type matrix expression.- Returns:
Input of the given parameter
x
-
template<typename E>
Impl::MatrixESqrt<E> Peanut::Sqrt(const MatrixExpr<E> &x) Element-wise sqrt operation of matrix.
- Template Parameters:
E – Matrix expression type.
- Returns:
Constructed
Impl::MatrixESqrtinstance.
-
template<Index row_ex, Index col_ex, typename E>
Impl::MatrixSub<row_ex, col_ex, E> Peanut::SubMat(const MatrixExpr<E> &x) Get a submatrix matrix by excluding row and column in given indices. See
Impl::MatrixSub.- Template Parameters:
row_ex – R index which will be excluded.
col_ex – Column index which will be excluded.
E – Matrix expression type.
- Returns:
Constructed
Impl::MatrixSubinstanceMatrix<int, 4, 4> mat{1,2,3,4, 5,6,7,8, 9,0,1,2, 3,4,5,6}; Matrix<int, 3, 3> ev = SubMat<1,2>(mat11); // 1 2 4 // 9 0 2 // 3 4 6
-
template<typename E>
Impl::MatrixTranspose<E> Peanut::T(const MatrixExpr<E> &x) Transpose operation of matrix. See
Impl::MatrixTransposeand https://en.wikipedia.org/wiki/Transpose for details.- Template Parameters:
E – Matrix expression type.
- Returns:
Constructed
Impl::MatrixTransposeinstance
-
template<typename E>
const E &Peanut::T(const Impl::MatrixTranspose<E> &x) Template specialization of
T()which represents a transpose of a transpose of a matrix. It is equivalent to a input of the given parameter (i.e., T(T(x)) = x).- Template Parameters:
E – Matrix expression type.
- Parameters:
x –
MatrixTranspose<E>type matrix expression.- Returns:
Input of the given parameter
x
-
template<Index start, Index var, Index end>
struct is_between - #include <common.h>
Compile-time checking structure if given constant is in range.
constexpr
valueis true ifstart<=var<end, false otherwise.- Template Parameters:
start – Minimum value of the range.
var – Constant which will be checked whether in range.
-
template<typename E1, typename E2>
struct is_equal_size_mat - #include <matrix_type_traits.h>
Compile-time checking structure if two Peanut matrix expression type has same size.
- Template Parameters:
E1 – Arbitrary Peanut matrix expression.
E2 – Arbitrary Peanut matrix expression.
-
template<typename E1, typename E2>
struct is_equal_type - #include <matrix_type_traits.h>
Compile-time checking structure if given Peanut matrix expression’s data type is same.
- Template Parameters:
E1 – Arbitrary Peanut matrix expression.
E2 – Arbitrary Peanut matrix expression.
-
template<typename E1, typename E2>
struct is_equal_type_size - #include <matrix_type_traits.h>
Compile-time checking structure if given Peanut matrix expressions have same size and type.
- Template Parameters:
E1 – Arbitrary Peanut matrix expression.
E2 – Arbitrary Peanut matrix expression.
Public Static Attributes
-
static bool value = (is_equal_type_v<E1, E2> && is_equal_size_mat_v<E1, E2>)
Equivalent to
is_equal_type_v<E1, E2> && is_equal_size_mat_v<E1, E2>.
-
template<typename E>
struct is_matrix - #include <matrix_type_traits.h>
Compile-time checking structure if given type is Peanut’s matrix expression type.
- Template Parameters:
E – Arbitrary type.
Public Static Attributes
-
static bool value = std::is_base_of_v<MatrixExpr<E>, E>
True if given type inherits
MatrixExpr, false otherwise. Note that every matrix expression type inheritsMatrixExprin Peanut.
-
template<typename E>
struct is_square - #include <matrix_type_traits.h>
Compile-time checking structure if given Peanut matrix expression type is square.
- Template Parameters:
E – Arbitrary Peanut matrix expression.
-
template<typename T, Index R, Index C>
struct Matrix : public Peanut::MatrixExpr<Matrix<T, R, C>> - #include <matrix.h>
Basic matrix class.
- Template Parameters:
T – Data type.
R – Row size.
C – Column size.
Public Types
-
using Type = T
Data type. See the detailed description of
MatrixExpr.
Public Functions
-
inline Matrix()
Constructor without any initialization.
-
template<typename ...TList>
inline Matrix(TList... tlist) Constructor with row-major elements.
- Parameters:
tlist – Parameter pack with
Ttypes.// {} is also available Matrix<int, 4, 4> mat1(1,2,3,4, 5,6,7,8, 9,0,1,2, 3,4,5,6);
-
inline explicit Matrix(const std::array<T, R * C> &data)
Constructor with std::array.
- Parameters:
data – A std::array having
Ttype andR*Csize.
-
inline explicit Matrix(const std::vector<T> &data)
Constructor with std::vector.
- Parameters:
data – std::vector having
Ttype.
-
template<typename E>
inline Matrix(const MatrixExpr<E> &expr) Constructor from arbitrary Peanut matrix expression.
Lazy evaluation is performed when the given expression is substituted to other
Matrix, orMatrix::eval()is called.- Parameters:
expr – Arbitrary Peanut matrix expression.
- inline INLINE T operator() (Index r, Index c) const
Implementation of
MatrixExpr::operator()which returns rvalue.- Parameters:
r – Row index.
c – Column index.
- Returns:
Rvalue of an element in
r‘th Row andc‘th column.
- inline INLINE T & operator() (Index r, Index c)
Get a reference of element in
r‘th row andc‘th column. Note thatPeanutallows to access lvalue for an evaluated matrix only.- Parameters:
r – Row index.
c – Column index.
- Returns:
Reference of an element in
r‘th Row andc‘th column.
-
inline void set_row(Index idx, const Matrix<Type, 1, Col> &row)
Set a
idx‘th row as a given argumentrow.- Parameters:
idx – Row index.
row – Row matrix which will be assigned to the r’th row of the matrix.
-
inline void set_col(Index idx, const Matrix<Type, Row, 1> &col)
Set a
idx‘th column as a given argumentcol.- Parameters:
idx – Column index.
row – Column matrix which will be assigned to the idx’th column of the matrix.
-
inline void eval(Matrix<Type, Row, Col> &_result) const
Evaluation expressions and return as a
Matrixinstance. Note that every matrix expression classes must implement this method even though it is not a method ofMatrixExpr.- Parameters:
Evaluated – matrix (reference output)
- inline INLINE T operator[] (Index i) const
Subscript operator available only for vector usage (i.e., Row==1 or Col==1)
- Parameters:
i – Index
- Returns:
Ttype i’th element data.
- inline INLINE T & operator[] (Index i)
Subscript operator available only for vector usage. (i.e., Row==1 or Col==1)
- Parameters:
i – Index
- Returns:
Reference of i’th element.
-
inline T dot(const Matrix &vec) const
Dot product available only for vector usage. (i.e., Row==1 or Col==1)
- Parameters:
vec – Equal-type matrix(vector).
- Returns:
T type dot product result.
-
inline Float length() const
L2 distance available only for vector usage. (i.e., Row==1 or Col==1)
- Returns:
Float l2 distance of the vector.
-
inline Matrix<Float, Row, Col> normalize() const
Vector normalization available only for vector usage. (i.e., Row==1 or Col==1)
- Returns:
Normalized Float matrix(vector).
-
inline T max() const
Return max element, available only for vector usage. (i.e., Row==1 or Col==1)
- Returns:
Max element in the vector.
-
inline T min() const
Return min element, available only for vector usage. (i.e., Row==1 or Col==1)
- Returns:
Min element in the vector.
-
inline void subtract_row(Index r1, Index r2, T scalar)
Helper function for Gaussian elimination. It performs row subtraction after multiplying given scalar to the row (i.e.,
r1 = r1 - (r2 * scalar)).- Parameters:
r1 – Row index.
r2 – Row index.
scalar – Scalar which will be multiplied to
r2‘th Row.
-
inline Matrix<Float, R, C> gaussian_elem() const
Perform brute-force Gaussian elimination, which elimiate left-most element per row by repeating
subtract_row().Since it does not perform elimination efficiently, numerical issue may exists with a extremely large/small numbers.
- Returns:
Gaussian elimination-performed matrix.
-
inline T det() const
Calculate a determinant by recursively calculate determinants of submatrices.
- Returns:
Determinant of the matrix.
-
inline T det2() const
Calculate a determinant by performing
gaussian_elem()and multiplying diagonal terms. It is equivalent todet()theoretically, but numerical issue may exists.- Returns:
Determinant of the matrix.
Public Static Functions
-
static inline Matrix zeros()
Factory function for zero matrix.
- Returns:
Zero matrix with given
RandC.
-
static inline Matrix identity()
Construct identity matrix. Available only for square matrix case.
- Returns:
Identity matrix with given
RandC.
-
template<typename ...RList>
static inline Matrix from_rows(RList... rlist) Construct a matrix using given rows (i.e.,
Matrix<Type, 1, Col>)- Parameters:
- Returns:
Constructed matrix
Peanut::Matrix<int, 1, 4> a{1,2,3,4}; Peanut::Matrix<int, 1, 4> b{5,6,7,8}; Peanut::Matrix<int, 1, 4> c{9,10,11,12}; auto mat = Peanut::Matrix<int, 3, 4>::from_rows(a, b, c); // 1 2 3 4 // 5 6 7 8 // 9 10 11 12
-
template<typename ...CList>
static inline Matrix from_cols(CList... clist) Construct a matrix using given columns (i.e.,
Matrix<Type, Row, 1>)- Parameters:
- Returns:
Constructed matrix
Peanut::Matrix<int, 4, 1> a{1,2,3,4}; Peanut::Matrix<int, 4, 1> b{5,6,7,8}; Peanut::Matrix<int, 4, 1> c{9,10,11,12}; auto introwmat = Peanut::Matrix<int, 4, 3>::from_cols(a, b, c); // 1 5 9 // 2 6 10 // 3 7 11 // 4 8 12
Public Static Attributes
-
template<typename E>
struct MatrixExpr - #include <matrix.h>
Base class of every matrix expressions in Peanut.
Peanut implements matrix expression by following CRTP concept to achieve a static polymorphism. Every derived class should follow its interface even they are not forced by the compiler (i.e., pure virtual method). Also they MUST provide their data type via
using Type = XXX, and implementeval()method for matrix evaluation. SeeMatrix<T, R, C>::eval()for more explanation.- Template Parameters:
E – Derived class.
MatrixExpr
Public Functions
-
inline INLINE auto operator()(Index r, Index c) const
Get element in
r‘th Row andc‘th column.It is also used for evaluation of an arbitrary matrix expression by recursively calling in derived classes. See also
Matrix::Matrix(const MatrixExpr<E> &expr)andMatrix::operator(Index r, Index c)and other derived classes.- Parameters:
r – R index.
c – C index.
- Returns:
Rvalue of an element in
r‘th Row andc‘th column.
-
template<std::size_t N>
struct num - #include <common.h>
Helper structure for
for_()
Details
-
template<typename E>
struct MatrixAdjugate : public Peanut::MatrixExpr<MatrixAdjugate<E>> - #include <adjugate.h>
Expression class which represents an adjugate matrix.
Note that
MatrixAdjugateevaluates its input expression internally during construction to avoid duplicated calculation.- Template Parameters:
E – Matrix expression type.
-
template<Index row_start, Index col_start, Index row_size, Index col_size, typename E>
struct MatrixBlock : public Peanut::MatrixExpr<MatrixBlock<row_start, col_start, row_size, col_size, E>> - #include <block.h>
Expression class which represents a block submatrix.
- Template Parameters:
row_start – Lower row index of the block
col_start – Lower column index of the block
row_size – Row size of the block
col_size – Column size of the block
E – Matrix expression type.
-
template<typename T, typename E>
struct MatrixCastType : public Peanut::MatrixExpr<MatrixCastType<T, E>> - #include <cast.h>
Expression class which represents a matrix type casting.
- Template Parameters:
T – Target data type
E – Matrix expression type.
-
template<typename E>
struct MatrixCofactor : public Peanut::MatrixExpr<MatrixCofactor<E>> - #include <cofactor.h>
Expression class which represents a cofactor matrix.
Note that
MatrixCofactorevaluates its input expression internally during construction to avoid duplicated calculation.- Template Parameters:
E – Matrix expression type.
-
template<typename E, typename T>
struct MatrixDivScalar : public Peanut::MatrixExpr<MatrixDivScalar<E, T>> - #include <matrix_div_scalar.h>
Expression class which represents
operator/(). It representsFloattype matrix while evaluation always.- Template Parameters:
E – Left hand side matrix expression type.
T – Right hand side scalar type.
-
template<typename E1, typename E2>
struct MatrixEDiv : public Peanut::MatrixExpr<MatrixEDiv<E1, E2>> - #include <matrix_ediv.h>
Expression class which represents
EDiv(), element-wise division.- Template Parameters:
E1 – Left hand side matrix expression type.
E2 – Right hand side matrix expression type.
-
template<typename E1, typename E2>
struct MatrixEMult : public Peanut::MatrixExpr<MatrixEMult<E1, E2>> - #include <matrix_emult.h>
Expression class which represents
operator%(), element-wise multiplication.- Template Parameters:
E1 – Left hand side matrix expression type.
E2 – Right hand side matrix expression type.
-
template<typename E>
struct MatrixESqrt : public Peanut::MatrixExpr<MatrixESqrt<E>> - #include <sqrt.h>
Expression class which represents a element-wise matrix sqrt.
- Template Parameters:
E – Matrix expression type.
-
template<typename E>
struct MatrixInverse : public Peanut::MatrixExpr<MatrixInverse<E>> - #include <inverse.h>
Expression class which represents an inverse matrix.
Note that
MatrixInverseevaluates its input expression internally during construction to avoid duplicated calculation.- Template Parameters:
E – Matrix expression type.
-
template<typename E>
struct MatrixMinor : public Peanut::MatrixExpr<MatrixMinor<E>> - #include <minor.h>
Expression class which represents a minor matrix.
Note that
MatrixMinorevaluates its input expression internally during construction to avoid duplicated calculation.- Template Parameters:
E – Matrix expression type.
-
template<typename E1, typename E2>
struct MatrixMult : public Peanut::MatrixExpr<MatrixMult<E1, E2>> - #include <matrix_mult.h>
Expression class which represents
operator*().Note that
MatrixMultevaluates its operands internally for the performance issues.- Template Parameters:
E1 – Left hand side matrix expression type.
E2 – Right hand side matrix expression type.
-
template<typename E, typename T>
struct MatrixMultScalar : public Peanut::MatrixExpr<MatrixMultScalar<E, T>> - #include <matrix_mult_scalar.h>
Expression class which represents
operator*().- Template Parameters:
E – Matrix expression type operand.
T – Scalar type operand.
-
template<typename E>
struct MatrixNegation : public Peanut::MatrixExpr<MatrixNegation<E>> - #include <negation.h>
Expression class which represents its negation.
- Template Parameters:
E – Matrix expression type.
-
template<Index row_ex, Index col_ex, typename E>
struct MatrixSub : public Peanut::MatrixExpr<MatrixSub<row_ex, col_ex, E>> - #include <submatrix.h>
Get a submatrix matrix by excluding row and column in given indices.
- Template Parameters:
row_ex – R index which will be excluded.
col_ex – Column index which will be excluded.
E – Matrix expression type.
-
template<typename E1, typename E2>
struct MatrixSubtract : public Peanut::MatrixExpr<MatrixSubtract<E1, E2>> - #include <matrix_subtract.h>
Expression class which represents
operator-().- Template Parameters:
E1 – Left hand side matrix expression type.
E2 – Right hand side matrix expression type.
-
template<typename E1, typename E2>
struct MatrixSum : public Peanut::MatrixExpr<MatrixSum<E1, E2>> - #include <matrix_sum.h>
Expression class which represents
operator+().- Template Parameters:
E1 – Left hand side matrix expression type.
E2 – Right hand side matrix expression type.
-
template<typename E>
struct MatrixTranspose : public Peanut::MatrixExpr<MatrixTranspose<E>> - #include <transpose.h>
Expression class which represents a transpose matrix.
- Template Parameters:
E – Matrix expression type.