22#include "rheolef/tensor4.h"
32 for (
size_t i = 0; i <
d; i++)
33 for (
size_t j = 0; j <
d; j++) a(i,j,i,j) = 1;
47 y(i,j) += a(i,j,k,l)*x(k,l);
60 x(k,l) += y(i,j)*a(i,j,k,l);
65 const std::initializer_list<std::initializer_list<
66 std::initializer_list<std::initializer_list<T> > > >& il)
69 typedef std::initializer_list<T> L1;
70 typedef std::initializer_list<L1> L2;
71 typedef std::initializer_list<L2> L3;
72 typedef std::initializer_list<L3> L4;
73 typedef typename std::initializer_list<L4>::const_iterator
const_iterator;
74 typedef typename std::initializer_list<L3>::const_iterator const_iterator_row3;
75 typedef typename std::initializer_list<L2>::const_iterator const_iterator_row2;
76 typedef typename std::initializer_list<L1>::const_iterator const_iterator_row1;
77 typedef typename std::initializer_list<T>::const_iterator const_iterator_elt;
79 check_macro (il.size() <= 3,
"unexpected initializer list size=" << il.size() <<
" > 3");
81 for (const_iterator_row3 iter = il.begin(); iter != il.end(); ++iter, ++i) {
82 const L3& row3 = *iter;
83 check_macro (row3.size() <= 3,
"unexpected initializer list size=" << row3.size() <<
" > 3");
85 for (const_iterator_row2 jter = row3.begin(); jter != row3.end(); ++jter, ++j) {
86 const L2& row2 = *jter;
87 check_macro (row2.size() <= 3,
"unexpected initializer list size=" << row2.size() <<
" > 3");
89 for (const_iterator_row1 kter = row2.begin(); kter != row2.end(); ++kter, ++k) {
90 const L1& row1 = *kter;
91 check_macro (row1.size() <= 3,
"unexpected initializer list size=" << row1.size() <<
" > 3");
93 for (const_iterator_elt lter = row1.begin(); lter != row1.end(); ++lter, ++l) {
109 operator() (i,j,k,l) = val;
120 operator() (i,j,k,l) = a(i,j,k,l);
133 c(i,j,k,l) =
operator() (i,j,k,l) + b(i,j,k,l);
146 c(i,j,k,l) =
operator() (i,j,k,l) - b(i,j,k,l);
157 operator() (i,j,k,l) += b(i,j,k,l);
168 operator() (i,j,k,l) -= b(i,j,k,l);
179 operator() (i,j,k,l) *= fact;
192 sum += sqr(a(i,j,k,l));
203 case 1 :
return out << _x(0,0)(0,0);
204 case 2 :
return out <<
"[[" << _x(0,0)(0,0) <<
", " << _x(0,0)(0,1) <<
";" << endl
205 <<
" " << _x(0,0)(1,0) <<
", " << _x(0,0)(1,1) <<
"]," << endl
206 <<
" [" << _x(0,1)(0,0) <<
", " << _x(0,1)(0,1) <<
";" << endl
207 <<
" " << _x(0,1)(1,0) <<
", " << _x(0,1)(1,1) <<
"];" << endl
208 <<
" [" << _x(1,0)(0,0) <<
", " << _x(1,0)(0,1) <<
";" << endl
209 <<
" " << _x(1,0)(1,0) <<
", " << _x(1,0)(1,1) <<
"]," << endl
210 <<
" [" << _x(1,1)(0,0) <<
", " << _x(1,1)(0,1) <<
";" << endl
211 <<
" " << _x(1,1)(1,0) <<
", " << _x(1,1)(1,1) <<
"]]" << endl;
212 default:
fatal_macro(
"put(d="<<
d<<
"): not yet, sorry");
return out;
218#define _RHEOLEF_instanciation(T) \
219template class tensor4_basic<T>; \
220template tensor_basic<T> ddot (const tensor4_basic<T>&, const tensor_basic<T>&); \
221template tensor_basic<T> ddot (const tensor_basic<T>&, const tensor4_basic<T>&); \
222template T norm2 (const tensor4_basic<T>&);
#define _RHEOLEF_instanciation(T, M, A)
field::size_type size_type
see the Float page for the full documentation
std::ostream & put(std::ostream &out, size_type d=3) const
tensor4_basic< T > operator+(const tensor4_basic< T > &b) const
tensor4_basic< T > operator-(const tensor4_basic< T > &b) const
tensor4_basic< T > & operator-=(const tensor4_basic< T > &)
tensor4_basic< T > & operator+=(const tensor4_basic< T > &)
tensor4_basic< T > & operator*=(const T &k)
tensor4_basic< T > & operator=(const tensor4_basic< T > &a)
static tensor4_basic< T > eye(size_type d=3)
T & operator()(size_type i, size_type j, size_type k, size_type l)
#define fatal_macro(message)
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
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
T norm2(const vec< T, M > &x)
norm2(x): see the expression page for the full documentation
t operator()(const t &a, const t &b)