Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
tensor4.h
Go to the documentation of this file.
1# ifndef _RHEOLEF_TENSOR4_H
2# define _RHEOLEF_TENSOR4_H
3//
4// This file is part of Rheolef.
5//
6// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7//
8// Rheolef is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 2 of the License, or
11// (at your option) any later version.
12//
13// Rheolef is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with Rheolef; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// =========================================================================
23
24namespace rheolef {
72} // namespace rheolef
73
74#include "rheolef/point.h"
75#include "rheolef/tensor.h"
76namespace rheolef {
77
78// [verbatim_tensor4_basic]
79template<class T>
81public:
82
83 typedef size_t size_type;
84 typedef T element_type;
85 typedef T float_type;
86
87// allocators:
88
90 explicit tensor4_basic (const T& init_val);
92 static tensor4_basic<T> eye (size_type d = 3);
93
94 tensor4_basic (const std::initializer_list<std::initializer_list<
95 std::initializer_list<std::initializer_list<T> > > >& il);
96
97// affectation:
98
100 tensor4_basic<T>& operator= (const T& val);
101
102// accessors:
103
105 const T& operator()(size_type i, size_type j, size_type k, size_type l) const;
106
109
110// algebra:
111
112 tensor4_basic<T> operator* (const T& k) const;
113 tensor4_basic<T> operator/ (const T& k) const;
118 tensor4_basic<T>& operator*= (const T& k);
119 tensor4_basic<T>& operator/= (const T& k) { return operator*= (1./k); }
120
121// io:
122 std::ostream& put (std::ostream& out, size_type d=3) const;
123// [verbatim_tensor4_basic]
124
125// data:
126protected:
128// [verbatim_tensor4_basic_cont]
129};
130// [verbatim_tensor4_basic_cont]
131
132// [verbatim_tensor4]
134// [verbatim_tensor4]
135
136// [verbatim_tensor4_basic_cont2]
137template <class T>
138T norm (const tensor4_basic<T>& a) { return sqrt(norm2(a)); }
139
140template <class T>
141T norm2 (const tensor4_basic<T>&);
142
143template <class T>
144tensor_basic<T> ddot (const tensor4_basic<T>&, const tensor_basic<T>&);
145
146template <class T>
147tensor_basic<T> ddot (const tensor_basic<T>&, const tensor4_basic<T>&);
148
149template <class T>
150tensor4_basic<T> dexp (const tensor_basic<T>& a, size_t d = 3);
151// [verbatim_tensor4_basic_cont2]
152// -----------------------------------------------------------------------
153// inlined
154// -----------------------------------------------------------------------
155template<class T> struct float_traits<tensor4_basic<T> > { typedef typename float_traits<T>::type type; };
156template<class T> struct scalar_traits<tensor4_basic<T> > { typedef T type; };
157
158template<class T>
159inline
164template<class T>
165inline
167 : _x (tensor_basic<T>(init_val))
168{
169}
170template<class T>
171inline
173 : _x (tensor_basic<T>(T()))
174{
175 operator= (a);
176}
177template<class T>
178inline
181{
182 return _x(i,j);
183}
184template<class T>
185inline
186const tensor_basic<T>&
188{
189 return _x(i,j);
190}
191template<class T>
192inline
193T&
195{
196 return _x(i,j)(k,l);
197}
198template<class T>
199inline
200const T&
202{
203 return _x(i,j)(k,l);
204}
205template <class T>
206inline
209{
210 tensor4_basic<T> b = *this;
211 b *= k;
212 return b;
213}
214template <class T, class U>
215inline
216typename
217std::enable_if<
218 details::is_rheolef_arithmetic<U>::value
220>::type
221operator* (const U& k, const tensor4_basic<T>& a)
222{
223 return a*k;
224}
225template <class T>
226inline
227tensor4_basic<T>
229{
230 return operator* (1./k);
231}
232// inputs/outputs:
233#ifdef TODO
234template<class T>
235inline
236std::istream& operator>> (std::istream& in, tensor4_basic<T>& a)
237{
238 return a.get (in);
239}
240#endif // TODO
241template<class T>
242inline
243std::ostream& operator<< (std::ostream& out, const tensor4_basic<T>& a)
244{
245 return a.put (out);
246}
247
248}// namespace rheolef
249# endif /* _RHEOLEF_TENSOR4_H */
field::size_type size_type
Definition branch.cc:430
std::ostream & put(std::ostream &out, size_type d=3) const
Definition tensor4.cc:198
tensor4_basic< T > operator+(const tensor4_basic< T > &b) const
Definition tensor4.cc:125
tensor4_basic< T > operator-(const tensor4_basic< T > &b) const
Definition tensor4.cc:138
tensor_basic< tensor_basic< T > > _x
Definition tensor4.h:127
tensor4_basic< T > & operator-=(const tensor4_basic< T > &)
Definition tensor4.cc:162
tensor4_basic< T > & operator/=(const T &k)
Definition tensor4.h:119
tensor4_basic< T > & operator+=(const tensor4_basic< T > &)
Definition tensor4.cc:151
tensor4_basic< T > operator*(const T &k) const
Definition tensor4.h:208
tensor4_basic< T > & operator*=(const T &k)
Definition tensor4.cc:173
tensor4_basic< T > & operator=(const tensor4_basic< T > &a)
Definition tensor4.cc:114
tensor4_basic< T > operator/(const T &k) const
Definition tensor4.h:228
T & operator()(size_type i, size_type j, size_type k, size_type l)
Definition tensor4.h:194
tensor4_basic< Float > tensor4
Definition tensor4.h:133
Expr1::float_type T
Definition field_expr.h:230
This file is part of Rheolef.
T ddot(const tensor_basic< T > &a, const tensor_basic< T > &b)
ddot(x,y): see the expression page for the full documentation
Definition tensor.cc:278
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition catchmark.h:99
T norm2(const vec< T, M > &x)
norm2(x): see the expression page for the full documentation
Definition vec.h:379
solver_basic< Float > eye()
see the eye page for the full documentation
Definition eye.h:74
tensor4_basic< T > dexp(const tensor_basic< T > &chi, size_t dim)
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition catchmark.h:88
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
Definition csr.h:437
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
Definition vec.h:387
helper for std::complex<T>: get basic T type
Definition Float.h:93
helper for point_basic<T> & tensor_basic<T>: get basic T type
Definition point.h:323