Peanut

Unit Test (macOS, AppleClang) Unit Test (macOS, Clang) Unit Test (Ubuntu) Unit Test (Windows MSVC) Unit Test (Windows Clang) Deploy doxygen documents

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>
constexpr bool Peanut::is_between_v = is_between<start, var, end>::value

Helper variable template for is_between<start, var, end>.

template<typename E>
constexpr bool Peanut::is_matrix_v = is_matrix<E>::value

Helper variable template for is_matrix<E>.

template<typename E1, typename E2>
constexpr 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>
constexpr bool Peanut::is_square_v = is_square<E>::value

Helper variable template for is_square<E>.

template<typename E1, typename E2>
constexpr 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>
constexpr 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::MatrixDivScalar instance

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::MatrixEMult instance

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::MatrixMult instance

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::MatrixMultScalar instance

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::MatrixMultScalar instance

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::MatrixSubtract instance

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::MatrixSum instance

template<typename T>
bool Peanut::is_zero(T val)

Check if given val is zero or not.

Parameters:

val[in] Arithmetic type value which will be checked.

Template Parameters:

T – A arithmetic type of parameter val.

Returns:

If T is floating point type, returns true if val is close to zero, false if not. If T is not a floating point type, returns true if val is 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<std::size_t N, typename F>
void Peanut::for_(F func)
template<typename E>
Impl::MatrixAdjugate<E> Peanut::Adjugate(const MatrixExpr<E> &x)

Adjugate operation of matrix. See Impl::MatrixAdjugate and https://en.wikipedia.org/wiki/Adjugate_matrix for details.

Template Parameters:

EMatrix expression type.

Returns:

Constructed Impl::MatrixAdjugate instance

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

  • EMatrix expression type.

Returns:

Constructed Impl::MatrixBlock instance

Matrix<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.

  • EMatrix expression type.

Returns:

Constructed Impl::MatrixCastType instance.

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::MatrixCofactor and https://en.wikipedia.org/wiki/Cofactor_(linear_algebra)

Template Parameters:

EMatrix expression type.

Returns:

Constructed Impl::MatrixCofactor instance

template<typename E>
Impl::MatrixInverse<E> Peanut::Inverse(const MatrixExpr<E> &x)

Inverse operation of matrix. See Impl::MatrixInverse and https://en.wikipedia.org/wiki/Invertible_matrix for details.

Template Parameters:

EMatrix expression type.

Returns:

Constructed Impl::MatrixInverse instance

template<typename E>
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 a MatrixInverse instance.

Template Parameters:

EMatrix expression type.

Parameters:

xMatrixInverse<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::MatrixMinor and https://en.wikipedia.org/wiki/Minor_(linear_algebra).

Template Parameters:

EMatrix expression type.

Returns:

Constructed Impl::MatrixMinor instance

template<typename E>
Impl::MatrixNegation<E> Peanut::operator-(const MatrixExpr<E> &x)

Negation operation of matrix.

Template Parameters:

EMatrix expression type.

Returns:

Constructed Impl::MatrixNegation instance

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.

  • EMatrix expression type.

Returns:

Constructed Impl::MatrixSub instance

Matrix<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::MatrixTranspose and https://en.wikipedia.org/wiki/Transpose for details.

Template Parameters:

EMatrix expression type.

Returns:

Constructed Impl::MatrixTranspose instance

template<typename E>
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:

EMatrix expression type.

Parameters:

xMatrixTranspose<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 value is true if start <= 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.

Public Static Attributes

static constexpr bool value = (E1::Row == E2::Row && E1::Col == E2::Col)

True if rows and cols of E1 and E2 are equal.

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.

Public Static Attributes

static constexpr bool value = std::is_same_v<typename E1::Type, typename E2::Type>

True if E1 ‘s data type and E2 ‘s data type are same.

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 constexpr 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 constexpr bool value = std::is_base_of_v<MatrixExpr<E>, E>

True if given type inherits MatrixExpr, false otherwise. Note that every matrix expression type inherits MatrixExpr in 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.

Public Static Attributes

static constexpr bool value = E::Row == E::Col

True if E ‘s row size equals to its column size.

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 parameters initialize to zero matrix.

template<typename ...TList>
inline Matrix(TList... tlist)

Constructor with row-major elements.

Parameters:

tlist – Parameter pack with T types.

// {} 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 T type and R * C size.

inline explicit Matrix(const std::vector<T> &data)

Constructor with std::vector.

Parameters:

data – std::vector having T type.

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, or Matrix::eval() is called.

Parameters:

expr – Arbitrary Peanut matrix expression.

inline INLINE T elem (Index r, Index c) const

Implementation of MatrixExpr::elem() which returns rvalue.

Parameters:
  • r – Row index.

  • c – Column index.

Returns:

Rvalue of an element in r ‘th Row and c ‘th column.

inline INLINE T & elem (Index r, Index c)

Get a reference of element in r ‘th row and c ‘th column. Note that Peanut allows to access lvalue for an evaluated matrix only.

Parameters:
  • r – Row index.

  • c – Column index.

Returns:

Reference of an element in r ‘th Row and c ‘th column.

inline Matrix<Type, 1, Col> get_row(Index idx) const

Get a idx ‘th row as a Matrix<Type, 1, Col> type.

Parameters:

idx – Row index.

Returns:

Matrix<Type, 1, Col> instance.

inline void set_row(Index idx, const Matrix<Type, 1, Col> &row)

Set a idx ‘th row as a given argument row .

Parameters:
  • idx – Row index.

  • row – Row matrix which will be assigned to the r’th row of the matrix.

inline Matrix<Type, Row, 1> get_col(Index idx) const

Get a idx ‘th column as a Matrix<Type, Row, 1> type.

Parameters:

idx – Column index.

Returns:

Matrix<Type, Row, 1> instance.

inline void set_col(Index idx, const Matrix<Type, Row, 1> &col)

Set a idx ‘th column as a given argument col .

Parameters:
  • idx – Column index.

  • row – Column matrix which will be assigned to the idx’th column of the matrix.

inline INLINE Matrix< Type, Row, Col > eval () const

Evaluation expressions and return as a Matrix instance. Note that every matrix expression classes must implement this method even though it is not a method of MatrixExpr.

Returns:

Evaluated matrix

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:

T type 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 constexpr T det() const

Calculate a determinant by recursively calculate determinants of submatrices.

Returns:

Determinant of the matrix.

inline constexpr T det2() const

Calculate a determinant by performing gaussian_elem() and multiplying diagonal terms. It is equivalent to det() theoretically, but numerical issue may exists.

Returns:

Determinant of the matrix.

Public Static Functions

static inline Matrix zeros()

Equivalent with Matrix::Matrix(), but for explicit purpose.

Returns:

Zero matrix with given R and C .

static inline Matrix identity()

Construct identity matrix. Available only for square matrix case.

Returns:

Identity matrix with given R and C .

template<typename ...RList>
static inline Matrix from_rows(RList... rlist)

Construct a matrix using given rows (i.e., Matrix<Type, 1, Col>)

Parameters:

tlist – Parameter pack with Matrix<Type, 1, Col> types.

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:

tlist – Parameter pack with Matrix<Type, Row, 1> types.

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

static inline Matrix cross(const Matrix &m1, const Matrix &m2)

Cross product available for 3-size vectors.

Returns:

Cross-product result

Public Static Attributes

static constexpr Index Row = R

Row size of the matrix.

static constexpr Index Col = C

Column size of the matrix.

Friends

inline friend std::ostream &operator<<(std::ostream &os, const Matrix &matrix)

An implementation of operator<<

Returns:

Given std::ostream

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 implement eval() method for matrix evaluation. See Matrix<T, R, C>::eval() for more explanation.

Template Parameters:

E – Derived class. MatrixExpr

Subclassed by Peanut::Matrix< Type, Row, Col >, Peanut::Matrix< Float, Row, Col >, Peanut::Matrix< Type, E1::Row, E1::Col >, Peanut::Matrix< Type, E2::Row, E2::Col >

Public Functions

inline INLINE auto elem(Index r, Index c) const

Get element in r ‘th Row and c ‘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) and Matrix::elem(Index r, Index c) and other derived classes.

Parameters:
  • r – R index.

  • c – C index.

Returns:

Rvalue of an element in r ‘th Row and c ‘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 MatrixAdjugate evaluates its input expression internally during construction to avoid duplicated calculation.

Template Parameters:

EMatrix 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

  • EMatrix 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

  • EMatrix expression type.

template<typename E>
struct MatrixCofactor : public Peanut::MatrixExpr<MatrixCofactor<E>>
#include <cofactor.h>

Expression class which represents a cofactor matrix.

Note that MatrixCofactor evaluates its input expression internally during construction to avoid duplicated calculation.

Template Parameters:

EMatrix 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 represents Float type 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 MatrixEMult : public Peanut::MatrixExpr<MatrixEMult<E1, E2>>
#include <matrix_emult.h>

Expression class which represents EMult(), element-wise multiplication.

Template Parameters:
  • E1 – Left hand side matrix expression type.

  • E2 – Right hand side 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 MatrixInverse evaluates its input expression internally during construction to avoid duplicated calculation.

Template Parameters:

EMatrix expression type.

template<typename E>
struct MatrixMinor : public Peanut::MatrixExpr<MatrixMinor<E>>
#include <minor.h>

Expression class which represents a minor matrix.

Note that MatrixMinor evaluates its input expression internally during construction to avoid duplicated calculation.

Template Parameters:

EMatrix 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 MatrixMult evaluates 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:
  • EMatrix 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:

EMatrix 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.

  • EMatrix 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:

EMatrix expression type.