SCOREC core
Parallel unstructured mesh tools
Public Member Functions | List of all members
mth::Tensor< T > Class Template Reference

run-time (dynamic) tensor More...

Inheritance diagram for mth::Tensor< T >:
mth::Matrix< T, M, N > can::Array< Vector< T, 0 >, 0 >

Public Member Functions

 Tensor ()
 default constructor
 
 Tensor (unsigned d)
 construct with dimension d
 
 Tensor (Tensor< T > const &b)
 copy constructor
 
 Tensor (Matrix< T > const &b)
 copy from a matrix
 
Tensor< T > & operator= (Tensor< T > const &b)
 assignment operator
 
Tensor< T > operator= (Matrix< T > const &b)
 assignent to a matrix
 
Tensor< T > operator+ (Tensor< T > const &b)
 add a tensor to a tensor
 
Tensor< T > operator- (Tensor< T > const &b)
 subtract a tensor from a tensor
 
Tensor< T > operator* (Tensor< T > const &b)
 multiply a tensor by a tensor
 
Tensor< T > operator* (T const &s)
 multiply a tensor by a scalar
 
Tensor< T > operator/ (T const &s)
 divide a tensor by a scalar
 
void resize (unsigned d)
 resize this tensor to dimension d More...
 
void resize (unsigned m, unsigned n)
 resize this tensor More...
 
unsigned dim () const
 get the dimension of this tensor
 
- Public Member Functions inherited from mth::Matrix< T, M, N >
 Matrix ()
 default constructor
 
 Matrix (unsigned m, unsigned n)
 construct with m by n elements More...
 
unsigned rows () const
 get the number of rows
 
unsigned cols () const
 get the number of columns
 
T & operator() (unsigned i, unsigned j)
 mutable index operator More...
 
T const & operator() (unsigned i, unsigned j) const
 immutable index operator More...
 
Matrix< T, M, N > operator+ (Matrix< T, M, N > const &b) const
 add two matrices
 
Matrix< T, M, N > operator- (Matrix< T, M, N > const &b) const
 subtract two matrices
 
Matrix< T, M, N > operator* (T const &s) const
 multiply by a scalar
 
Matrix< T, M, N > operator/ (T const &s) const
 divide by a scalar
 
Vector< T, M > operator* (Vector< T, N > const &b) const
 multiply a matrix by a vector
 
template<unsigned O>
Matrix< T, M, O > operator* (Matrix< T, N, O > const &b) const
 multiply two matrices More...
 
void zero ()
 zero a matrix
 
- Public Member Functions inherited from can::Array< Vector< T, 0 >, 0 >
 Array ()
 default constructor - necessary
 
 Array (Array< Vector< T, 0 >, N > const &other)
 copy constructor
 
 ~Array ()
 elems is destroyed automatically
 
Array< Vector< T, 0 >, N > & operator= (Array< Vector< T, 0 >, N > const &other)
 assignment operator
 
Vector< T, 0 > & operator[] (unsigned i)
 mutable index operator
 
Vector< T, 0 > const & operator[] (unsigned i) const
 immutable index operator
 
unsigned size () const
 get the size of this array
 

Detailed Description

template<class T>
class mth::Tensor< T >

run-time (dynamic) tensor

This is a silly wrapper around mth::Matrix<T> for 2x2 and 3x3 matrices that provides operator overloads like tensor * tensor that the dynamic matrix mth::Matrix<T> does not provide for performance and user safety reasons

Definition at line 28 of file mthTensor.h.

Member Function Documentation

◆ resize() [1/2]

template<class T >
void mth::Tensor< T >::resize ( unsigned  d)
inline

resize this tensor to dimension d

d must be 2 or 3

Definition at line 106 of file mthTensor.h.

107  {
108  PCU_ALWAYS_ASSERT((d==2) || (d==3));
109  this->columns = d;
110  this->elems.resize(d*d);
111  }

◆ resize() [2/2]

template<class T >
void mth::Tensor< T >::resize ( unsigned  m,
unsigned  n 
)
inline

resize this tensor

this method overrides Matrix.resize(m,n) to ensure that a Tensor is not improperly resized

Definition at line 115 of file mthTensor.h.

116  {
117  PCU_ALWAYS_ASSERT(m==n);
118  PCU_ALWAYS_ASSERT((m==2) || (m==3));
119  this->columns = m;
120  this->elems.resize(m*m);
121  }

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