Matrix.h
Go to the documentation of this file.
35 static_assert(!(M == 2 && N == 2) && !(M == 3 && N == 3) && !(M == 4 && N == 4), "Use specialized matrix for 2z2, 3x3, and 4x4 matrices.");
36 static_assert(std::is_floating_point<T>::value, "Matrix only can be instantiated with floating point types.");
126 bool IsSimilar(const MatrixExpression<T, E>& other, double tol = std::numeric_limits<double>::epsilon()) const;
bool IsSimilar(const MatrixExpression< T, E > &other, double tol=std::numeric_limits< double >::epsilon()) const
Definition: Matrix-Impl.h:169
static MatrixConstant< T > MakeZero()
Makes a M x N matrix with zeros.
Definition: Matrix-Impl.h:823
MatrixDiagonal< T, Matrix > Diagonal() const
Returns diagonal part of this matrix.
Definition: Matrix-Impl.h:633
MatrixDiagonal< T, Matrix > OffDiagonal() const
Returns off-diagonal part of this matrix.
Definition: Matrix-Impl.h:639
Matrix & operator*=(const T &s)
Multiplication assignment with input scalar.
Definition: Matrix-Impl.h:737
Matrix & operator/=(const T &s)
Division assignment with input scalar.
Definition: Matrix-Impl.h:752
void SetDiagonal(const T &s)
Sets diagonal elements with input scalar.
Definition: Matrix-Impl.h:92
void IMul(const T &s)
Multiplies input scalar to this matrix.
Definition: Matrix-Impl.h:376
MatrixScalarRSub< T, Matrix > RSub(const T &s) const
Returns input scalar - this matrix.
Definition: Matrix-Impl.h:318
void IAdd(const T &s)
Adds input scalar to this matrix.
Definition: Matrix-Impl.h:350
void Set(const T &s)
Sets whole matrix with input scalar.
Definition: Matrix-Impl.h:52
Matrix expression for matrix-scalar binary operation.
Definition: MatrixExpression.h:261
MatrixScalarAdd< T, Matrix > Add(const T &s) const
Returns this matrix + input scalar.
Definition: Matrix-Impl.h:253
constexpr Size2 size() const
Returns the size of this matrix.
Definition: Matrix-Impl.h:199
void SetRow(size_t i, const VectorExpression< T, E > &row)
Sets i-th row with input vector.
Definition: Matrix-Impl.h:116
void IDiv(const T &s)
Divides this matrix with input scalar.
Definition: Matrix-Impl.h:390
bool operator!=(const MatrixExpression< T, E > &m) const
Returns true if is not equal to m.
Definition: Matrix-Impl.h:791
Iterator begin()
Returns the begin iterator of the matrix.
Definition: Matrix-Impl.h:229
MatrixTriangular< T, Matrix > StrictLowerTri() const
Returns strictly lower triangle part of this matrix.
Definition: Matrix-Impl.h:645
void ISub(const T &s)
Subtracts input scalar from this matrix.
Definition: Matrix-Impl.h:363
Vector expression for matrix-vector multiplication.
Definition: MatrixExpression.h:296
constexpr size_t Cols() const
Returns number of columns of this matrix.
Definition: Matrix-Impl.h:211
T Max() const
Returns maximum among all elements.
Definition: Matrix-Impl.h:515
Matrix & operator+=(const T &s)
Addition assignment with input scalar.
Definition: Matrix-Impl.h:707
MatrixScalarDiv< T, Matrix > Div(const T &s) const
Returns this matrix / input scalar.
Definition: Matrix-Impl.h:299
MatrixScalarSub< T, Matrix > Sub(const T &s) const
Returns this matrix - input scalar.
Definition: Matrix-Impl.h:266
Matrix Inverse() const
Returns inverse matrix.
Definition: Matrix-Impl.h:677
MatrixScalarMul< T, Matrix > RMul(const T &s) const
Returns input scalar * this matrix.
Definition: Matrix-Impl.h:331
MatrixScalarAdd< T, Matrix > RAdd(const T &s) const
Returns input scalar + this matrix.
Definition: Matrix-Impl.h:305
void Resize(size_t m, size_t n, const T &s=T(0))
Resizes to m x n matrix with initial value s.
MatrixScalarMul< T, Matrix > Mul(const T &s) const
Returns this matrix * input scalar.
Definition: Matrix-Impl.h:279
bool IsEqual(const MatrixExpression< T, E > &other) const
Definition: Matrix-Impl.h:144
void ForEach(Callback func) const
Iterates the matrix and invoke given func for each index.
Definition: Matrix-Impl.h:798
Definition: pybind11Utils.h:24
T & operator[](size_t i)
Returns reference of i-th element.
Definition: Matrix-Impl.h:759
bool operator==(const MatrixExpression< T, E > &m) const
Returns true if is equal to m.
Definition: Matrix-Impl.h:784
MatrixTriangular< T, Matrix > StrictUpperTri() const
Returns strictly upper triangle part of this matrix.
Definition: Matrix-Impl.h:651
constexpr bool IsSquare() const
Returns true if this matrix is a square matrix.
Definition: Matrix-Impl.h:193
Iterator end()
Returns the end iterator of the matrix.
Definition: Matrix-Impl.h:241
Matrix & operator-=(const T &s)
Subtraction assignment with input scalar.
Definition: Matrix-Impl.h:722
const Matrix< T, M, N > & operator()() const
Returns actual implementation (the subclass).
Definition: MatrixExpression-Impl.h:34
typename ContainerType::const_iterator ConstIterator
Definition: Matrix.h:40
T Determinant() const
Returns determinant of this matrix.
Definition: Matrix-Impl.h:569
MatrixTriangular< T, Matrix > UpperTri() const
Returns upper triangle part of this matrix (including the diagonal).
Definition: Matrix-Impl.h:663
void ForEachIndex(Callback func) const
Iterates the matrix and invoke given func for each index.
Definition: Matrix-Impl.h:811
static MatrixIdentity< T > MakeIdentity()
Makes a M x N matrix with all diagonal elements to 1, and other elements to 0.
Definition: Matrix-Impl.h:829
T Min() const
Returns minimum among all elements.
Definition: Matrix-Impl.h:502
T AbsMin() const
Returns absolute minimum among all elements.
Definition: Matrix-Impl.h:528
void SetOffDiagonal(const T &s)
Sets off-diagonal elements with input scalar.
Definition: Matrix-Impl.h:103
MatrixTypeCast< U, Matrix, T > CastTo() const
MatrixScalarRDiv< T, Matrix > RDiv(const T &s) const
Returns input matrix / this scalar.
Definition: Matrix-Impl.h:344
constexpr size_t Rows() const
Returns number of rows of this matrix.
Definition: Matrix-Impl.h:205
Matrix< T, N, M > Transposed() const
Returns transposed matrix.
Definition: Matrix-Impl.h:669
T AbsMax() const
Returns absolute maximum among all elements.
Definition: Matrix-Impl.h:541
void SetColumn(size_t j, const VectorExpression< T, E > &col)
Sets j-th column with input vector.
Definition: Matrix-Impl.h:130
MatrixTriangular< T, Matrix > LowerTri() const
Returns lower triangle part of this matrix (including the diagonal).
Definition: Matrix-Impl.h:657
Matrix expression for matrix-matrix multiplication.
Definition: MatrixExpression.h:323