SYNOPSYS

The tensor4 class defines a fourth tensor where indices varie from zero to 2 (aka 3D physical space).

IMPLEMENTATION

template<class T>
class tensor4_basic {
public:

  typedef size_t size_type;
  typedef T      element_type;
  typedef T      float_type;

// allocators:

  tensor4_basic (const T& init_val = 0);
  tensor4_basic (const tensor4_basic<T>& a);

#ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST
        tensor4_basic (const std::initializer_list<std::initializer_list<
                             std::initializer_list<std::initializer_list<T> > > >& il);
#endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST

// affectation:

  tensor4_basic<T>& operator= (const tensor4_basic<T>& a);
  tensor4_basic<T>& operator= (const T& val);

// accessors:

  T&       operator()(size_type i, size_type j, size_type k, size_type l);
  const T& operator()(size_type i, size_type j, size_type k, size_type l) const;

// algebra:

  tensor4_basic<T>& operator*= (const T& k);
  tensor4_basic<T>& operator/= (const T& k) { return operator*= (1./k); }
  tensor4_basic<T>  operator+ (const tensor4_basic<T>& b) const;
  tensor4_basic<T>  operator- (const tensor4_basic<T>& b) const;

// io:
  std::ostream& put (std::ostream& out, size_type d=3) const;

// data:
protected:
  T _x [3][3][3][3];
};
typedef tensor4_basic<Float> tensor4;

// nonlinear algebra:
template <class T>
T norm2 (const tensor4_basic<T>&);
template <class T>
T norm (const tensor4_basic<T>& a) { return sqrt(norm2(a)); }
template <class T>
tensor4_basic<T> dexp (const tensor_basic<T>& a, size_t d = 3);

// algebra:
template <class T>
tensor_basic<T> ddot (const tensor4_basic<T>&, const tensor_basic<T>&);
template <class T>
tensor_basic<T> ddot (const tensor_basic<T>&, const tensor4_basic<T>&);