rheolef  7.0
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); }
51  tensor4_basic<T> operator* (const T& k) const;
52  tensor4_basic<T> operator/ (const T& k) const;
55 
56  std::ostream& put (std::ostream& out, size_type d=3) const;
57 
58 protected:
60 };
62 
63 template <class T>
64 T norm2 (const tensor4_basic<T>&);
65 template <class T>
66 T norm (const tensor4_basic<T>& a) { return sqrt(norm2(a)); }
67 template <class T>
68 tensor4_basic<T> dexp (const tensor_basic<T>& a, size_t d = 3);
69 
70 template <class T>
72 template <class T>
74 @endcode
75 template<class T> struct float_traits<tensor4_basic<T> > { typedef typename float_traits<T>::type type; };
76 template<class T> struct scalar_traits<tensor4_basic<T> > { typedef T type; };
77 
78 template<class T>
79 inline
81  : _x (tensor_basic<T>(T()))
82 {
83 }
84 template<class T>
85 inline
87  : _x (tensor_basic<T>(init_val))
88 {
89 }
90 template<class T>
91 inline
93  : _x (tensor_basic<T>(T()))
94 {
95  operator= (a);
96 }
97 template<class T>
98 inline
101 {
102  return _x(i,j);
103 }
104 template<class T>
105 inline
106 const tensor_basic<T>&
108 {
109  return _x(i,j);
110 }
111 template<class T>
112 inline
113 T&
115 {
116  return _x(i,j)(k,l);
117 }
118 template<class T>
119 inline
120 const T&
122 {
123  return _x(i,j)(k,l);
124 }
125 template <class T>
126 inline
129 {
130  tensor4_basic<T> b = *this;
131  b *= k;
132  return b;
133 }
134 template <class T, class U>
135 inline
136 typename
137 std::enable_if<
140 >::type
141 operator* (const U& k, const tensor4_basic<T>& a)
142 {
143  return a*k;
144 }
145 template <class T>
146 inline
149 {
150  return operator* (1./k);
151 }
152 // inputs/outputs:
153 #ifdef TODO
154 template<class T>
155 inline
156 std::istream& operator>> (std::istream& in, tensor4_basic<T>& a)
157 {
158  return a.get (in);
159 }
160 #endif // TODO
161 template<class T>
162 inline
163 std::ostream& operator<< (std::ostream& out, const tensor4_basic<T>& a)
164 {
165  return a.put (out);
166 }
167 
168 }// namespace rheolef
169 # endif /* _RHEOLEF_TENSOR4_H */
tensor4_basic< T > operator*(const T &k) const
Definition: tensor4.h:128
tensor_basic< tensor_basic< T > > _x
Definition: tensor4.h:59
static tensor4_basic< T > eye(size_type d=3)
Definition: tensor4.cc:8
irheostream, orheostream - large data streams
Definition: compiler.h:7
T norm2(const vec< T, M > &x)
Definition: vec.h:334
T norm(const vec< T, M > &x)
Definition: vec.h:341
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:211
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:126
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:114
helper for point_basic<T> & tensor_basic<T>: get basic T type
Definition: point.h:234
tensor4_basic< T > operator-(const tensor4_basic< T > &b) const
Definition: tensor4.cc:139
return a operator*(xh)
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:48
rheolef::std type
tensor4_basic< Float > tensor4
Definition: tensor4.h:61
tensor4_basic< T > & operator*=(const T &k)
Definition: tensor4.cc:115
tensor4_basic< T > operator/(const T &k) const
Definition: tensor4.h:148
std::ostream & put(std::ostream &out, size_type d=3) const
Definition: tensor4.cc:165