34 #include <boost/mpl/vector.hpp>
35 #include <boost/numeric/ublas/matrix.hpp>
36 #include <boost/numeric/ublas/matrix_proxy.hpp>
37 #include <boost/numeric/ublas/vector.hpp>
39 #include <boost/mpl/if.hpp>
40 #include <boost/mpl/find.hpp>
42 #include <feel/feelcore/feel.hpp>
46 namespace ublas = boost::numeric::ublas;
50 enum transformation_type { LINEAR, BILINEAR, NONLINEAR };
58 template<u
int16_type Dim>
61 static const uint16_type rank = 0;
62 static const uint16_type nDim = Dim;
64 static const bool is_scalar =
true;
65 static const bool is_vectorial =
false;
66 static const bool is_tensor2 =
false;
67 static const bool is_tensor3 =
false;
69 static const uint16_type nComponents = 1;
70 static const uint16_type nComponents1 = 1;
71 static const uint16_type nComponents2 = 1;
72 static const uint16_type nComponents3 = 1;
73 static const uint16_type nComponentsLast = 1;
77 inline ublas::matrix<T>
const&
78 toMatrix( ublas::matrix<T>
const& __c )
84 inline ublas::matrix<T>
const&
85 toType( ublas::matrix<T>
const& __c )
97 template<u
int16_type Dim>
100 static const uint16_type rank = 1;
101 static const uint16_type nDim = Dim;
103 static const bool is_scalar =
false;
104 static const bool is_vectorial =
true;
105 static const bool is_tensor2 =
false;
106 static const bool is_tensor3 =
false;
108 static const uint16_type nComponents = nDim;
109 static const uint16_type nComponents1 = nDim;
110 static const uint16_type nComponents2 = 1;
111 static const uint16_type nComponents3 = 1;
112 static const uint16_type nComponentsLast = nComponents1;
116 toMatrix( ublas::matrix<T>
const& __c )
118 typedef T value_type;
120 const size_type nRows = __c.size1()/nComponents;
122 ublas::matrix<T> __c_reshaped( ublas::zero_matrix<value_type>( nRows, nComponents*nCols ) );
124 for (
int c = 0; c < nComponents; ++c )
127 ublas::range( 0, nRows ),
129 ublas::slice( c, nComponents, nRows ),
130 ublas::slice( 0, 1, nCols ) );
136 template<
typename AE>
138 ublas::matrix<typename ublas::matrix_expression<AE>::value_type>
139 toType( ublas::matrix_expression<AE>
const& __c )
141 typedef typename ublas::matrix_expression<AE>::value_type value_type;
144 const size_type nRows = __c().size1()*nComponents;
145 const size_type nCols = __c().size2()/nComponents;
146 ublas::matrix<value_type> __c_reshaped( ublas::zero_matrix<value_type>( nRows, nCols ) );
148 for (
int c = 0; c < nComponents; ++c )
151 ublas::slice( c, nComponents, nRows/nComponents ),
153 ublas::range( 0, nRows/nComponents ),
154 ublas::range( c*nCols, ( c+1 )*nCols ) );
163 toType( ublas::matrix<T>
const& __c )
165 typedef T value_type;
168 const size_type nRows = __c.size1()*nComponents;
169 const size_type nCols = __c.size2()/nComponents;
170 ublas::matrix<value_type> __c_reshaped( ublas::zero_matrix<value_type>( nRows, nCols ) );
172 for (
int c = 0; c < nComponents; ++c )
175 ublas::slice( c, nComponents, nRows/nComponents ),
177 ublas::range( 0, nRows/nComponents ),
178 ublas::range( c*nCols, ( c+1 )*nCols ) );
191 template<u
int16_type N, u
int16_type M>
194 static const uint16_type rank = ( M > 1 );
195 static const uint16_type nDim = N;
196 static const uint16_type nVariables = N;
198 static const bool is_scalar = ( M==1 );
199 static const bool is_vectorial = ( N==M );
200 static const bool is_tensor2 =
false;
201 static const bool is_tensor3 =
false;
203 static const uint16_type nComponents = M;
204 static const uint16_type nComponents1 = M;
205 static const uint16_type nComponents2 = 1;
206 static const uint16_type nComponents3 = 1;
207 static const uint16_type nComponentsLast = 1;
211 inline ublas::matrix<T>
const&
212 toMatrix( ublas::matrix<T>
const& __c )
218 inline ublas::matrix<T>
const&
219 toType( ublas::matrix<T>
const& __c )
226 template<u
int16_type M>
229 template <u
int16_type Nvar>
232 typedef detail::Field<Nvar,M> type;
241 template<u
int16_type Dim>
244 static const uint16_type rank = 2;
245 static const uint16_type nDim = Dim;
247 static const bool is_scalar =
false;
248 static const bool is_vectorial =
false;
249 static const bool is_tensor2 =
true;
250 static const bool is_tensor3 =
false;
252 static const uint16_type nComponents = nDim*nDim;
253 static const uint16_type nComponents1 = nDim;
254 static const uint16_type nComponents2 = nDim;
255 static const uint16_type nComponents3 = 1;
256 static const uint16_type nComponentsLast = nComponents2;
261 toMatrix( ublas::matrix<T>
const& __c )
263 typedef T value_type;
266 const size_type nRows1= __c.size2()*nComponents;
268 ublas::matrix<T> __c_reshaped( nRows/nComponents, nCols*nComponents );
271 for (
int c1 = 0; c1 < nComponents; ++c1 )
273 uint16_type i1 = nRows1*c1;
275 for (
int c2 = 0; c2 < nComponents; ++c2 )
278 ublas::range( i1/nComponents, ( i1+nRows1 )/nComponents ),
280 ublas::slice( i1+c2, nComponents, nRows1/nComponents ),
281 ublas::slice( 0, 1, nCols ) );
288 template<
typename AE>
290 ublas::matrix<typename ublas::matrix_expression<AE>::value_type>
291 toType( ublas::matrix_expression<AE>
const& __c )
299 toType( ublas::matrix<T>
const& __c )
301 typedef T value_type;
303 const size_type nRows = __c.size1()*nComponents;
305 const size_type nCols = __c.size2()/nComponents;
306 ublas::matrix<T> __c_reshaped( nRows, nCols );
309 for (
int c1 = 0; c1 < nComponents; ++c1 )
311 uint16_type i1 = nRows1*c1;
313 for (
int c2 = 0; c2 < nComponents; ++c2 )
316 ublas::slice( i1+c2, nComponents, nRows1/nComponents ),
318 ublas::range( i1/nComponents, ( i1+nRows1 )/nComponents ),
319 ublas::range( c2*nCols, ( c2+1 )*nCols ) );
332 template<u
int16_type Dim>
335 static const uint16_type rank = 3;
336 static const uint16_type nDim = Dim;
338 static const bool is_scalar =
false;
339 static const bool is_vectorial =
false;
340 static const bool is_tensor2 =
false;
341 static const bool is_tensor3 =
true;
343 static const uint16_type nComponents = nDim*nDim*nDim;
344 static const uint16_type nComponents1 = nDim;
345 static const uint16_type nComponents2 = nDim;
346 static const uint16_type nComponents3 = nDim;
347 static const uint16_type nComponentsLast = nComponents3;
351 struct ListReturnTypes
355 template<
typename T1,
typename T2>
358 typedef typename mpl::if_<boost::is_same<T1, T2>,
360 typename mpl::if_<mpl::greater<mpl::int_<T1::rank>, mpl::int_<T2::rank> >,
362 mpl::identity<T2> >::type>::type::type type;
368 COMPONENT_IN_COMPONENT,
369 GLOBAL_FUNCTION_INDEX,
370 PER_COMPONENT_FUNCTION_INDEX,
371 COMPONENT_IN_COMPONENT_FUNCTION_INDEX,
375 const mpl::int_<GLOBAL_COMPONENT> INDEX_GLOBAL_COMPONENT = mpl::int_<GLOBAL_COMPONENT>();
376 const mpl::int_<COMPONENT_IN_COMPONENT> INDEX_COMPONENT_IN_COMPONENT = mpl::int_<COMPONENT_IN_COMPONENT>() ;
377 const mpl::int_<GLOBAL_FUNCTION_INDEX> INDEX_GLOBAL_FUNCTION_INDEX = mpl::int_<GLOBAL_FUNCTION_INDEX>();
378 const mpl::int_<PER_COMPONENT_FUNCTION_INDEX> INDEX_PER_COMPONENT_FUNCTION_INDEX = mpl::int_<PER_COMPONENT_FUNCTION_INDEX>();
379 const mpl::int_<COMPONENT_IN_COMPONENT_FUNCTION_INDEX> INDEX_COMPONENT_IN_COMPONENT_FUNCTION_INDEX = mpl::int_<COMPONENT_IN_COMPONENT_FUNCTION_INDEX>();
380 const mpl::int_<FUNCTION_INDEX> INDEX_FUNCTION_INDEX = mpl::int_<FUNCTION_INDEX>();
392 static const uint16_type nDim = T::nDim;
395 typedef typename mpl::find<types, T>::type iter;
396 typedef typename mpl::if_<boost::is_same<T, Scalar<nDim> >,
397 mpl::identity<Scalar<nDim> >,
398 mpl::identity<typename mpl::deref<typename mpl::prior<iter>::type>::type> >::type::type type;
400 typedef typename mpl::if_<boost::is_same<T, Scalar<nDim> >,
401 mpl::identity<Scalar<nDim> >,
402 typename mpl::if_<boost::is_same<T, Vectorial<nDim> >,
403 mpl::identity<Vectorial<nDim> >,
404 typename mpl::if_<boost::is_same<T, Tensor2<nDim> >,
405 mpl::identity<Tensor2<nDim> > >::type>::type>::type::type type;
419 static const uint16_type nDim = T::nDim;
421 typedef typename mpl::find<types, T>::type iter;
422 typedef typename mpl::deref<typename mpl::next<iter>::type>::type type;
428 static const uint16_type nDim = T::nDim;
430 typedef typename mpl::find<types, T>::type iter;
431 typedef typename mpl::deref<typename mpl::next<typename mpl::next<iter>::type>::type>::type type;
437 static const uint16_type nDim = T::nDim;
444 static const uint16_type nDim = T::nDim;
445 typedef mpl::vector<Scalar<nDim>, Vectorial<nDim>, Tensor2<nDim>, Tensor3<nDim> > types;
446 typedef typename mpl::find<types, T>::type iter;
447 typedef typename mpl::deref<typename mpl::prior<iter>::type>::type _type;
448 typedef typename mpl::if_<boost::is_same<_type,mpl::void_>,
449 mpl::identity<Scalar<nDim> >,
450 mpl::identity<_type> >::type::type type;
457 template<
bool normalized>
460 static const bool is_normalized = normalized;
471 typedef T value_type;
472 typedef ublas::vector<value_type> vector_type;
473 typedef ublas::matrix<value_type> matrix_type;
474 typedef ublas::vector<matrix_type> vector_matrix_type;
475 typedef ublas::vector<vector_matrix_type> vector_vector_matrix_type;
Definition: feelpoly/policy.hpp:458
Polynomial< Pset, Scalar > project(Pset const &pset, Func const &f, IM const &im)
Definition: operations.hpp:436
Definition: feelpoly/policy.hpp:98
Definition: feelpoly/policy.hpp:390
Definition: feelpoly/policy.hpp:417
Definition: feelpoly/policy.hpp:469
Definition: feelpoly/policy.hpp:59
Definition: feelpoly/policy.hpp:333
size_t size_type
Indices (starting from 0)
Definition: feelcore/feel.hpp:319
Definition: feelpoly/policy.hpp:242