Rheolef  7.2
an efficient C++ finite element environment
expression.h
Go to the documentation of this file.
1 #ifndef _RHEOLEF_EXPRESSION_H
2 #define _RHEOLEF_EXPRESSION_H
3 //
4 // This file is part of Rheolef.
5 //
6 // Copyright (C) 2000-2009 Pierre Saramito
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 // author: Pierre.Saramito@imag.fr
24 // date: 25 march 2013
25 
26 
27 namespace rheolef {
129 } // namespace rheolef
130 
131 /*
132 This file "expression.h" focuses on operators between fields
133 since the field return value (scalar,vector,tensor) is not known
134 at compile time, operators try to infer it when the return type
135 or a second argument is known at compile time
136 
137 optherwise, the return value is undeterminated_basic<T> that
138 will be solved at run time from the field::valued_tag() method.
139 
140 OVERVIEW:
141  0. error utilities
142  1. unary operations
143  1.1. unary function helper
144  1.2. unary operators: +x -x
145  1.3. unary standard maths: sin(x), cos(x), ...
146  1.4. unary extensions: tr(x), trans(x), norm(x) norm2(x)
147  2. binary operations
148  2.1. binary function helper
149  2.2. binary operators: x+y, x-y, x*y, x/y
150  2.3. binary standard maths: pow(x,y), atan2(x,y),...
151  2.4. binary extensions: dot(x,y), ddot(x,y), dddot(x,y)
152  3. binders
153  3.1. binder_first
154  3.2. binder_second
155  3.3. swapper
156 */
157 #include "rheolef/promote.h"
158 #include "rheolef/undeterminated.h"
159 #include "rheolef/space_constant.h"
160 
161 namespace rheolef { namespace details {
162 
163 // ===========================================================================
164 // part 0. error utilities
165 // ===========================================================================
166 template<class Op, class T1, class T2, class R>
167 struct binop_error {};
168 
169 template <class T> struct is_error: std::false_type {};
170 
171 template<class Op, class T1, class T2, class R>
172 struct is_error<binop_error<Op,T1,T2,R> >: std::true_type {};
173 
174 } // namespace details
175 
176 template<class Op, class T1, class T2, class R>
177 struct float_traits<details::binop_error<Op,T1,T2,R> > { typedef typename float_traits<R>::type type; };
178 
179 // ===========================================================================
180 // part 1. unary operations
181 // ===========================================================================
182 namespace details {
183 // ---------------------------------------------------------------------------
184 // chap 1.1. unary function helper
185 // ---------------------------------------------------------------------------
186 // defualt is STL class-functions
187 template<class Function>
189  template <class Arg>
190  struct result_hint {
192  };
193  template <class Arg, class Result>
194  struct hint {
196  typedef typename std::decay<typename function_traits<Function>::template arg<0>::type>::type
198  };
202  }
203 };
204 // ----------------------------------------------------------------------------
205 // chap 1.2. unary operators: +x -x
206 // ----------------------------------------------------------------------------
207 // +x
208 // ------
209 struct unary_plus {
210  template <class T> T operator() (const T& a) const { return +a; }
211 };
212 template<>
214  template <class Arg>
215  struct result_hint {
216  typedef Arg type;
217  };
218  template <class Arg, class Result>
219  struct hint {
222  };
225  return tag;
226  }
227 };
228 // ------
229 // -x
230 // ------
231 struct negate {
232  template <class T> T operator() (const T& a) const { return -a; }
233 };
234 template<>
236  template <class Arg>
237  struct result_hint {
238  typedef Arg type;
239  };
240  template <class Arg, class Result>
241  struct hint {
244  };
247  return tag;
248  }
249 };
250 // ----------------------------------------------------------------------------
251 // chap 1.3. unary standard maths: sin(x), cos(x), ...
252 // ----------------------------------------------------------------------------
253 // specialization for is scalar generic functions, as details::sin_, details::cos_, etc
254 #define _RHEOLEF_generic_unary_scalar(F) \
255 struct F##_ { \
256  template<class T> \
257  T operator() (const T& x) const { return F(x); } \
258 }; \
259 template<> \
260 struct generic_unary_traits<F##_> { \
261  template <class Arg> \
262  struct result_hint { \
263  typedef typename scalar_traits<Arg>::type type; \
264  }; \
265  template <class Arg, class Result> \
266  struct hint { \
267  typedef typename promote< \
268  typename scalar_traits<Arg>::type \
269  ,typename scalar_traits<Result>::type>::type S; \
270  typedef S result_type; \
271  typedef S argument_type; \
272  }; \
273  static space_constant::valued_type \
274  valued_tag (space_constant::valued_type) { \
275  return space_constant::scalar; \
276  } \
277 };
278 // std::cmath
296 // rheolef extension:
298 #undef _RHEOLEF_generic_unary_scalar
299 // ----------------------------------------------------------------------------
300 // chap 1.4. unary extensions: tr(x), norm(x) norm2(x)
301 // ----------------------------------------------------------------------------
302 // tr(tau)
303 // ----------
304 struct tr_ {
305  template <class T> T operator() (const tensor_basic<T>& a) const { return tr(a); }
306 };
307 template<>
308 struct generic_unary_traits<tr_> {
309  template <class A1>
310  struct result_hint {
311  typedef typename scalar_traits<A1>::type type;
312  };
313  template <class A1, class R>
314  struct hint {
317  };
320  return space_constant::scalar;
321  }
322 };
323 // ----------
324 // trans(tau)
325 // ----------
326 struct trans_ {
327  template <class T> tensor_basic<T> operator() (const tensor_basic<T>& a) const { return trans(a); }
328 };
329 template<>
331  template <class A1>
332  struct result_hint {
334  };
335  template <class A1, class R>
336  struct hint {
340  };
344  }
345 };
346 // ----------
347 // norm(x)
348 // ----------
349 struct norm_ {
350  template<class T>
351  typename float_traits<T>::type operator() (const T& x) const { return fabs(x); }
352  template<class T>
353  typename float_traits<T>::type operator() (const point_basic<T>& x) const { return norm(x); }
354  template<class T>
355  typename float_traits<T>::type operator() (const tensor_basic<T>& x) const { return norm(x); }
356 };
357 template<>
359  template <class Arg>
360  struct result_hint {
361  typedef typename float_traits<Arg>::type type;
362  };
363  template <class A1, class R>
364  struct hint {
366  typedef A1 argument_type;
367  };
370  return space_constant::scalar;
371  }
372 };
373 // ----------
374 // norm2(x)
375 // ----------
376 struct norm2_ {
377  template<class T>
378  typename float_traits<T>::type operator() (const T& x) const { return sqr(x); }
379  template<class T>
380  typename float_traits<T>::type operator() (const point_basic<T>& x) const { return norm2(x); }
381  template<class T>
382  typename float_traits<T>::type operator() (const tensor_basic<T>& x) const { return norm2(x); }
383 };
384 template<>
386  template <class Arg>
387  struct result_hint {
388  typedef typename float_traits<Arg>::type type;
389  };
390  template <class A1, class R>
391  struct hint {
393  typedef A1 argument_type;
394  };
397  return space_constant::scalar;
398  }
399 };
400 // ===========================================================================
401 // part 2. binary operations
402 // ===========================================================================
403 // ---------------------------------------------------------------------------
404 // chap 2.1. binary function helper
405 // ---------------------------------------------------------------------------
406 template<class Function>
408  template <class Arg1, class Arg2>
409  struct result_hint {
411  };
412  template <class Arg1, class Arg2, class Result>
413  struct hint {
414  typedef typename std::decay<typename function_traits<Function>::template arg<0>::type>::type
416  typedef typename std::decay<typename function_traits<Function>::template arg<1>::type>::type
418  typedef typename std::decay<typename function_traits<Function>::result_type>::type
420  };
424  }
425 };
426 // ----------------------------------------------------------------------------
427 // chap 2.2. binary operators: x+y, x-y, x*y, x/y
428 // ----------------------------------------------------------------------------
429 // x+y
430 // --------
431 struct plus; // foward declaration
432 
433 // result type
434 // -----------
435 template <class A1, class A2, class Sfinae = void>
436 struct plus_result {
438 };
439 // s+s -> s
440 template <class A1, class A2>
441 struct plus_result<A1,A2,
442  typename std::enable_if<
443  is_rheolef_arithmetic<A1>::value &&
444  is_rheolef_arithmetic<A2>::value
445  >::type>
446 {
447  typedef typename promote<A1,A2>::type type;
448 };
449 // v+v -> v, t+t -> t
450 template <class A>
451 struct plus_result<A,A,
452  typename std::enable_if<
453  ! is_rheolef_arithmetic<A>::value>::type>
454 {
455  typedef A type;
456 };
457 struct plus {
458  template <class T1, class T2>
459  typename plus_result<T1,T2>::type operator() (const T1& a, const T2& b) const { return a+b; }
460 };
461 template<>
463  // --------------------------
464  // hint interface
465  // --------------------------
466  template <class A1, class A2, class R>
467  struct hint {
470  typedef R result_type;
471  };
472  // two types are known
473  // --------------------------
474  // a1+a2 -> ? : deduce r
475  template <class A1, class A2, class R>
476  struct hint<A1,A2,undeterminated_basic<R> > {
480  };
481  // ?+a2 -> r : deduce a1
482  template <class A1, class A2, class R>
483  struct hint<undeterminated_basic<A1>,A2,R> {
484  typedef typename std::conditional<
486  R,
490  typedef R result_type;
491  };
492  // a1+? -> r : deduce a2
493  template <class A1, class A2, class R>
494  struct hint<A1,undeterminated_basic<A2>,R> {
496  typedef typename std::conditional<
498  R,
501  typedef R result_type;
502  };
503  // ?+? -> r : deduce a1,a2
504  template <class A1, class A2, class R>
508  typedef R result_type;
509  };
510  // a1+? -> ? : deduce a2,r
511  template <class A1, class A2, class R>
512  struct hint<A1,undeterminated_basic<A2>,undeterminated_basic<R> > {
515  typedef A1 result_type;
516  };
517  // ?+a2 -> ? : deduce a2,r
518  template <class A1, class A2, class R>
519  struct hint<undeterminated_basic<A1>,A2, undeterminated_basic<R> > {
522  typedef A2 result_type;
523  };
524  // ?+? -> ? : deduce a1, a2,r
525  template <class A1, class A2, class R>
530  };
533  return (tag2 == space_constant::last_valued) ? tag1 : tag2;
534  }
535  typedef std::true_type is_symmetric;
536  template <class Arg1, class Arg2>
537  struct result_hint {
538  typedef typename hint<Arg1,Arg2,undeterminated_basic<Float> >::result_type type;
539  };
540 };
541 // --------
542 // x-y
543 // --------
544 struct minus {
545  template <class T1, class T2>
546  typename plus_result<T1,T2>::type operator() (const T1& a, const T2& b) const { return a-b; }
547 };
548 template<>
550  template <class A1, class A2, class R>
551  struct hint : generic_binary_traits<plus>::template hint<A1,A2,R> {};
552 
553  template <class A1, class A2>
554  struct result_hint {
555  typedef typename hint<A1,A2,undeterminated_basic<Float> >::result_type type;
556  };
559  return (tag2 == space_constant::last_valued) ? tag1 : tag2;
560  }
561  typedef std::false_type is_symmetric;
562 };
563 // --------
564 // x*y
565 // --------
566 /*
567  result: when arg1 & arg2 are given
568  1\2 s v t t3 t4
569  s s v t t3 t4
570  v v E E E E
571  t t v t E E
572  t3 t3 t t3 E E
573  t4 t4 E E E E
574 
575  arg1: deduced when arg2 & result are known
576  2\r s v t t3 t4
577  s s v t t3 t4
578  v E (st)t3 E E
579  t E E (st)t3 E st: indetermine'
580  t3 E E E s E
581  t4 E E E E s
582 
583  arg2: deduced when arg1 & result are known
584  1\r s v t t3 t4
585  s s v t t3 t4
586  v E s E E E
587  t E v (st)E E st: indetermine'
588  t3 E E v (st) E
589  t4 E E E E E
590 
591  il n'y a que deux cas ou l'arg1 est indetermine' :
592  quand arg2=v et res_t=v alors arg1=s ou t
593  quand arg2=t et res_t=t alors arg1=s ou t
594  dans tous les autres cas, on deduit l'arg1
595 
596  il n'y a qu'un cas ou l'arg2 est indetermine' :
597  quand arg1=t et res_t=t alors arg2=s ou t
598  dans tous les autres cas, on deduit l'arg2
599 */
600 struct multiplies; // foward declaration
601 
602 // result type
603 // -----------
604 // s*s -> s
605 template <class A1, class A2>
607  typedef typename promote<A1,A2>::type type;
608 };
609 // s*v -> v
610 template <class S>
613 };
614 // s*t -> t
615 template <class S>
618 };
619 // v*s -> v
620 template <class S>
623 };
624 // v*v -> err
625 template <class S1, class S2>
627  typedef typename promote<S1,S2>::type S;
629 };
630 // v*t -> err
631 template <class S1, class S2>
633  typedef typename promote<S1,S2>::type S;
635 };
636 // t*s -> t
637 template <class S>
640 };
641 // t*v -> v
642 template <class S1, class S2>
644  typedef typename promote<S1,S2>::type S;
646 };
647 // t*t -> t
648 template <class S1, class S2>
650  typedef typename promote<S1,S2>::type S;
652 };
653 // s*t3 -> t3
654 template <class S>
657 };
658 // t*s -> t
659 template <class S>
662 };
663 // t3*v -> t
664 template <class S1, class S2>
666  typedef typename promote<S1,S2>::type S;
668 };
669 // t3*t -> t3
670 template <class S1, class S2>
672  typedef typename promote<S1,S2>::type S;
674 };
675 // v*t3 -> err
676 template <class S1, class S2>
678  typedef typename promote<S1,S2>::type S;
680 };
681 // t*t3 -> err
682 template <class S1, class S2>
684  typedef typename promote<S1,S2>::type S;
686 };
687 // t3*t3 -> err
688 template <class S1, class S2>
690  typedef typename promote<S1,S2>::type S;
692 };
693 // s*t4 -> t4
694 template <class S>
697 };
698 // t4*s -> t4
699 template <class S>
702 };
703 // v*t4 -> err
704 template <class S1, class S2>
706  typedef typename promote<S1,S2>::type S;
708 };
709 // t*t4 -> err
710 template <class S1, class S2>
712  typedef typename promote<S1,S2>::type S;
714 };
715 // t3*t4 -> err
716 template <class S1, class S2>
718  typedef typename promote<S1,S2>::type S;
720 };
721 // t4*v -> err
722 template <class S1, class S2>
724  typedef typename promote<S1,S2>::type S;
726 };
727 // t4*t -> err
728 template <class S1, class S2>
730  typedef typename promote<S1,S2>::type S;
732 };
733 // t4*t3 -> err
734 template <class S1, class S2>
736  typedef typename promote<S1,S2>::type S;
738 };
739 // t4*t4 -> err
740 template <class S1, class S2>
742  typedef typename promote<S1,S2>::type S;
744 };
745 
746 struct multiplies {
747  template <class T1, class T2>
749  operator() (const T1& a, const T2& b) const { return a*b; }
750 };
751 template<>
755  return space_constant::multiplies_result_tag(tag1,tag2);
756  }
757  // --------------------------
758  // hint arg1 type
759  // --------------------------
760  // ?*s=s => a1=s
761  template <class A2, class R, class Sfinae = void>
762  struct first_argument_hint {
763  typedef typename promote<A2,R>::type type;
764  };
765  // ?*s=v => a1=v
766  template <class A2, class R>
767  struct first_argument_hint<A2,point_basic<R> > {
769  };
770  // ?*s=t => a1=t
771  template <class A2, class R>
772  struct first_argument_hint<A2,tensor_basic<R> > {
774  };
775  // ?*s=t3 => a1=t3
776  template <class A2, class R>
777  struct first_argument_hint<A2,tensor3_basic<R> > {
779  };
780  // ?*s=t4 => a1=t4
781  template <class A2, class R>
782  struct first_argument_hint<A2,tensor4_basic<R>,
783  typename std::enable_if<is_rheolef_arithmetic<A2>::value>::type> {
785  };
786  // ?*v=s => a1=err
787  template <class A2, class R>
788  struct first_argument_hint<point_basic<A2>,R> {
790  };
791  // ?*v=v => a1={s,t}=undeterminated
792  template <class A2, class R>
793  struct first_argument_hint<point_basic<A2>,point_basic<R> > {
795  };
796  // ?*v=t => a1=t3
797  template <class A2, class R>
798  struct first_argument_hint<point_basic<A2>,tensor_basic<R> > {
800  };
801  // ?*v=t3 => a1=err
802  template <class A2, class R>
803  struct first_argument_hint<point_basic<A2>,tensor3_basic<R> > {
805  };
806  // ?*v=t4 => a1=err
807  template <class A2, class R>
808  struct first_argument_hint<point_basic<A2>,tensor4_basic<R> > {
810  };
811  // ?*t=s => a1=err
812  template <class A2, class R>
813  struct first_argument_hint<tensor_basic<A2>,R> {
815  };
816  // ?*t=v => a1=err
817  template <class A2, class R>
818  struct first_argument_hint<tensor_basic<A2>,point_basic<R> > {
820  };
821  // ?*t=t => a1={s,t}=undeterminated
822  template <class A2, class R>
823  struct first_argument_hint<tensor_basic<A2>,tensor_basic<R> > {
825  };
826  // ?*t=t3 => a1=t3
827  template <class A2, class R>
828  struct first_argument_hint<tensor_basic<A2>,tensor3_basic<R> > {
830  };
831  // ?*t3=s => a1=err
832  template <class A2, class R>
833  struct first_argument_hint<tensor3_basic<A2>,R> {
835  };
836  // ?*t3=v => a1=err
837  template <class A2, class R>
838  struct first_argument_hint<tensor3_basic<A2>,point_basic<R> > {
840  };
841  // ?*t3=t => a1=err
842  template <class A2, class R>
843  struct first_argument_hint<tensor3_basic<A2>,tensor_basic<R> > {
845  };
846  // ?*t3=t3 => a1=s
847  template <class A2, class R>
848  struct first_argument_hint<tensor3_basic<A2>,tensor3_basic<R> > {
849  typedef typename promote<A2,R>::type type;
850  };
851  // ?*t4=s => a1=E
852  template <class A2, class R>
853  struct first_argument_hint<tensor4_basic<A2>,R,
854  typename std::enable_if<is_rheolef_arithmetic<R>::value>::type> {
855  typedef typename promote<A2,R>::type S;
857  };
858  // ?*t4=v => a1=E
859  template <class A2, class R>
860  struct first_argument_hint<tensor4_basic<A2>,point_basic<R> > {
861  typedef typename promote<A2,R>::type S;
863  };
864  // ?*t4=t => a1=E
865  template <class A2, class R>
866  struct first_argument_hint<tensor4_basic<A2>,tensor_basic<R> > {
867  typedef typename promote<A2,R>::type S;
869  };
870  // ?*t4=t3 => a1=E
871  template <class A2, class R>
872  struct first_argument_hint<tensor4_basic<A2>,tensor3_basic<R> > {
873  typedef typename promote<A2,R>::type S;
875  };
876  // ?*t4=t4 => a1=s
877  template <class A2, class R>
878  struct first_argument_hint<tensor4_basic<A2>,tensor4_basic<R> > {
879  typedef typename promote<A2,R>::type type;
880  };
881  // --------------------------
882  // hint arg2 type
883  // --------------------------
884  // s*?=s => a2=s
885  template <class A1, class R, class Sfinae = void>
886  struct second_argument_hint {
887  typedef typename promote<A1,R>::type type;
888  };
889  // s*?=v => a2=v
890  template <class A1, class R>
891  struct second_argument_hint<A1,point_basic<R> > {
893  };
894  // s*?=t => a2=t
895  template <class A1, class R>
896  struct second_argument_hint<A1,tensor_basic<R> > {
898  };
899  // s*?=t3 => a2=t3
900  template <class A1, class R>
901  struct second_argument_hint<A1,tensor3_basic<R> > {
903  };
904  // s*?=t4 => a2=t4
905  template <class A1, class R>
906  struct second_argument_hint<A1,tensor4_basic<R>,
907  typename std::enable_if<is_rheolef_arithmetic<A1>::value>::type> {
909  };
910  // v*?=s => a2=err
911  template <class A1, class R>
912  struct second_argument_hint<point_basic<A1>,R> {
914  };
915  // v*?=v => a2=s
916  template <class A1, class R>
917  struct second_argument_hint<point_basic<A1>,point_basic<R> > {
918  typedef typename promote<A1,R>::type type;
919  };
920  // v*?=t => a2=err
921  template <class A1, class R>
922  struct second_argument_hint<point_basic<A1>,tensor_basic<R> > {
924  };
925  // t*?=s => a2=err
926  template <class A1, class R>
927  struct second_argument_hint<tensor_basic<A1>,R> {
929  };
930  // t*?=v => a2=v
931  template <class A1, class R>
932  struct second_argument_hint<tensor_basic<A1>,point_basic<R> > {
934  };
935  // t*?=t => a2={s,t}=undeterminated
936  template <class A1, class R>
937  struct second_argument_hint<tensor_basic<A1>,tensor_basic<R> > {
939  };
940  // v*?=t3 => a2=err
941  template <class A1, class R>
942  struct second_argument_hint<point_basic<A1>,tensor3_basic<R> > {
944  };
945  // t*?=t3 => a2=err
946  template <class A1, class R>
947  struct second_argument_hint<tensor_basic<A1>,tensor3_basic<R> > {
949  };
950  // t3*?=s => a2=err
951  template <class A1, class R>
952  struct second_argument_hint<tensor3_basic<A1>,R > {
954  };
955  // t3*?=v => a2=err
956  template <class A1, class R>
957  struct second_argument_hint<tensor3_basic<A1>,point_basic<R> > {
959  };
960  // t3*?=t => a2=v
961  template <class A1, class R>
962  struct second_argument_hint<tensor3_basic<A1>,tensor_basic<R> > {
964  };
965  // t3*?=t3 => a2={st}
966  template <class A1, class R>
967  struct second_argument_hint<tensor3_basic<A1>,tensor3_basic<R> > {
969  };
970  // t4*?=s => a2=err
971  template <class A1, class R>
972  struct second_argument_hint<tensor4_basic<A1>,R,
973  typename std::enable_if<is_rheolef_arithmetic<R>::value>::type> {
975  };
976  // t4*?=v => a2=err
977  template <class A1, class R>
978  struct second_argument_hint<tensor4_basic<A1>,point_basic<R> > {
980  };
981  // t4*?=t => a2=err
982  template <class A1, class R>
983  struct second_argument_hint<tensor4_basic<A1>,tensor_basic<R> > {
985  };
986  // t4*?=t3 => a2=err
987  template <class A1, class R>
988  struct second_argument_hint<tensor4_basic<A1>,tensor3_basic<R> > {
990  };
991  // t4*?=t4 => a2=err
992  template <class A1, class R>
993  struct second_argument_hint<tensor4_basic<A1>,tensor4_basic<R> > {
994  typedef typename promote<A1,R>::type S;
995  typedef S type;
996  };
997  // --------------------------
998  // hint interface
999  // --------------------------
1000  template <class A1, class A2, class R>
1001  struct hint {
1004  typedef R result_type;
1005  };
1006  // two types are known
1007  // --------------------------
1008  // a1*a2 -> ? : deduce r
1009  template <class A1, class A2, class R>
1010  struct hint<A1,A2,undeterminated_basic<R> > {
1014  };
1015  // ?*a2 -> r : deduce a1
1016  template <class A1, class A2, class R>
1017  struct hint<undeterminated_basic<A1>,A2,R> {
1018  // TODO: promote scalar_type of first arg: tensor<Float>*point<complex> -> point<complex>
1019  // promote_valued<Arg,Scalar>::type
1020  // e.g. promote_valued<point_basic<Float>,complex<Float> >::type -> point_basic<cmplex<Float>>
1023  typedef R result_type;
1024  };
1025  // a1*? -> r : deduce a2
1026  template <class A1, class A2, class R>
1027  struct hint<A1,undeterminated_basic<A2>,R> {
1030  typedef R result_type;
1031  };
1032  // only one type is known
1033  // -----------------------
1034  // ?*? -> s : deduce a1=a2=s
1035  template <class A1, class A2, class R>
1039  typedef R result_type;
1040  };
1041  // ?*? -> v : deduce (a1,a2)={(s,v),(v,s),(t,v)}=?
1042  template <class A1, class A2, class R>
1047  };
1048  // ?*? -> t : deduce (a1,a2)={(s,t),(t,s),(t,t)}=?
1049  template <class A1, class A2, class R>
1054  };
1055  // ?*? -> t3 : deduce (a1,a2)={(s,t3),(t3,s),(t3,t)}=?
1056  template <class A1, class A2, class R>
1061  };
1062  // ?*? -> t4 : deduce (a1,a2)={(s,t4),(t4,s)}=?
1063  template <class A1, class A2, class R>
1068  };
1069  // s*? -> ? : deduce (a2,r)={(s,s),(v,v),(t,t)}=?
1070  template <class A1, class A2, class R>
1071  struct hint<A1,undeterminated_basic<A2>,undeterminated_basic<R> > {
1075  };
1076  // v*? -> ? : deduce (a2,r)=(s,v)
1077  template <class A1, class A2, class R>
1082  };
1083  // t*? -> ? : deduce (a2,r)={(v,v),(t,t),(s,t)}=?
1084  template <class A1, class A2, class R>
1089  };
1090  // t3*? -> ? : deduce (a2,r)={(s,t3),(v,t),(t3,t3)}=?
1091  template <class A1, class A2, class R>
1096  };
1097  // ?*s -> ? : deduce (a1,r)={(s,s),(v,v),(t,t)}=?
1098  template <class A1, class A2, class R>
1099  struct hint<undeterminated_basic<A1>,A2,undeterminated_basic<R> > {
1103  };
1104  // ?*v -> ? : deduce (a1,r)={(s,v),(t,v)}=?
1105  template <class A1, class A2, class R>
1110  };
1111  // ?*t -> ? : deduce (a1,r)={(s,t),(t,t)}=?
1112  template <class A1, class A2, class R>
1117  };
1118  // ?*t3 -> ? : deduce (a1,r)=(s,t3)
1119  template <class A1, class A2, class R>
1124  };
1125  // ?*t4 -> ? : deduce (a1,r)=(s,t4)
1126  template <class A1, class A2, class R>
1131  };
1132  // t4*? -> ? : deduce (a2,r)=(s,t4)
1133  template <class A1, class A2, class R>
1138  };
1139  // none types are known
1140  // -----------------------
1141  // ?*? -> ? : deduce (a1,a2,r)=?
1142  template <class A1, class A2, class R>
1147  };
1148  // short interface
1149  template <class Arg1, class Arg2>
1150  struct result_hint {
1151  typedef typename hint<Arg1,Arg2,undeterminated_basic<Float> >::result_type type;
1152  };
1153  typedef std::false_type is_symmetric; // tensor*vector do not commute
1154 }; // generic_binary_traits<multiplies>
1155 // --------
1156 // x/y
1157 // --------
1158 struct divides; // foward declaration
1159 
1160 template <class T1, class T2, class Sfinae = void>
1163 };
1164 // s/s -> s
1165 template <class T1, class T2>
1166 struct divides_result<T1,T2,
1167  typename std::enable_if<
1168  is_rheolef_arithmetic<T1>::value &&
1169  is_rheolef_arithmetic<T2>::value
1170  >::type>
1171 {
1172  typedef typename promote<T1,T2>::type type;
1173 };
1174 // undef/undef -> undef
1175 template <class T1, class T2>
1176 struct divides_result<T1,T2,
1177  typename std::enable_if<
1178  is_undeterminated<T1>::value &&
1179  is_undeterminated<T2>::value
1180  >::type>
1181 {
1183 };
1184 // v/v -> err ; t/t -> err
1185 template <class T>
1187  typename std::enable_if<
1188  ! is_rheolef_arithmetic<T>::value
1189  && ! is_undeterminated<T>::value
1190 >::type>
1191 {
1192  typedef typename scalar_traits<T>::type S;
1194 };
1195 template <class T>
1198 };
1199 template <class T>
1202 };
1203 template <class T>
1206 };
1207 template <class T>
1210 };
1211 template <class T1, class T2>
1213  typedef typename promote<T1,T2>::type S;
1215 };
1216 template <class T1, class T2>
1218  typedef typename promote<T1,T2>::type S;
1220 };
1221 template <class T>
1224 };
1225 template <class T>
1228 };
1229 template <class T>
1232 };
1233 template <class T1, class T2>
1235  typedef typename promote<T1,T2>::type S;
1237 };
1238 template <class T1, class T2>
1240  typedef typename promote<T1,T2>::type S;
1242 };
1243 template <class T1, class T2>
1245  typedef typename promote<T1,T2>::type S;
1247 };
1248 template <class T1, class T2>
1250  typedef typename promote<T1,T2>::type S;
1252 };
1253 template <class T>
1256 };
1257 template <class T1, class T2>
1259  typedef typename promote<T1,T2>::type S;
1261 };
1262 template <class T1, class T2>
1264  typedef typename promote<T1,T2>::type S;
1266 };
1267 template <class T1, class T2>
1269  typedef typename promote<T1,T2>::type S;
1271 };
1272 struct divides {
1273  template <class T1, class T2>
1275  operator() (const T1& a, const T2& b) const { return a/b; }
1276 };
1277 template<>
1279  template <class Arg1, class Arg2>
1280  struct result_hint {
1282  };
1283  template <class Arg1, class Arg2, class Result>
1284  struct hint {
1285  typedef Arg1 first_argument_type;
1286  typedef Arg2 second_argument_type;
1287  typedef Result result_type;
1288  };
1289  // two types are known
1290  // --------------------------
1291  // a1/a2 -> ? : deduce r=a1 when a2=s (error otherwise)
1292  template <class A1, class A2, class R>
1293  struct hint<A1,A2,undeterminated_basic<R> > {
1297  };
1298  // ?/a2 -> r : deduce a1=r when a2=s (error otherwise)
1299  template <class A1, class A2, class R>
1300  struct hint<undeterminated_basic<A1>,A2,R> {
1301  typedef typename scalar_traits<A2>::type S2;
1302  typedef typename std::conditional<
1304  R,
1307  typedef R result_type;
1308  };
1309  // a1/? -> r : deduce a2=s when a1=r (error otherwise)
1310  template <class A1, class A2, class R>
1311  struct hint<A1,undeterminated_basic<A2>,R> {
1312  typedef typename promote<
1313  typename scalar_traits<A1>::type,
1316  typedef typename std::conditional<
1318  S,
1320  typedef R result_type;
1321  };
1322  // two types are unknown
1323  // --------------------------
1324  // ?/? -> r : deduce a1=r and a2=s
1325  template <class A1, class A2, class R>
1329  typedef R result_type;
1330  };
1331  // a1/? -> ? : deduce r=a1 and a2=s
1332  template <class A1, class A2, class R>
1333  struct hint<A1,undeterminated_basic<A2>,undeterminated_basic<R> > {
1336  typedef A1 result_type;
1337  };
1338  // ?/a2 -> ? : deduce r=a1=? and a2=s
1339  template <class A1, class A2, class R>
1340  struct hint<undeterminated_basic<A1>,A2,undeterminated_basic<R> > {
1341  typedef typename scalar_traits<A2>::type S2;
1342  typedef typename std::conditional<
1348  };
1349  // three types are unknown
1350  // -----------------------
1351  // ?/? -> ? : deduce a1=r=? and a2=s
1352  template <class A1, class A2, class R>
1357  };
1360  return space_constant::divides_result_tag(tag1,tag2);
1361  }
1362  typedef std::false_type is_symmetric;
1363 };
1364 // ----------------------------------------------------------------------------
1365 // chap 2.3. binary standard maths: pow(x,y), atan2(x,y),...
1366 // ----------------------------------------------------------------------------
1367 // specialization for scalar generic functions, as details::pow_, details::atan2_, etc
1368 //ICI
1369 template<class F>
1373  return space_constant::scalar;
1374  }
1375  template <class Arg1, class Arg2>
1376  struct result_hint {
1378  };
1379  template <class A1, class A2, class R>
1380  struct hint {
1381  typedef typename scalar_traits<A1>::type S1;
1382  typedef typename scalar_traits<A2>::type S2;
1383  typedef typename scalar_traits<R>::type S;
1384  typedef typename details::and_type<
1388  >
1392  >
1396  >
1398  typedef typename std::conditional<
1400  ,typename std::conditional<
1401  is_good::value
1402  ,S1
1404  >::type
1405  ,A1
1407  typedef typename std::conditional<
1409  ,typename std::conditional<
1410  is_good::value
1411  ,S2
1413  >::type
1414  ,A2
1416  typedef typename std::conditional<
1418  ,typename std::conditional<
1419  is_good::value
1420  ,S
1422  >::type
1423  ,R
1425  };
1426  typedef std::false_type is_symmetric;
1427 };
1428 #define _RHEOLEF_generic_binary_scalar(F) \
1429 struct F##_ { \
1430  template<class A1, class A2> \
1431  typename promote<A1,A2>::type \
1432  operator() (const A1& x, const A2& y) const { \
1433  typedef typename promote<A1,A2>::type R; \
1434  return F(R(x),R(y)); } \
1435 }; \
1436 template<> \
1437 struct generic_binary_traits<F##_> : scalar_binary_traits<F##_> {}; \
1438 
1444 #undef _RHEOLEF_generic_binary_scalar
1445 // ----------------------------------------------------------------------------
1446 // chap 2.4. binary extensions: dot(x,y), ddot(x,y), dddot(x,y)
1447 // ----------------------------------------------------------------------------
1448 // dot(x,y)
1449 // ------------
1450 struct dot_ {
1451  template<class T>
1452  T operator() (const point_basic<T>& x, const point_basic<T>& y) const { return dot(x,y); }
1453 };
1454 template<>
1458  return space_constant::scalar;
1459  }
1460  template <class Arg1, class Arg2>
1461  struct result_hint {
1463  };
1464  template <class A1, class A2, class R>
1465  struct hint {
1466  typedef typename scalar_traits<A1>::type S1;
1467  typedef typename scalar_traits<A2>::type S2;
1468  typedef typename scalar_traits<R>::type S;
1469  typedef typename details::and_type<
1473  >
1477  >
1481  >
1483  typedef typename std::conditional<
1485  ,typename std::conditional<
1486  is_good::value
1489  >::type
1490  ,A1
1492  typedef typename std::conditional<
1494  ,typename std::conditional<
1495  is_good::value
1498  >::type
1499  ,A2
1501  typedef typename std::conditional<
1503  ,typename std::conditional<
1504  is_good::value
1505  ,S
1507  >::type
1508  ,R
1510  };
1511  typedef std::true_type is_symmetric;
1512 };
1513 // ------------
1514 // ddot(x,y)
1515 // ------------
1516 /*
1517  result: when arg1 & arg2 are given
1518  1\2 t t4
1519  t s t
1520  t4 t E
1521 */
1522 struct ddot_;
1523 template <class A1, class A2>
1524 struct ddot_result {
1527 };
1528 template <class A1, class A2>
1531  typedef S type;
1532 };
1533 template <class A1, class A2>
1537 };
1538 template <class A1, class A2>
1542 };
1543 struct ddot_ {
1544  template<class A1, class A2>
1545  typename ddot_result<A1,A2>::type
1546  operator() (const A1& x, const A2& y) const { return ddot(x,y); }
1547 };
1548 template<>
1552  return space_constant::scalar;
1553  }
1554  template <class A1, class A2, class R>
1555  struct hint {
1557  typedef typename std::conditional<is_undeterminated<A1>::value,T,A1>::type first_argument_type;
1558  typedef typename std::conditional<is_undeterminated<A2>::value,T,A2>::type second_argument_type;
1559  typedef typename std::conditional<is_undeterminated<R>::value, T,R> ::type result_type;
1560  };
1561  // a:b -> ?
1562  template <class A1, class A2, class R>
1563  struct hint<A1,A2,undeterminated_basic<R> > {
1565  typedef typename std::conditional<
1568  ,result_type
1570  typedef typename std::conditional<
1573  ,result_type
1575  };
1576  // ====================
1577  // A1 xor A2 is unknown
1578  // ====================
1579  // ?:t -> s => a=t
1580  template <class A1, class A2, class R>
1581  struct hint<undeterminated_basic<A1>,tensor_basic<A2>,R> {
1583  typedef typename std::conditional<is_scalar<R>::value,tensor_basic<A1>,E>::type
1586  typedef R result_type;
1587  };
1588  // t:? -> s => b=t
1589  template <class A1, class A2, class R>
1590  struct hint<tensor_basic<A1>,undeterminated_basic<A2>,R> {
1593  typedef typename std::conditional<is_scalar<R>::value,tensor_basic<A2>,E>::type
1595  typedef R result_type;
1596  };
1597  // ?:t4 -> t => a=t
1598  template <class A1, class A2, class R>
1603  };
1604  // t4:? -> t => b=t
1605  template <class A1, class A2, class R>
1610  };
1611  // =====================
1612  // A1 and A2 are unknown
1613  // =====================
1614  // ?:? -> s => a=b=t
1615  template <class A1, class A2, class R>
1618  typedef typename std::conditional<is_scalar<R>::value,tensor_basic<A1>,E>::type
1620  typedef typename std::conditional<is_scalar<R>::value,tensor_basic<A2>,E>::type
1622  typedef R result_type;
1623  };
1624  // ?:? -> t => (a,b)={(t,t4),(t4,t)}
1625  // =====================
1626  // A1 and R are unknown
1627  // =====================
1628  // ?:t -> ? => (a,r)={(t,s),(t4,t)}
1629  template <class A1, class A2, class R>
1634  };
1635  // ?:t4 -> ? => (a,r)=(t,t)
1636  template <class A1, class A2, class R>
1641  };
1642  // =====================
1643  // A2 and R are unknown
1644  // =====================
1645  // t:? -> ? => (b,r)={(t,s),(t4,t)}
1646  template <class A1, class A2, class R>
1651  };
1652  // t4:? -> ? => (b,r)=(t,t)
1653  template <class A1, class A2, class R>
1658  };
1659  // ========================
1660  // A1, A2 and R are unknown
1661  // ========================
1662  // ?:? -> ? => a,b,r=?
1663  template <class A1, class A2, class R>
1668  };
1669  // short interface
1670  template <class Arg1, class Arg2>
1671  struct result_hint {
1672  typedef typename hint<Arg1,Arg2,undeterminated_basic<Float> >::result_type type;
1673  };
1674  typedef std::true_type is_symmetric;
1675 };
1676 // ------------
1677 // dddot(x,y)
1678 // ------------
1679 /*
1680  result: when arg1 & arg2 are given
1681  1\2 t3
1682  t3 s
1683 */
1684 struct dddot_;
1685 template <class A1, class A2>
1689 };
1690 template <class A1, class A2>
1693  typedef S type;
1694 };
1695 struct dddot_ {
1696  template<class A1, class A2>
1697  typename dddot_result<A1,A2>::type
1698  operator() (const A1& x, const A2& y) const { return dddot(x,y); }
1699 };
1700 template<>
1704  return space_constant::scalar;
1705  }
1706  template <class A1, class A2, class R>
1707  struct hint {
1709  typedef typename std::conditional<is_undeterminated<A1>::value,T,A1>::type first_argument_type;
1710  typedef typename std::conditional<is_undeterminated<A2>::value,T,A2>::type second_argument_type;
1711  typedef typename std::conditional<is_undeterminated<R>::value, T,R> ::type result_type;
1712  };
1713  // a:.b -> ?
1714  template <class A1, class A2, class R>
1715  struct hint<A1,A2,undeterminated_basic<R> > {
1717  typedef typename std::conditional<
1720  ,result_type
1722  typedef typename std::conditional<
1725  ,result_type
1727  };
1728  // ====================
1729  // A1 xor A2 is unknown
1730  // ====================
1731  // ?:.t3 -> s => a=t3
1732  template <class A1, class A2, class R>
1733  struct hint<undeterminated_basic<A1>,tensor3_basic<A2>,R> {
1735  typedef typename std::conditional<is_scalar<R>::value,tensor3_basic<A1>,E>::type
1738  typedef R result_type;
1739  };
1740  // t3:.? -> s => b=t3
1741  template <class A1, class A2, class R>
1742  struct hint<tensor3_basic<A1>,undeterminated_basic<A2>,R> {
1745  typedef typename std::conditional<is_scalar<R>::value,tensor3_basic<A2>,E>::type
1747  typedef R result_type;
1748  };
1749  // =====================
1750  // A1 and A2 are unknown
1751  // =====================
1752  // ?:.? -> s => a=b=t3
1753  template <class A1, class A2, class R>
1756  typedef typename std::conditional<is_scalar<R>::value,tensor3_basic<A1>,E>::type
1758  typedef typename std::conditional<is_scalar<R>::value,tensor3_basic<A2>,E>::type
1760  typedef R result_type;
1761  };
1762  // =====================
1763  // A2 and R are unknown
1764  // =====================
1765  // t3:.? -> ? => (b,r)={(t3,s)}
1766  template <class A1, class A2, class R>
1770  typedef R result_type;
1771  };
1772  // ========================
1773  // A1, A2 and R are unknown
1774  // ========================
1775  // ?:.? -> ? => a,b,r=?
1776  template <class A1, class A2, class R>
1780  typedef R result_type;
1781  };
1782  // short interface
1783  template <class Arg1, class Arg2>
1784  struct result_hint {
1785  typedef typename hint<Arg1,Arg2,undeterminated_basic<Float> >::result_type type;
1786  };
1787  typedef std::true_type is_symmetric;
1788 };
1789 // ===========================================================================
1790 // part 3. binders
1791 // ===========================================================================
1792 // similar to std::binder1st, std::binder2nd, but for generic operators
1793 
1794 // ----------------------------------------------------------------------------
1795 // chap 3.1. binder_first
1796 // ----------------------------------------------------------------------------
1797 template<class BinaryFunction, class A1>
1799  binder_first (const BinaryFunction& f, const A1& x1) : _f(f), _x1(x1) {}
1800  template<class A2>
1801  typename generic_binary_traits<BinaryFunction>::template result_hint<A1,A2>::type
1802  operator() (const A2& x2) const { return _f(_x1,x2); }
1803 protected:
1805  A1 _x1;
1806 };
1807 template<class BinaryFunction, class A1>
1809  template <class A2>
1810  struct result_hint {
1812  };
1813  template <class A2, class Result>
1814  struct hint {
1815  typedef Result result_type;
1816  typedef A2 argument_type;
1817  };
1818  // result unknown:
1819  template <class A2, class T>
1820  struct hint<A2,undeterminated_basic<T> > {
1822  typedef A1 argument_type;
1823  };
1824  // A2 unknown:
1825  template <class R, class T>
1826  struct hint<undeterminated_basic<T>,R> {
1827  typedef R result_type;
1828  typedef typename generic_binary_traits<BinaryFunction>::template hint<A1,undeterminated_basic<T>,R>::second_argument_type
1830  };
1831  // A2 & R unknown:
1832  template <class T1, class T>
1834  typedef typename generic_binary_traits<BinaryFunction>::template hint<A1,undeterminated_basic<T1>,undeterminated_basic<T> >::second_argument_type
1836  typedef typename generic_binary_traits<BinaryFunction>::template hint<A1,undeterminated_basic<T>,undeterminated_basic<T> >::result_type
1838  };
1842  return generic_binary_traits<BinaryFunction>::valued_tag (arg1_tag, arg_tag) ;
1843  }
1844 };
1845 // ----------------------------------------------------------------------------
1846 // chap 3.2. binder_second
1847 // ----------------------------------------------------------------------------
1848 template<class BinaryFunction, class A2>
1850  binder_second (const BinaryFunction& f, const A2& x2) : _f(f), _x2(x2) {}
1851  template<class A1>
1852  typename generic_binary_traits<BinaryFunction>::template result_hint<A1,A2>::type
1853  operator() (const A1& x1) const { return _f(x1,_x2); }
1854 protected:
1856  A2 _x2;
1857 };
1858 template<class BinaryFunction, class A2>
1860  template <class A1>
1861  struct result_hint {
1863  };
1864  template <class A1, class Result>
1865  struct hint {
1866  typedef Result result_type;
1867  typedef A1 argument_type;
1868  };
1869  // result unknown:
1870  template <class A1, class T>
1871  struct hint<A1,undeterminated_basic<T> > {
1873  typedef A1 argument_type;
1874  };
1875  // A1 unknown:
1876  template <class R, class T>
1877  struct hint<undeterminated_basic<T>,R> {
1878  typedef R result_type;
1879  typedef typename generic_binary_traits<BinaryFunction>::template hint<undeterminated_basic<T>,A2,R>::first_argument_type
1881  };
1882  // A1 & R unknown:
1883  template <class T1, class T>
1885  typedef typename generic_binary_traits<BinaryFunction>::template hint<undeterminated_basic<T1>,A2,undeterminated_basic<T> >::first_argument_type
1887  typedef typename generic_binary_traits<BinaryFunction>::template hint<undeterminated_basic<T>,A2,undeterminated_basic<T> >::result_type
1889  };
1893  return generic_binary_traits<BinaryFunction>::valued_tag (arg_tag, arg2_tag) ;
1894  }
1895 };
1896 // ---------------------------------------------------------------------------
1897 // chap 3.3. binary swapper
1898 // ---------------------------------------------------------------------------
1899 // as details::mutiplies, for field_vf_bind_bf
1900 // swap is equivalet to binder_second, but with a field instead of a constant
1901 template<class BinaryFunction>
1902 struct swapper {
1903  swapper (const BinaryFunction& f) : _f(f) {}
1904  template<class A1, class A2>
1905  typename generic_binary_traits<BinaryFunction>::template result_hint<A2,A1>::type
1906  operator() (const A1& x1, const A2& x2) const { return _f(x2,x1); }
1907 protected:
1909 };
1910 template<class BinaryFunction>
1912  template <class A1, class A2>
1913  struct result_hint : generic_binary_traits<BinaryFunction>::template result_hint<A2,A1> {};
1914 
1915  template <class A1, class A2, class Result>
1916  struct hint {
1917  typedef typename generic_binary_traits<BinaryFunction>::template hint<A2,A1,Result> base;
1918  typedef typename base::second_argument_type first_argument_type;
1919  typedef typename base::first_argument_type second_argument_type;
1920  typedef typename base::result_type result_type;
1921  };
1924  return generic_binary_traits<BinaryFunction>::valued_tag (arg2_tag, arg1_tag) ;
1925  }
1926 };
1927 // ---------------------------------------------------------------------------
1928 // chap 3.4. unary & binary function wrapper, for compose
1929 // ---------------------------------------------------------------------------
1930 // TODO: use std::function<F> ?
1931 template<class Function>
1933  typedef Function type;
1934 };
1935 template<class Result, class Arg>
1936 struct function_wrapper<Result(Arg)> {
1937  typedef std::function<Result(Arg)> type;
1938 };
1939 template<class Result, class Arg1, class Arg2>
1940 struct function_wrapper<Result(Arg1,Arg2)> {
1941  typedef std::function<Result(Arg1,Arg2)> type;
1942 };
1943 
1944 template<class Function>
1945 inline
1946 Function
1948 {
1949  return f;
1950 }
1951 template<class Result, class Arg>
1952 inline
1953 std::pointer_to_unary_function<Arg,Result>
1954 function_wrap (Result(*f)(Arg))
1955 {
1956  return std::ptr_fun(f);
1957 }
1958 template<class Result, class Arg1, class Arg2>
1959 inline
1960 std::pointer_to_binary_function<Arg1,Arg2,Result>
1961 function_wrap (Result(*f)(Arg1,Arg2))
1962 {
1963  return std::ptr_fun(f);
1964 }
1965 
1966 }} // namespace rheolef::details
1967 #endif // _RHEOLEF_EXPRESSION_H
rheolef::std type
rheolef::std BinaryFunction
rheolef::std value
rheolef::std Function
Expr1::float_type T
Definition: field_expr.h:230
_RHEOLEF_generic_unary_scalar(cos) _RHEOLEF_generic_unary_scalar(sin) _RHEOLEF_generic_unary_scalar(tan) _RHEOLEF_generic_unary_scalar(acos) _RHEOLEF_generic_unary_scalar(asin) _RHEOLEF_generic_unary_scalar(atan) _RHEOLEF_generic_unary_scalar(cosh) _RHEOLEF_generic_unary_scalar(sinh) _RHEOLEF_generic_unary_scalar(tanh) _RHEOLEF_generic_unary_scalar(exp) _RHEOLEF_generic_unary_scalar(log) _RHEOLEF_generic_unary_scalar(log10) _RHEOLEF_generic_unary_scalar(sqrt) _RHEOLEF_generic_unary_scalar(abs) _RHEOLEF_generic_unary_scalar(fabs) _RHEOLEF_generic_unary_scalar(floor) _RHEOLEF_generic_unary_scalar(ceil) _RHEOLEF_generic_unary_scalar(sqr) struct tr_
Definition: expression.h:279
rheolef::details::is_vec dot
_RHEOLEF_generic_binary_scalar(atan2) _RHEOLEF_generic_binary_scalar(pow) _RHEOLEF_generic_binary_scalar(fmod) _RHEOLEF_generic_binary_scalar(min) _RHEOLEF_generic_binary_scalar(max) struct dot_
Definition: expression.h:1439
Function function_wrap(Function f)
Definition: expression.h:1947
valued_type multiplies_result_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
valued_type divides_result_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
This file is part of Rheolef.
t operator()(const t &a, const t &b)
Definition: space.cc:386
T dddot(const tensor3_basic< T > &a, const tensor3_basic< T > &b)
Definition: tensor3.cc:94
csr< T, sequential > trans(const csr< T, sequential > &a)
trans(a): see the form page for the full documentation
Definition: csr.h:455
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
Definition: vec.h:387
T norm2(const vec< T, M > &x)
norm2(x): see the expression page for the full documentation
Definition: vec.h:379
U tr(const tensor_basic< U > &a, size_t d=3)
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
space_mult_list< T, M > pow(const space_basic< T, M > &X, size_t n)
Definition: space_mult.h:120
tensor_basic< T > exp(const tensor_basic< T > &a, size_t d)
Definition: tensor-exp.cc:92
Definition: cavity_dg.h:29
generic_binary_traits< BinaryFunction >::template result_hint< A1, A2 >::type operator()(const A2 &x2) const
Definition: expression.h:1802
binder_first(const BinaryFunction &f, const A1 &x1)
Definition: expression.h:1799
binder_second(const BinaryFunction &f, const A2 &x2)
Definition: expression.h:1850
generic_binary_traits< BinaryFunction >::template result_hint< A1, A2 >::type operator()(const A1 &x1) const
Definition: expression.h:1853
dddot_result< A1, A2 >::type operator()(const A1 &x, const A2 &y) const
Definition: expression.h:1698
promote< typename float_traits< A1 >::type, typename float_traits< A2 >::type >::type S
Definition: expression.h:1692
binop_error< dddot_, A1, A2, undeterminated_basic< S > > type
Definition: expression.h:1688
promote< typename float_traits< A1 >::type, typename float_traits< A2 >::type >::type S
Definition: expression.h:1687
ddot_result< A1, A2 >::type operator()(const A1 &x, const A2 &y) const
Definition: expression.h:1546
promote< typename float_traits< A1 >::type, typename float_traits< A2 >::type >::type S
Definition: expression.h:1535
promote< typename float_traits< A1 >::type, typename float_traits< A2 >::type >::type S
Definition: expression.h:1540
promote< typename float_traits< A1 >::type, typename float_traits< A2 >::type >::type S
Definition: expression.h:1530
promote< typename float_traits< A1 >::type, typename float_traits< A2 >::type >::type S
Definition: expression.h:1525
binop_error< ddot_, A1, A2, undeterminated_basic< S > > type
Definition: expression.h:1526
binop_error< details::divides, T, point_basic< T >, undeterminated_basic< T > > type
Definition: expression.h:1205
binop_error< details::divides, T, tensor3_basic< T >, undeterminated_basic< T > > type
Definition: expression.h:1231
binop_error< details::divides, T, tensor4_basic< T >, undeterminated_basic< T > > type
Definition: expression.h:1255
binop_error< details::divides, T, tensor_basic< T >, undeterminated_basic< T > > type
Definition: expression.h:1209
binop_error< details::divides, point_basic< T1 >, tensor3_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1236
binop_error< details::divides, point_basic< T1 >, tensor4_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1260
binop_error< details::divides, point_basic< T1 >, tensor_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1214
binop_error< details::divides, tensor3_basic< T1 >, point_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1246
binop_error< details::divides, tensor3_basic< T1 >, tensor4_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1270
binop_error< details::divides, tensor3_basic< T1 >, tensor_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1251
binop_error< details::divides, tensor_basic< T1 >, point_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1219
binop_error< details::divides, tensor_basic< T1 >, tensor3_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1241
binop_error< details::divides, tensor_basic< T1 >, tensor4_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1265
undeterminated_basic< typename promote< typename scalar_traits< T1 >::type, typename scalar_traits< T2 >::type >::type > type
Definition: expression.h:1162
divides_result< T1, T2 >::type operator()(const T1 &a, const T2 &b) const
Definition: expression.h:1275
std::decay< typename function_traits< Function >::template arg< 0 >::type >::type first_argument_type
Definition: expression.h:415
std::decay< typename function_traits< Function >::template arg< 1 >::type >::type second_argument_type
Definition: expression.h:417
std::decay< typename function_traits< Function >::result_type >::type result_type
Definition: expression.h:419
function_traits< Function >::result_type type
Definition: expression.h:410
std::conditional< is_undeterminated< A2 >::value &&is_error< result_type >::value,result_type,A2 >::type second_argument_type
Definition: expression.h:1726
std::conditional< is_undeterminated< A1 >::value &&is_error< result_type >::value,result_type,A1 >::type first_argument_type
Definition: expression.h:1721
std::conditional< is_scalar< R >::value, tensor3_basic< A2 >, E >::type second_argument_type
Definition: expression.h:1746
std::conditional< is_scalar< R >::value, tensor3_basic< A2 >, E >::type second_argument_type
Definition: expression.h:1759
std::conditional< is_scalar< R >::value, tensor3_basic< A1 >, E >::type first_argument_type
Definition: expression.h:1757
std::conditional< is_scalar< R >::value, tensor3_basic< A1 >, E >::type first_argument_type
Definition: expression.h:1736
std::conditional< is_undeterminated< A1 >::value, T, A1 >::type first_argument_type
Definition: expression.h:1709
std::conditional< is_undeterminated< A2 >::value, T, A2 >::type second_argument_type
Definition: expression.h:1710
hint< Arg1, Arg2, undeterminated_basic< Float > >::result_type type
Definition: expression.h:1785
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:1703
std::conditional< is_undeterminated< A2 >::value &&is_error< result_type >::value,result_type,A2 >::type second_argument_type
Definition: expression.h:1574
std::conditional< is_undeterminated< A1 >::value &&is_error< result_type >::value,result_type,A1 >::type first_argument_type
Definition: expression.h:1569
std::conditional< is_scalar< R >::value, tensor_basic< A2 >, E >::type second_argument_type
Definition: expression.h:1594
std::conditional< is_scalar< R >::value, tensor_basic< A1 >, E >::type first_argument_type
Definition: expression.h:1584
std::conditional< is_scalar< R >::value, tensor_basic< A2 >, E >::type second_argument_type
Definition: expression.h:1621
std::conditional< is_scalar< R >::value, tensor_basic< A1 >, E >::type first_argument_type
Definition: expression.h:1619
std::conditional< is_undeterminated< A1 >::value, T, A1 >::type first_argument_type
Definition: expression.h:1557
std::conditional< is_undeterminated< A2 >::value, T, A2 >::type second_argument_type
Definition: expression.h:1558
hint< Arg1, Arg2, undeterminated_basic< Float > >::result_type type
Definition: expression.h:1672
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:1551
promote< typename scalar_traits< A1 >::type, typename scalar_traits< R >::type >::type S
Definition: expression.h:1314
std::conditional< details::is_equal< A1, R >::value, S, binop_error< details::divides, A1, A2, R > >::type second_argument_type
Definition: expression.h:1319
std::conditional< details::is_scalar< A2 >::value, undeterminated_basic< A1 >, binop_error< details::divides, A1, A2, R > >::type first_argument_type
Definition: expression.h:1345
std::conditional< details::is_scalar< A2 >::value, R, binop_error< details::divides, A1, A2, R > >::type first_argument_type
Definition: expression.h:1305
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:1359
std::conditional< is_undeterminated< R >::value,typename std::conditional< is_good::value,S,binop_error< details::dot_, A1, A2, R > >::type,R >::type result_type
Definition: expression.h:1509
std::conditional< is_undeterminated< A2 >::value,typename std::conditional< is_good::value,point_basic< S2 >,binop_error< details::dot_, A1, A2, R > >::type,A2 >::type second_argument_type
Definition: expression.h:1500
details::and_type< details::or_type< details::is_point< A1 >,is_undeterminated< A1 > >,details::or_type< details::is_point< A2 >,is_undeterminated< A2 > >,details::or_type< details::is_scalar< R >,is_undeterminated< R > > >::type is_good
Definition: expression.h:1482
std::conditional< is_undeterminated< A1 >::value,typename std::conditional< is_good::value,point_basic< S1 >,binop_error< details::dot_, A1, A2, R > >::type,A1 >::type first_argument_type
Definition: expression.h:1491
promote< typename float_traits< Arg1 >::type, typename float_traits< Arg2 >::type >::type type
Definition: expression.h:1462
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:1457
hint< A1, A2, undeterminated_basic< Float > >::result_type type
Definition: expression.h:555
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:558
binop_error< details::multiplies, undeterminated_basic< A2 >, tensor3_basic< A2 >, point_basic< R > > type
Definition: expression.h:839
binop_error< details::multiplies, undeterminated_basic< A2 >, point_basic< A2 >, tensor3_basic< R > > type
Definition: expression.h:804
binop_error< details::multiplies, undeterminated_basic< A2 >, tensor_basic< A2 >, point_basic< R > > type
Definition: expression.h:819
binop_error< details::multiplies, undeterminated_basic< S >, tensor4_basic< A2 >, tensor3_basic< R > > type
Definition: expression.h:874
binop_error< details::multiplies, undeterminated_basic< S >, tensor4_basic< A2 >, point_basic< R > > type
Definition: expression.h:862
binop_error< details::multiplies, undeterminated_basic< A2 >, tensor3_basic< A2 >, tensor_basic< R > > type
Definition: expression.h:844
binop_error< details::multiplies, undeterminated_basic< S >, tensor4_basic< A2 >, tensor_basic< R > > type
Definition: expression.h:868
binop_error< details::multiplies, undeterminated_basic< A2 >, point_basic< A2 >, tensor4_basic< R > > type
Definition: expression.h:809
hint< Arg1, Arg2, undeterminated_basic< Float > >::result_type type
Definition: expression.h:1151
binop_error< details::multiplies, tensor_basic< A1 >, undeterminated_basic< A1 >, tensor3_basic< R > > type
Definition: expression.h:948
binop_error< details::multiplies, tensor4_basic< A1 >, undeterminated_basic< A1 >, point_basic< R > > type
Definition: expression.h:979
binop_error< details::multiplies, tensor4_basic< A1 >, undeterminated_basic< A1 >, tensor_basic< R > > type
Definition: expression.h:984
binop_error< details::multiplies, tensor3_basic< A1 >, undeterminated_basic< A1 >, point_basic< R > > type
Definition: expression.h:958
binop_error< details::multiplies, tensor4_basic< A1 >, undeterminated_basic< A1 >, tensor3_basic< R > > type
Definition: expression.h:989
binop_error< details::multiplies, point_basic< A1 >, undeterminated_basic< A1 >, tensor3_basic< R > > type
Definition: expression.h:943
binop_error< details::multiplies, tensor_basic< A1 >, undeterminated_basic< A1 >, tensor_basic< R > > type
Definition: expression.h:923
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:754
std::conditional< details::is_equal< A1, R >::value, R, binop_error< details::plus, A1, A2, R > >::type second_argument_type
Definition: expression.h:500
std::conditional< details::is_equal< A2, R >::value, R, binop_error< details::plus, A1, A2, R > >::type first_argument_type
Definition: expression.h:488
hint< Arg1, Arg2, undeterminated_basic< Float > >::result_type type
Definition: expression.h:538
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:532
generic_binary_traits< BinaryFunction >::template hint< A2, A1, Result > base
Definition: expression.h:1917
static space_constant::valued_type valued_tag(space_constant::valued_type arg1_tag, space_constant::valued_type arg2_tag)
Definition: expression.h:1923
static space_constant::valued_type valued_tag(space_constant::valued_type, space_constant::valued_type)
Definition: expression.h:422
std::decay< typename function_traits< Function >::template arg< 0 >::type >::type argument_type
Definition: expression.h:197
function_traits< Function >::result_type result_type
Definition: expression.h:195
function_traits< Function >::result_type type
Definition: expression.h:191
generic_binary_traits< BinaryFunction >::template result_hint< A1, A2 >::type type
Definition: expression.h:1811
static space_constant::valued_type valued_tag(space_constant::valued_type arg_tag)
Definition: expression.h:1840
generic_binary_traits< BinaryFunction >::template hint< A1, undeterminated_basic< T >, R >::second_argument_type argument_type
Definition: expression.h:1829
generic_binary_traits< BinaryFunction >::template hint< A1, undeterminated_basic< T >, undeterminated_basic< T > >::result_type result_type
Definition: expression.h:1837
generic_binary_traits< BinaryFunction >::template hint< A1, undeterminated_basic< T1 >, undeterminated_basic< T > >::second_argument_type argument_type
Definition: expression.h:1835
generic_binary_traits< BinaryFunction >::template hint< undeterminated_basic< T >, A2, R >::first_argument_type argument_type
Definition: expression.h:1880
generic_binary_traits< BinaryFunction >::template hint< undeterminated_basic< T1 >, A2, undeterminated_basic< T > >::first_argument_type argument_type
Definition: expression.h:1886
generic_binary_traits< BinaryFunction >::template hint< undeterminated_basic< T >, A2, undeterminated_basic< T > >::result_type result_type
Definition: expression.h:1888
generic_binary_traits< BinaryFunction >::template result_hint< A1, A2 >::type type
Definition: expression.h:1862
static space_constant::valued_type valued_tag(space_constant::valued_type arg_tag)
Definition: expression.h:1891
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:246
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:396
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:369
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:319
promote< typename scalar_traits< A1 >::type, typename scalar_traits< R >::type >::type S
Definition: expression.h:337
tensor_basic< typename scalar_traits< A1 >::type > type
Definition: expression.h:333
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:342
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:224
static space_constant::valued_type valued_tag(space_constant::valued_type)
Definition: expression.h:200
plus_result< T1, T2 >::type operator()(const T1 &a, const T2 &b) const
Definition: expression.h:546
binop_error< details::multiplies, point_basic< S1 >, point_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:628
binop_error< details::multiplies, point_basic< S1 >, tensor3_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:679
binop_error< details::multiplies, point_basic< S1 >, tensor4_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:707
binop_error< details::multiplies, point_basic< S1 >, tensor_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:634
binop_error< details::multiplies, tensor3_basic< S1 >, tensor3_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:691
binop_error< details::multiplies, tensor3_basic< S1 >, tensor4_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:719
binop_error< details::multiplies, tensor4_basic< S1 >, point_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:725
binop_error< details::multiplies, tensor4_basic< S1 >, tensor3_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:737
binop_error< details::multiplies, tensor4_basic< S1 >, tensor4_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:743
binop_error< details::multiplies, tensor4_basic< S1 >, tensor_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:731
binop_error< details::multiplies, tensor_basic< S1 >, tensor3_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:685
binop_error< details::multiplies, tensor_basic< S1 >, tensor4_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:713
promote< A1, A2 >::type type
Definition: expression.h:607
multiplies_result< T1, T2 >::type operator()(const T1 &a, const T2 &b) const
Definition: expression.h:749
T operator()(const T &a) const
Definition: expression.h:232
float_traits< T >::type operator()(const T &x) const
Definition: expression.h:378
float_traits< T >::type operator()(const T &x) const
Definition: expression.h:351
binop_error< details::plus, A1, A2, undeterminated_basic< Float > > type
Definition: expression.h:437
plus_result< T1, T2 >::type operator()(const T1 &a, const T2 &b) const
Definition: expression.h:459
std::conditional< is_undeterminated< A1 >::value,typename std::conditional< is_good::value,S1,binop_error< F, A1, A2, R > >::type,A1 >::type first_argument_type
Definition: expression.h:1406
details::and_type< details::or_type< details::is_scalar< A1 >,is_undeterminated< A1 > >,details::or_type< details::is_scalar< A2 >,is_undeterminated< A2 > >,details::or_type< details::is_scalar< R >,is_undeterminated< R > > >::type is_good
Definition: expression.h:1397
std::conditional< is_undeterminated< A2 >::value,typename std::conditional< is_good::value,S2,binop_error< F, A1, A2, R > >::type,A2 >::type second_argument_type
Definition: expression.h:1415
std::conditional< is_undeterminated< R >::value,typename std::conditional< is_good::value,S,binop_error< F, A1, A2, R > >::type,R >::type result_type
Definition: expression.h:1424
promote< typename scalar_traits< Arg1 >::type, typename scalar_traits< Arg2 >::type >::type type
Definition: expression.h:1377
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:1372
swapper(const BinaryFunction &f)
Definition: expression.h:1903
generic_binary_traits< BinaryFunction >::template result_hint< A2, A1 >::type operator()(const A1 &x1, const A2 &x2) const
Definition: expression.h:1906
tensor_basic< T > operator()(const tensor_basic< T > &a) const
Definition: expression.h:327
T operator()(const T &a) const
Definition: expression.h:210
helper for std::complex<T>: get basic T type
Definition: Float.h:93
helper for generic field value_type: T, point_basic<T> or tensor_basic<T>