rheolef  6.6
tensor4.h
Go to the documentation of this file.
1 # ifndef _RHEOLEF_TENSOR4_H
2 # define _RHEOLEF_TENSOR4_H
3 
14 #include "rheolef/point.h"
15 #include "rheolef/tensor.h"
16 namespace rheolef {
17 
18 template<class T>
20 public:
21 
22  typedef size_t size_type;
23  typedef T element_type;
24  typedef T float_type;
25 
26 
27  tensor4_basic ();
28  explicit tensor4_basic (const T& init_val);
30  static tensor4_basic<T> eye (size_type d = 3);
31 
32 #ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST
33  tensor4_basic (const std::initializer_list<std::initializer_list<
34  std::initializer_list<std::initializer_list<T> > > >& il);
35 #endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST
36 
37 
39  tensor4_basic<T>& operator= (const T& val);
40 
41 
42  T& operator()(size_type i, size_type j, size_type k, size_type l);
43  const T& operator()(size_type i, size_type j, size_type k, size_type l) const;
44 
45  tensor_basic<T>& operator()(size_type i, size_type j);
46  const tensor_basic<T>& operator()(size_type i, size_type j) const;
47 
48 
49  tensor4_basic<T>& operator*= (const T& k);
50  tensor4_basic<T>& operator/= (const T& k) { return operator*= (1./k); }
53 
54  std::ostream& put (std::ostream& out, size_type d=3) const;
55 
56 protected:
58 };
60 
61 template <class T>
62 T norm2 (const tensor4_basic<T>&);
63 template <class T>
64 T norm (const tensor4_basic<T>& a) { return sqrt(norm2(a)); }
65 template <class T>
66 tensor4_basic<T> dexp (const tensor_basic<T>& a, size_t d = 3);
67 
68 template <class T>
69 tensor_basic<T> ddot (const tensor4_basic<T>&, const tensor_basic<T>&);
70 template <class T>
71 tensor_basic<T> ddot (const tensor_basic<T>&, const tensor4_basic<T>&);
72 @endcode
73 template<class T> struct float_traits<tensor4_basic<T> > { typedef typename float_traits<T>::type type; };
74 template<class T> struct scalar_traits<tensor4_basic<T> > { typedef T type; };
75 
76 template<class T>
77 inline
79  : _x (tensor_basic<T>(T()))
80 {
81 }
82 template<class T>
83 inline
85  : _x (tensor_basic<T>(init_val))
86 {
87 }
88 template<class T>
89 inline
91  : _x (tensor_basic<T>(T()))
92 {
93  operator= (a);
94 }
95 template<class T>
96 inline
99 {
100  return _x(i,j);
101 }
102 template<class T>
103 inline
104 const tensor_basic<T>&
106 {
107  return _x(i,j);
108 }
109 template<class T>
110 inline
111 T&
113 {
114  return _x(i,j)(k,l);
115 }
116 template<class T>
117 inline
118 const T&
120 {
121  return _x(i,j)(k,l);
122 }
123 template <class T>
124 inline
126 operator* (const T& k, const tensor4_basic<T>& a)
127 {
128  tensor4_basic<T> b = a;
129  b *= k;
130  return b;
131 }
132 template <class T>
133 inline
134 tensor4_basic<T>
135 operator* (const tensor4_basic<T>& a, const T& k)
136 {
137  return k*a;
138 }
139 template <class T>
140 inline
141 tensor4_basic<T>
142 operator/ (const tensor4_basic<T>& a, const T& k)
143 {
144  return (1./k)/a;
145 }
146 // inputs/outputs:
147 #ifdef TODO
148 template<class T>
149 inline
150 std::istream& operator>> (std::istream& in, tensor4_basic<T>& a)
151 {
152  return a.get (in);
153 }
154 #endif // TODO
155 template<class T>
156 inline
157 std::ostream& operator<< (std::ostream& out, const tensor4_basic<T>& a)
158 {
159  return a.put (out);
160 }
161 
162 }// namespace rheolef
163 # endif /* _RHEOLEF_TENSOR4_H */
tensor_basic< tensor_basic< T > > _x
Definition: tensor4.h:57
static tensor4_basic< T > eye(size_type d=3)
Definition: tensor4.cc:8
irheostream, orheostream - large data streams
Definition: compiler.h:7
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
Definition: csr.h:367
T norm2(const vec< T, M > &x)
Definition: vec_expr.h:319
T norm(const vec< T, M > &x)
Definition: vec_expr.h:326
dia< T, M > operator/(const T &lambda, const dia< T, M > &d)
Definition: dia.h:118
size_t d
T ddot(const tensor_basic< T > &a, const tensor_basic< T > &b)
Definition: tensor.cc:200
field_nonlinear_expr< field_nonlinear_expr_uf< details::sqrt_,field_expr_terminal_field< T, M > > > sqrt(const field_basic< T, M > &x)
tensor4_basic< T > & operator=(const tensor4_basic< T > &a)
Definition: tensor4.cc:103
tensor4_basic< T > & operator/=(const T &k)
Definition: tensor4.h:50
tensor4_basic< T > operator-(const tensor4_basic< T > &b) const
Definition: tensor4.cc:139
tensor4_basic< T > dexp(const tensor_basic< T > &chi, size_t dim)
Definition: tensor4-dexp.cc:9
T & operator()(size_type i, size_type j, size_type k, size_type l)
Definition: tensor4.h:112
helper for point_basic & tensor_basic: get basic T type
Definition: point.h:247
std::ostream & put(std::ostream &out, size_type d=3) const
Definition: tensor4.cc:165
tensor4_basic< T > operator+(const tensor4_basic< T > &b) const
Definition: tensor4.cc:126
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:48
tensor4_basic< Float > tensor4
Definition: tensor4.h:59
tensor4_basic< T > & operator*=(const T &k)
Definition: tensor4.cc:115