SCOREC core
Parallel unstructured mesh tools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
apf::Matrix< M, N > Class Template Reference

template-generic matrix of M by N doubles More...

Inherits Array< Vector< N >, M >.

Public Member Functions

 Matrix ()
 mandatory
 
 Matrix (Vector< N > const *vectors)
 construct from an array More...
 
Matrix< M, N > operator+ (Matrix< M, N > const &b) const
 add two matrices
 
Matrix< M, N > operator- (Matrix< M, N > const &b) const
 subtract two matrices
 
Matrix< M, N > operator* (double s) const
 multiply a matrix by a scalar
 
Matrix< M, N > operator/ (double s) const
 divide a matrix by a scalar
 
Vector< M > operator* (Vector< N > const &b) const
 multiply a matrix by a vector
 
template<std::size_t O>
Matrix< M, O > operator* (Matrix< N, O > const &b) const
 multiply two matrices More...
 

Detailed Description

template<std::size_t M, std::size_t N>
class apf::Matrix< M, N >

template-generic matrix of M by N doubles

see apf::Vector for the rationale on templating. In short, this class is designed to handle matrices whose small sizes are known at compile time. They should be used in a functional programming style

For matrices sized at runtime, see apf::DynamicMatrix. For sparse structures or parallel matrices, look outside of APF.

for those interested in software design, notice how Array and Vector come together to form Matrix

Definition at line 31 of file apfMatrix.h.

Constructor & Destructor Documentation

template<std::size_t M, std::size_t N>
apf::Matrix< M, N >::Matrix ( Vector< N > const *  vectors)
inline

construct from an array

construct from an array of Vector

Definition at line 44 of file apfMatrix.h.

45  {
46  for (std::size_t i=0; i < M; ++i)
47  for (std::size_t j=0; j < N; ++j)
48  (*this)[i][j] = vectors[i][j];
49  }

Member Function Documentation

template<std::size_t M, std::size_t N>
template<std::size_t O>
Matrix<M,O> apf::Matrix< M, N >::operator* ( Matrix< N, O > const &  b) const
inline

multiply two matrices

the extra template parameter generates code for all possible combinations of matrix sizes

Definition at line 95 of file apfMatrix.h.

96  {
97  Matrix<M,O> r;
98  for (std::size_t i=0; i < M; ++i)
99  for (std::size_t j=0; j < O; ++j)
100  {
101  r[i][j] = (*this)[i][0]*b[0][j];
102  for (std::size_t k=1; k < N; ++k)
103  r[i][j] += (*this)[i][k]*b[k][j];
104  }
105  return r;
106  }

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