tinymatrixmath
tmm::Matrix< n, m, Scalar > Class Template Reference

Public Member Functions

 Matrix (const float M[n][m])
 
 Matrix (const float M)
 
void operator= (const Matrix< n, m, Scalar > &M)
 
void operator= (const Scalar M[n][m])
 
void operator= (const Scalar value)
 
Scalar * operator[] (Size i)
 
template<typename T = Scalar, typename = tmm::enable_if_t<(m==1&&n==1), T>>
 operator T ()
 Implicit casting to the Scalar type, enabled only if this matrix is 1x1.
 
template<typename Other_Scalar >
bool equals (const Matrix< n, m, Scalar > &other, Scalar tolerance) const
 Returns true if all elements of this matrix are equal to the elements of another matrix, within some tolerance. More...
 
template<typename Other_Scalar >
bool operator== (const Matrix< n, m, Other_Scalar > &other) const
 Returns true if all elements of this matrix are identically equal to the elements of another matrix. More...
 
template<Size q>
Matrix< n, m+q, Scalar > augmentAfter (const Matrix< n, q, Scalar > &other) const
 
template<Size q>
Matrix< n, m+q, Scalar > augmentBefore (const Matrix< n, q, Scalar > &other) const
 
template<Size p>
Matrix< n+p, m, Scalar > augmentAbove (const Matrix< p, m, Scalar > &other) const
 
template<Size p>
Matrix< n+p, m, Scalar > augmentBelow (const Matrix< p, m, Scalar > &other) const
 
template<Size q>
Matrix< n, q, Scalar > operator* (const Matrix< m, q, Scalar > &other) const
 
Matrix< n, m, Scalar > elementwise_times (const Matrix< n, m, Scalar > &other) const
 
Matrix< n, m, Scalar > negate () const
 
Matrix< n, m, Scalar > operator+ (const Matrix< n, m, Scalar > &other) const
 
Matrix< n, m, Scalar > operator- (const Matrix< n, m, Scalar > &other) const
 
Matrix< n, m, Scalar > operator+ (Scalar a) const
 
Matrix< n, m, Scalar > operator- (Scalar a) const
 
Matrix< n, m, Scalar > operator* (Scalar a) const
 
Matrix< n, m, Scalar > operator/ (Scalar a) const
 
Matrix< m, n, Scalar > transpose () const
 
template<Size p, Size q>
Matrix< p, q, Scalar > get (Size c, Size d) const
 
void set (Size i, Size j, Scalar newVal)
 
template<Size p, Size q>
void set (Size c, Size d, Matrix< p, q, Scalar > newVal)
 
Matrix< 1, m, Scalar > row (Size i) const
 
Matrix< 1, m, Scalar > column (Size j) const
 
void copyTo (Matrix< n, m, Scalar > &other) const
 Copies the contents of this matrix to another matrix. More...
 
template<typename T = Scalar>
tmm::enable_if_t<(m==n), T > determinant () const
 
template<typename T = Matrix<n,n,Scalar>>
tmm::enable_if_t<(m==n), T > cofactor () const
 
template<typename T = Matrix<n,n,Scalar>>
tmm::enable_if_t<(m==n), T > inverse () const
 Attempts to invert the matrix. More...
 

Public Attributes

Scalar data [n][m]
 

Member Function Documentation

◆ copyTo()

template<Size n, Size m, typename Scalar = float>
void tmm::Matrix< n, m, Scalar >::copyTo ( Matrix< n, m, Scalar > &  other) const
inline

Copies the contents of this matrix to another matrix.

Parameters
otherthe matrix to copy to

◆ equals()

template<Size n, Size m, typename Scalar = float>
template<typename Other_Scalar >
bool tmm::Matrix< n, m, Scalar >::equals ( const Matrix< n, m, Scalar > &  other,
Scalar  tolerance 
) const
inline

Returns true if all elements of this matrix are equal to the elements of another matrix, within some tolerance.

Template Parameters
Other_Scalarthe type of the other matrix
Parameters
otherthe matrix to compare to
tolerancethe tolerance to use when comparing elements
Returns
true if all elements of this matrix are equal to the elements of another matrix, within some tolerance

◆ inverse()

template<Size n, Size m, typename Scalar = float>
template<typename T = Matrix<n,n,Scalar>>
tmm::enable_if_t<(m==n), T> tmm::Matrix< n, m, Scalar >::inverse ( ) const
inline

Attempts to invert the matrix.

Template Parameters
Ta helper parameter that ensures this function is only available on small matrices. (No need to set it.)
Returns
an inverted matrix
Warning
This method is not implemented correctly yet.
Todo:
fix and test this method

◆ operator==()

template<Size n, Size m, typename Scalar = float>
template<typename Other_Scalar >
bool tmm::Matrix< n, m, Scalar >::operator== ( const Matrix< n, m, Other_Scalar > &  other) const
inline

Returns true if all elements of this matrix are identically equal to the elements of another matrix.

Parameters
otherthe matrix to compare to
Returns
true if all elements of this matrix are identically equal to the elements of another matrix
Note
For floating-point matrices, consider using equals() instead. equals() allows for a tolerance.

The documentation for this class was generated from the following file: