Go to the documentation of this file.
7 #ifndef INCLUDE_JET_MATRIX_MXN_H_
8 #define INCLUDE_JET_MATRIX_MXN_H_
29 std::is_floating_point<T>::value,
30 "MatrixMxN only can be instantiated with floating point types");
62 MatrixMxN(
const std::initializer_list<std::initializer_list<T>>& lst);
81 void resize(
size_t m,
size_t n,
const T& s = T(0));
105 void set(
const std::initializer_list<std::initializer_list<T>>& lst);
108 template <
typename E>
113 void set(
size_t m,
size_t n,
const T* arr);
122 template <
typename E>
126 template <
typename E>
130 template <
typename E>
135 template <
typename E>
137 double tol = std::numeric_limits<double>::epsilon())
const;
175 template <
typename E>
182 template <
typename E>
189 template <
typename VE>
194 template <
typename E>
205 template <
typename E>
212 template <
typename E>
219 template <
typename E>
231 template <
typename E>
238 template <
typename E>
245 template <
typename E>
314 template <
typename U>
320 template <
typename E>
333 template <
typename E>
340 template <
typename E>
347 template <
typename E>
368 template <
typename E>
372 template <
typename E>
403 template <
typename Callback>
432 template <
typename Callback>
454 template <
typename Callback>
474 template <
typename Callback>
498 #include "detail/matrix_mxn-inl.h"
500 #endif // INCLUDE_JET_MATRIX_MXN_H_
M x N matrix class.
Definition: matrix_mxn.h:26
T determinant() const
Returns determinant of this matrix.
const T *const data() const
Returns constant pointer of this matrix.
void iadd(const E &m)
Adds input matrix to this matrix (element-wise).
Base class for vector expression.
Definition: vector_expression.h:25
T * data()
Returns data pointer of this matrix.
bool operator==(const MatrixExpression< T, E > &m) const
Returns true if is equal to m.
MatrixMul< T, E, MatrixMxN > rmul(const E &m) const
Returns input matrix * this matrix.
size_t cols() const
Returns number of columns of this matrix.
ContainerType::ConstIterator ConstIterator
Definition: matrix_mxn.h:34
void forEachIndex(Callback func) const
Iterates the matrix and invoke given func for each index.
bool isEqual(const MatrixExpression< T, E > &other) const
MatrixScalarMul< T, MatrixMxN > rmul(const T &s) const
Returns input scalar * this matrix.
void idiv(const T &s)
Divides this matrix with input scalar.
MatrixMul< T, MatrixMxN, E > mul(const E &m) const
Returns this matrix * input matrix.
Size2 size() const
Returns the size of this matrix.
ContainerType::const_iterator ConstIterator
Definition: array2.h:46
T sum() const
Returns sum of all elements.
void imul(const E &m)
Multiplies input matrix to this matrix.
MatrixSub< T, MatrixMxN, E > rsub(const E &m) const
Returns input matrix - this matrix (element-wise).
MatrixDiagonal< T, MatrixMxN > offDiagonal() const
Returns off-diagonal part of this matrix.
void resize(size_t m, size_t n, const T &s=T(0))
Resizes to m x n matrix with initial value s.
Constant matrix expression.
Definition: matrix_expression.h:49
MatrixMxN(const MatrixExpression< T, E > &other)
Constructs a matrix with expression template.
MatrixMxN & operator-=(const E &m)
Subtraction assignment with input matrix (element-wise).
MatrixTriangular< T, MatrixMxN > strictUpperTri() const
Returns strictly upper triangle part of this matrix.
T & operator()(size_t i, size_t j)
Returns reference of (i,j) element.
Vector expression for matrix-vector multiplication.
Definition: matrix_expression.h:295
bool operator!=(const MatrixExpression< T, E > &m) const
Returns true if is not equal to m.
Matrix expression for binary operation.
Definition: matrix_expression.h:225
MatrixMxN(size_t m, size_t n, const T &s=T(0))
Constructs m x n constant value matrix.
T max() const
Returns maximum among all elements.
void set(const T &s)
Sets whole matrix with input scalar.
bool isSquare() const
Returns true if this matrix is a square matrix.
T min() const
Returns minimum among all elements.
static MatrixIdentity< T > makeIdentity(size_t m)
MatrixScalarAdd< T, MatrixMxN > radd(const T &s) const
Returns input scalar + this matrix.
MatrixMxN(MatrixMxN &&other)
Move constructor.
MatrixTriangular< T, MatrixMxN > lowerTri() const
Returns lower triangle part of this matrix (including the diagonal).
void setOffDiagonal(const T &s)
Sets off-diagonal elements with input scalar.
MatrixMxN(const std::initializer_list< std::initializer_list< T >> &lst)
Constructs a matrix with given initializer list lst.
MatrixMxN & operator/=(const T &s)
Division assignment with input scalar.
MatrixMxN inverse() const
Returns inverse matrix.
2-D array class.
Definition: array2.h:42
MatrixScalarDiv< T, MatrixMxN > div(const T &s) const
Returns this matrix / input scalar.
MatrixMxN & operator=(const E &m)
Assigns input matrix.
MatrixMxN & operator+=(const T &s)
Addition assignment with input scalar.
void parallelForEachIndex(Callback func) const
Iterates the matrix and invoke given func for each index in parallel using multi-threading.
void set(const MatrixExpression< T, E > &other)
Copies from input matrix expression.
MatrixMxN & operator+=(const E &m)
Addition assignment with input matrix (element-wise).
Definition: advection_solver2.h:18
MatrixMxN & operator-=(const T &s)
Subtraction assignment with input scalar.
Iterator begin()
Returns the begin iterator of the matrix.
void parallelForEach(Callback func)
Iterates the matrix and invoke given func for each index in parallel.
T & operator[](size_t i)
Returns reference of i-th element.
void isub(const E &m)
Subtracts input matrix from this matrix (element-wise).
Base class for matrix expression.
Definition: matrix_expression.h:26
ConstIterator end() const
Returns the end const iterator of the matrix.
ConstIterator begin() const
Returns the begin const iterator of the matrix.
MatrixMxN()
Constructs an empty matrix.
T absmax() const
Returns absolute maximum among all elements.
MatrixScalarRDiv< T, MatrixMxN > rdiv(const T &s) const
Returns input matrix / this scalar.
Matrix expression for matrix-scalar binary operation.
Definition: matrix_expression.h:261
void isub(const T &s)
Subtracts input scalar from this matrix.
MatrixMxN(const MatrixMxN &other)
Copy constructor.
MatrixMxN & operator=(const MatrixMxN &other)
Copies to this matrix.
void set(const std::initializer_list< std::initializer_list< T >> &lst)
Sets a matrix with given initializer list lst.
MatrixTriangular< T, MatrixMxN > upperTri() const
Returns upper triangle part of this matrix (including the diagonal).
MatrixAdd< T, MatrixMxN, E > add(const E &m) const
Returns this matrix + input matrix (element-wise).
size_t rows() const
Returns number of rows of this matrix.
Array2< T > ContainerType
Definition: matrix_mxn.h:30
MatrixTypeCast< U, MatrixMxN, T > castTo() const
Type-casts to different value-typed matrix.
MatrixMxN< float > MatrixMxNF
Float-type M x N matrix.
Definition: matrix_mxn.h:491
Iterator end()
Returns the end iterator of the matrix.
T absmin() const
Returns absolute minimum among all elements.
Identity matrix expression.
Definition: matrix_expression.h:80
void transpose()
Transposes this matrix.
void setDiagonal(const T &s)
Sets diagonal elements with input scalar.
MatrixMxN & operator*=(const E &m)
Multiplication assignment with input matrix.
MatrixMxN< double > MatrixMxND
Double-type M x N matrix.
Definition: matrix_mxn.h:494
2-D size class.
Definition: size2.h:19
MatrixSub< T, MatrixMxN, E > sub(const E &m) const
Returns this matrix - input matrix (element-wise).
void setColumn(size_t j, const VectorExpression< T, E > &col)
Sets j-th column with input vector.
Triangular matrix expression.
Definition: matrix_expression.h:179
void forEach(Callback func) const
Iterates the matrix and invoke given func for each index.
ContainerType::Iterator Iterator
Definition: matrix_mxn.h:33
MatrixMxN & operator=(MatrixMxN &&other)
Moves to this matrix.
MatrixAdd< T, MatrixMxN, E > radd(const E &m) const
Returns input matrix + this matrix (element-wise).
MatrixTriangular< T, MatrixMxN > strictLowerTri() const
Returns strictly lower triangle part of this matrix.
MatrixMxN(size_t m, size_t n, const T *arr)
Matrix expression for matrix-matrix multiplication.
Definition: matrix_expression.h:321
const T & operator()(size_t i, size_t j) const
Returns constant reference of (i,j) element.
void set(size_t m, size_t n, const T *arr)
void setRow(size_t i, const VectorExpression< T, E > &row)
Sets i-th row with input vector.
MatrixScalarMul< T, MatrixMxN > mul(const T &s) const
Returns this matrix * input scalar.
void iadd(const T &s)
Adds input scalar to this matrix.
void imul(const T &s)
Multiplies input scalar to this matrix.
Diagonal matrix expression.
Definition: matrix_expression.h:146
MatrixScalarSub< T, MatrixMxN > sub(const T &s) const
Returns this matrix - input scalar.
Matrix expression for unary operation.
Definition: matrix_expression.h:114
MatrixMxN transposed() const
Returns transposed matrix.
ContainerType::iterator Iterator
Definition: array2.h:45
MatrixScalarRSub< T, MatrixMxN > rsub(const T &s) const
Returns input scalar - this matrix.
static MatrixConstant< T > makeZero(size_t m, size_t n)
Makes a m x n matrix with zeros.
MatrixDiagonal< T, MatrixMxN > diagonal() const
Returns diagonal part of this matrix.
MatrixScalarAdd< T, MatrixMxN > add(const T &s) const
Returns this matrix + input scalar.
const T & operator[](size_t i) const
Returns constant reference of i-th element.
void invert()
Inverts this matrix.
bool isSimilar(const MatrixExpression< T, E > &other, double tol=std::numeric_limits< double >::epsilon()) const
MatrixMxN & operator*=(const T &s)
Multiplication assignment with input scalar.
MatrixVectorMul< T, MatrixMxN, VE > mul(const VectorExpression< T, VE > &v) const
Returns this matrix * input vector.
T avg() const
Returns average of all elements.