Digital Image Correlation Engine  Version 1.0
A modular, high-performance, image correlation tool used to compute full-field displacements and strains from digital images
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
DICe::Matrix< Type, Rows, Cols > Class Template Reference

Generic class for matrix storage and operations The idea behind this matrix class is to have a simple matrix (and vector) class that has all it's storage on the stack and several of it's methods optimized. This class is intended for small size matrices that are used in things like objective calculations of other heavily repeated operations. It is not intended for use with dynamic sizes. In most cases the size should be known at compile time. In a few instances the size is not known (for example when there are different sets of shape functions activated by the user, this leads to runtime sizing of the tangent matrix in the subset-based optimization loop). In cases like these, functionality for dynamic sizing has been emulated by making a Matrix of MAX_MATRIX_DIM size and only uses a portion of that allocation. More...

#include <DICe_Matrix.h>

Public Types

template<size_t VRows = 16>
using Vector = Matrix< Type, VRows, 1 >
 convenience alias for vectors
 

Public Member Functions

 Matrix (const size_t rows=Rows, const size_t cols=Cols)
 
 Matrix (Matrix const &in)
 copy constructor
 
 Matrix (std::initializer_list< std::initializer_list< Type > > list)
 initializer list constructor
 
virtual ~Matrix ()
 default destructor
 
size_t rows () const
 return the number of rows
 
size_t storage_rows () const
 return the stack storage number of rows
 
size_t cols () const
 return the number of columns
 
size_t storage_cols () const
 return the stack storage number of columns
 
size_t size () const
 return the number of columns
 
size_t storage_size () const
 return the stack storage number of columns
 
template<typename RType , size_t RRows, size_t RCols>
void validate_dimensions (const Matrix< RType, RRows, RCols > &rhs) const
 validate the matrix dimensions of the rhs for copy, etc.
 
Type & operator() (const size_t row, const size_t col)
 access operator
 
const Type & operator() (const size_t row, const size_t col) const
 const access operator
 
Type & operator() (const size_t index)
 const access operator
 
const Type & operator() (const size_t index) const
 const access operator
 
const Type operator[] (const size_t index) const
 const access operator
 
Type * data ()
 return a pointer to the storage of the matrix (for LAPACK calls)
 
void put_value (const Type &value)
 set all values of a matrix to given value
 
template<typename RType , size_t RRows, size_t RCols>
void copy (const Matrix< RType, RRows, RCols > &rhs)
 copy another matrix of a different type
 
template<size_t RRows, size_t RCols>
Matrix< Type, Rows, Cols > & operator= (const Matrix< Type, RRows, RCols > &rhs)
 assignment operator
 
template<size_t RRows, size_t RCols>
Matrix< Type, Rows, Cols > operator+ (const Matrix< Type, RRows, RCols > &rhs) const
 add operator
 
template<size_t RRows, size_t RCols>
Matrix< Type, Rows, Cols > operator- (const Matrix< Type, RRows, RCols > &rhs) const
 subtract operator
 
template<typename RType , size_t RRows, size_t RCols>
Matrix< Type, Rows, RCols > operator* (const Matrix< RType, RRows, RCols > &rhs) const
 matrix times a matrix
 
Matrix< Type, Cols, Rows > transpose () const
 transpose of a matrix
 
scalar_t norm () const
 2 norm of a matrix
 
scalar_t max () const
 largest value
 
scalar_t min () const
 smallest value
 
void scale_by (const Type &value)
 scale all values
 
bool all_values_are_zero () const
 
Matrix< scalar_t, Rows, Cols > inv ()
 compute the inverse of a matrix and return as a new matrix
 
scalar_t condition_number ()
 

Static Public Member Functions

static Matrix< Type, Rows, Cols > diag (const Type &value, const size_t size=Rows)
 make a diagonal matrix
 
static Matrix< Type, Rows, Cols > identity (const size_t size=Rows)
 
static scalar_t norm (Matrix< Type, Rows, Cols > matrix)
 2 norm of a matrix as a static method
 

Private Attributes

size_t rows_
 number of rows (may not be equal to Rows if the dimensions are runtime defined)
 
size_t cols_
 number of columns (may not be equal to Rows if the dimensions are runtime defined)
 
std::array< Type, Rows *Cols > data_ {}
 value storage (using array to have the storage be on the stack not the heap like a vector)
 
std::array< int_t, Rows *Rows > int_work_ {}
 work vectors for lapack calls
 
std::array< scalar_t,(Rows >10)?Rows *Rows:10 *Rows > scalar_work_ {}
 
Teuchos::LAPACK< int_t, scalar_tlapack_
 member lapack object
 

Friends

template<size_t RRows, size_t RCols>
bool operator== (const Matrix< Type, Rows, Cols > &lhs, const Matrix< Type, RRows, RCols > &rhs)
 comparison operator
 
template<size_t RRows, size_t RCols>
bool operator!= (const Matrix< Type, Rows, Cols > &lhs, const Matrix< Type, RRows, RCols > &rhs)
 comparison operator
 
std::ostream & operator<< (std::ostream &os, const Matrix< Type, Rows, Cols > &matrix)
 overload the ostream operator to enable std::cout << matrix << std::endl;, etc.
 

Detailed Description

template<typename Type, size_t Rows = 16, size_t Cols = Rows>
class DICe::Matrix< Type, Rows, Cols >

Generic class for matrix storage and operations The idea behind this matrix class is to have a simple matrix (and vector) class that has all it's storage on the stack and several of it's methods optimized. This class is intended for small size matrices that are used in things like objective calculations of other heavily repeated operations. It is not intended for use with dynamic sizes. In most cases the size should be known at compile time. In a few instances the size is not known (for example when there are different sets of shape functions activated by the user, this leads to runtime sizing of the tangent matrix in the subset-based optimization loop). In cases like these, functionality for dynamic sizing has been emulated by making a Matrix of MAX_MATRIX_DIM size and only uses a portion of that allocation.

Constructor & Destructor Documentation

◆ Matrix()

template<typename Type, size_t Rows = 16, size_t Cols = Rows>
DICe::Matrix< Type, Rows, Cols >::Matrix ( const size_t  rows = Rows,
const size_t  cols = Cols 
)
inline

default constructor take two args which are the dimensions of the matrix

Parameters
rowsnumber of rows in use (the Rows template parameter will determine how many rows are allocated on the stack memory)
colsnumber of columns in use (the Cols template parameter will determine how many cols are allocated on the stack memory)