molecular
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
molecular::util::Matrix< rows, cols, T > Class Template Reference

Generic matrix template class. More...

#include <Matrix.h>

Public Types

using ValueType = T
 

Public Member Functions

 Matrix ()=default
 Default constructor. More...
 
 Matrix (const T values[rows *cols])
 Construct matrix from an array in row-major order. More...
 
 Matrix (const T values[rows][cols])
 Construct matrix from two-dimensional array. More...
 
 Matrix (std::initializer_list< T > init)
 
template<typename OtherDerived >
 Matrix (const Eigen::MatrixBase< OtherDerived > &other)
 Construct from Eigen expression. More...
 
template<typename OtherDerived >
Matrixoperator= (const Eigen::MatrixBase< OtherDerived > &other)
 Assign from Eigen expression. More...
 
const T * Get () const
 Returns array of matrix elements in row-major order. More...
 
T * operator[] (int row)
 
const T * operator[] (int row) const
 
operator() (int row, int col) const
 
T & operator() (int row, int col)
 
auto ToEigen ()
 
auto ToEigen () const
 
template<class M >
Matrix< rows, M::kCols, T > operator* (const M &mat) const
 Matrix-matrix multiplication. More...
 
Matrix operator* (ValueType s) const
 Matrix-scalar multiplication. More...
 
Matrix operator+ (const Matrix &mat) const
 
Matrixoperator+= (const Matrix &mat)
 
Matrixoperator*= (const Matrix &mat)
 
Matrixoperator*= (ValueType s)
 
Matrixoperator/= (ValueType s)
 
void SetIdentity ()
 
template<class M >
Matrix< M::kRows, M::kCols+cols, T > Augmented (const M &mat) const
 Returns the matrix with mat concatenated to the right side. More...
 
template<int newcols>
Matrix< rows, newcols, T > SubMatrixRight () const
 Returns the right portion of the matrix with the given width. More...
 
template<int newcols>
Matrix< rows, newcols, T > SubMatrixLeft () const
 Returns the left portion of the matrix with the given width. More...
 
void Print () const
 
Matrix< rows, cols, T > Inverse () const
 Returns the inverse of the matrix. More...
 
Matrix< cols, rows, T > Transposed () const
 Returns the transposed of the matrix. More...
 
Trace () const
 Returns the sum of the diagonal elements. More...
 

Static Public Member Functions

static Matrix Identity ()
 
static Matrix Zeros ()
 

Static Public Attributes

static const int kRows = rows
 
static const int kCols = cols
 

Protected Attributes

m [rows][cols]
 

Detailed Description

template<int rows, int cols, typename T = float>
class molecular::util::Matrix< rows, cols, T >

Generic matrix template class.

Member Typedef Documentation

template<int rows, int cols, typename T = float>
using molecular::util::Matrix< rows, cols, T >::ValueType = T

Constructor & Destructor Documentation

template<int rows, int cols, typename T = float>
molecular::util::Matrix< rows, cols, T >::Matrix ( )
default

Default constructor.

template<int rows, int cols, typename T = float>
molecular::util::Matrix< rows, cols, T >::Matrix ( const T  values[rows *cols])
inline

Construct matrix from an array in row-major order.

template<int rows, int cols, typename T = float>
molecular::util::Matrix< rows, cols, T >::Matrix ( const T  values[rows][cols])
inline

Construct matrix from two-dimensional array.

template<int rows, int cols, typename T = float>
molecular::util::Matrix< rows, cols, T >::Matrix ( std::initializer_list< T >  init)
inline
template<int rows, int cols, typename T = float>
template<typename OtherDerived >
molecular::util::Matrix< rows, cols, T >::Matrix ( const Eigen::MatrixBase< OtherDerived > &  other)
inline

Construct from Eigen expression.

Member Function Documentation

template<int rows, int cols, typename T = float>
template<class M >
Matrix<M::kRows, M::kCols + cols, T> molecular::util::Matrix< rows, cols, T >::Augmented ( const M &  mat) const
inline

Returns the matrix with mat concatenated to the right side.

Both matrices must have the same number of rows. The resulting matrix has as many columns as both input matrices together.

template<int rows, int cols, typename T = float>
const T* molecular::util::Matrix< rows, cols, T >::Get ( ) const
inline

Returns array of matrix elements in row-major order.

OpenGL wants column-major order.

template<int rows, int cols, typename T = float>
static Matrix molecular::util::Matrix< rows, cols, T >::Identity ( )
inlinestatic
template<int rows, int cols, typename T >
Matrix< rows, cols, T > molecular::util::Matrix< rows, cols, T >::Inverse ( ) const

Returns the inverse of the matrix.

template<int rows, int cols, typename T = float>
T molecular::util::Matrix< rows, cols, T >::operator() ( int  row,
int  col 
) const
inline

Eigen compatibility.

template<int rows, int cols, typename T = float>
T& molecular::util::Matrix< rows, cols, T >::operator() ( int  row,
int  col 
)
inline

Eigen compatibility.

template<int rows, int cols, typename T = float>
template<class M >
Matrix<rows, M::kCols, T> molecular::util::Matrix< rows, cols, T >::operator* ( const M &  mat) const
inline

Matrix-matrix multiplication.

template<int rows, int cols, typename T = float>
Matrix molecular::util::Matrix< rows, cols, T >::operator* ( ValueType  s) const
inline

Matrix-scalar multiplication.

template<int rows, int cols, typename T = float>
Matrix& molecular::util::Matrix< rows, cols, T >::operator*= ( const Matrix< rows, cols, T > &  mat)
inline
template<int rows, int cols, typename T = float>
Matrix& molecular::util::Matrix< rows, cols, T >::operator*= ( ValueType  s)
inline
template<int rows, int cols, typename T = float>
Matrix molecular::util::Matrix< rows, cols, T >::operator+ ( const Matrix< rows, cols, T > &  mat) const
inline
template<int rows, int cols, typename T = float>
Matrix& molecular::util::Matrix< rows, cols, T >::operator+= ( const Matrix< rows, cols, T > &  mat)
inline
template<int rows, int cols, typename T = float>
Matrix& molecular::util::Matrix< rows, cols, T >::operator/= ( ValueType  s)
inline
template<int rows, int cols, typename T = float>
template<typename OtherDerived >
Matrix& molecular::util::Matrix< rows, cols, T >::operator= ( const Eigen::MatrixBase< OtherDerived > &  other)
inline

Assign from Eigen expression.

template<int rows, int cols, typename T = float>
T* molecular::util::Matrix< rows, cols, T >::operator[] ( int  row)
inline
template<int rows, int cols, typename T = float>
const T* molecular::util::Matrix< rows, cols, T >::operator[] ( int  row) const
inline
template<int rows, int cols, typename T = float>
void molecular::util::Matrix< rows, cols, T >::Print ( ) const
inline
template<int rows, int cols, typename T = float>
void molecular::util::Matrix< rows, cols, T >::SetIdentity ( )
inline
template<int rows, int cols, typename T >
template<int newcols>
Matrix< rows, newcols, T > molecular::util::Matrix< rows, cols, T >::SubMatrixLeft ( ) const

Returns the left portion of the matrix with the given width.

template<int rows, int cols, typename T >
template<int newcols>
Matrix< rows, newcols, T > molecular::util::Matrix< rows, cols, T >::SubMatrixRight ( ) const

Returns the right portion of the matrix with the given width.

template<int rows, int cols, typename T = float>
auto molecular::util::Matrix< rows, cols, T >::ToEigen ( )
inline
template<int rows, int cols, typename T = float>
auto molecular::util::Matrix< rows, cols, T >::ToEigen ( ) const
inline
template<int rows, int cols, typename T = float>
T molecular::util::Matrix< rows, cols, T >::Trace ( ) const
inline

Returns the sum of the diagonal elements.

template<int rows, int cols, typename T = float>
Matrix<cols, rows, T> molecular::util::Matrix< rows, cols, T >::Transposed ( ) const
inline

Returns the transposed of the matrix.

template<int rows, int cols, typename T = float>
static Matrix molecular::util::Matrix< rows, cols, T >::Zeros ( )
inlinestatic

Member Data Documentation

template<int rows, int cols, typename T = float>
const int molecular::util::Matrix< rows, cols, T >::kCols = cols
static
template<int rows, int cols, typename T = float>
const int molecular::util::Matrix< rows, cols, T >::kRows = rows
static
template<int rows, int cols, typename T = float>
T molecular::util::Matrix< rows, cols, T >::m[rows][cols]
protected

Row-major order.


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