Go to the documentation of this file.
7 #ifndef INCLUDE_JET_MATRIX2X2_H_
8 #define INCLUDE_JET_MATRIX2X2_H_
28 static_assert(std::is_floating_point<T>::value,
29 "Matrix only can be instantiated with floating point types");
61 Matrix(
const std::initializer_list<std::initializer_list<U>>& lst);
77 void set(T m00, T m01, T m10, T m11);
98 void set(
const std::initializer_list<std::initializer_list<U>>& lst);
124 double tol = std::numeric_limits<double>::epsilon())
const;
270 template <
typename U>
335 std::array<T, 4> _elements;
339 template <
typename T>
344 template <
typename T>
348 template <
typename T>
352 template <
typename T>
356 template <
typename T>
360 template <
typename T>
364 template <
typename T>
368 template <
typename T>
372 template <
typename T>
376 template <
typename T>
380 template <
typename T>
384 template <
typename T>
388 template <
typename T>
392 template <
typename T>
403 #include "detail/matrix2x2-inl.h"
405 #endif // INCLUDE_JET_MATRIX2X2_H_
Matrix & operator+=(const Matrix &m)
Addition assignment with input matrix (element-wise).
T & operator[](size_t i)
Returns reference of i-th element.
Matrix rmul(const Matrix &m) const
Returns input matrix * this matrix.
static Matrix makeScaleMatrix(T sx, T sy)
Makes scale matrix.
void transpose()
Transposes this matrix.
void isub(const Matrix &m)
Subtracts input matrix from this matrix (element-wise).
void idiv(T s)
Divides this matrix with input scalar.
Matrix(const Matrix &m)
Constructs a matrix with input matrix.
T determinant() const
Returns determinant of this matrix.
Vector2< T > mul(const Vector2< T > &v) const
Returns this matrix * input vector.
Matrix rsub(const Matrix &m) const
Returns input matrix - this matrix (element-wise).
T * data()
Returns data pointer of this matrix.
Static-sized M x N matrix class.
Definition: matrix.h:29
Matrix sub(T s) const
Returns this matrix - input scalar.
Matrix rdiv(T s) const
Returns input scalar / this matrix.
Matrix rsub(T s) const
Returns input scalar - this matrix.
void invert()
Inverts this matrix.
Matrix rmul(T s) const
Returns input scalar * this matrix.
Matrix2x2< float > Matrix2x2F
Float-type 2x2 matrix.
Definition: matrix2x2.h:396
void setOffDiagonal(T s)
Sets off-diagonal elements with input scalar.
Matrix2x2< double > Matrix2x2D
Double-type 2x2 matrix.
Definition: matrix2x2.h:399
Matrix(const std::initializer_list< std::initializer_list< U >> &lst)
Constructs a matrix with given initializer list lst.
Matrix strictUpperTri() const
Returns strictly upper triangle part of this matrix.
Matrix mul(const Matrix &m) const
Returns this matrix * input matrix.
const T & operator[](size_t i) const
Returns constant reference of i-th element.
bool isSimilar(const Matrix &m, double tol=std::numeric_limits< double >::epsilon()) const
Matrix & operator+=(T s)
Addition assignment with input scalar.
Matrix(T m00, T m01, T m10, T m11)
Matrix mul(T s) const
Returns this matrix * input scalar.
T frobeniusNorm() const
Returns Frobenius norm.
void imul(T s)
Multiplies input scalar to this matrix.
Matrix & operator*=(const Matrix &m)
Multiplication assignment with input matrix.
void iadd(const Matrix &m)
Adds input matrix to this matrix (element-wise).
Matrix strictLowerTri() const
Returns strictly lower triangle part of this matrix.
void setRow(size_t i, const Vector2< T > &row)
Sets i-th row with input vector.
Definition: advection_solver2.h:18
T trace() const
Returns sum of all diagonal elements.
Matrix< U, 2, 2 > castTo() const
static Matrix makeScaleMatrix(const Vector2< T > &s)
Makes scale matrix.
Matrix(T s)
Constructs constant value matrix.
Matrix()
Constructs identity matrix.
void set(T m00, T m01, T m10, T m11)
Matrix add(const Matrix &m) const
Returns this matrix + input matrix (element-wise).
T absmax() const
Returns absolute maximum among all elements.
2-D matrix class.
Definition: matrix2x2.h:26
T & operator()(size_t i, size_t j)
Returns reference of (i,j) element.
2-D vector class.
Definition: vector2.h:24
Matrix & operator-=(T s)
Subtraction assignment with input scalar.
Matrix upperTri() const
Returns upper triangle part of this matrix (including the diagonal).
bool operator==(const Matrix &m) const
Returns true if is equal to m.
Matrix2x2< T > operator+(const Matrix2x2< T > &a, const Matrix2x2< T > &b)
Returns a + b (element-size).
bool operator!=(const Matrix &m) const
Returns true if is not equal to m.
Matrix inverse() const
Returns inverse matrix.
Matrix lowerTri() const
Returns lower triangle part of this matrix (including the diagonal).
const T * data() const
Returns constant pointer of this matrix.
Matrix sub(const Matrix &m) const
Returns this matrix - input matrix (element-wise).
static Matrix makeIdentity()
Makes all diagonal elements to 1, and other elements to 0.
static Matrix makeZero()
Sets all matrix entries to zero.
void isub(T s)
Subtracts input scalar from this matrix.
size_t cols() const
Returns number of columns of this matrix.
Matrix radd(const Matrix &m) const
Returns input matrix + this matrix (element-wise).
void set(T s)
Sets whole matrix with input scalar.
T sum() const
Returns sum of all elements.
static Matrix makeRotationMatrix(const T &rad)
Matrix transposed() const
Returns transposed matrix.
void imul(const Matrix &m)
Multiplies input matrix to this matrix.
void set(const Matrix &m)
Copies from input matrix.
bool isSquare() const
Returns true if this matrix is a square matrix.
Matrix & operator=(const Matrix &m)
Assigns input matrix.
Matrix2x2< T > operator/(const Matrix2x2< T > &a, T b)
Returns a' / b, where every element of matrix a' is a.
Matrix div(T s) const
Returns this matrix / input scalar.
void set(const std::initializer_list< std::initializer_list< U >> &lst)
Sets this matrix with given initializer list lst.
Matrix add(T s) const
Returns this matrix + input scalar.
Matrix offDiagonal() const
Returns off-diagonal part of this matrix.
Matrix & operator/=(T s)
Division assignment with input scalar.
void setColumn(size_t i, const Vector2< T > &col)
Sets i-th column with input vector.
Matrix2x2< T > operator-(const Matrix2x2< T > &a)
Returns a matrix with opposite sign.
T min() const
Returns minimum among all elements.
void iadd(T s)
Adds input scalar to this matrix.
Matrix2x2< T > operator*(const Matrix2x2< T > &a, T b)
Returns a * b', where every element of matrix b' is b.
const T & operator()(size_t i, size_t j) const
Returns constant reference of (i,j) element.
T max() const
Returns maximum among all elements.
Matrix diagonal() const
Returns diagonal part of this matrix.
void setDiagonal(T s)
Sets diagonal elements with input scalar.
T absmin() const
Returns absolute minimum among all elements.
T avg() const
Returns average of all elements.
Matrix & operator-=(const Matrix &m)
Subtraction assignment with input matrix (element-wise).
Matrix & operator*=(T s)
Multiplication assignment with input scalar.
size_t rows() const
Returns number of rows of this matrix.
Matrix radd(T s) const
Returns input scalar + this matrix.