Rheolef  7.1
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 {
128 } // namespace rheolef
129 
130 /*
131 This file "expression.h" focuses on operators between fields
132 since the field return value (scalar,vector,tensor) is not known
133 at compile time, operators try to infer it when the return type
134 or a second argument is known at compile time
135 
136 optherwise, the return value is undeterminated_basic<T> that
137 will be solved at run time from the field::valued_tag() method.
138 
139 OVERVIEW:
140  0. error utilities
141  1. unary operations
142  1.1. unary function helper
143  1.2. unary operators: +x -x
144  1.3. unary standard maths: sin(x), cos(x), ...
145  1.4. unary extensions: tr(x), trans(x), norm(x) norm2(x)
146  2. binary operations
147  2.1. binary function helper
148  2.2. binary operators: x+y, x-y, x*y, x/y
149  2.3. binary standard maths: pow(x,y), atan2(x,y),...
150  2.4. binary extensions: dot(x,y), ddot(x,y)
151  3. binders
152  3.1. binder_first
153  3.2. binder_second
154  3.3. swapper
155 */
156 #include "rheolef/promote.h"
157 #include "rheolef/undeterminated.h"
158 #include "rheolef/space_constant.h"
159 
160 namespace rheolef { namespace details {
161 
162 // ===========================================================================
163 // part 0. error utilities
164 // ===========================================================================
165 template<class Op, class T1, class T2, class R>
166 struct binop_error {};
167 
168 template <class T> struct is_error: std::false_type {};
169 
170 template<class Op, class T1, class T2, class R>
171 struct is_error<binop_error<Op,T1,T2,R> >: std::true_type {};
172 
173 } // namespace details
174 
175 template<class Op, class T1, class T2, class R>
176 struct float_traits<details::binop_error<Op,T1,T2,R> > { typedef typename float_traits<R>::type type; };
177 
178 // ===========================================================================
179 // part 1. unary operations
180 // ===========================================================================
181 namespace details {
182 // ---------------------------------------------------------------------------
183 // chap 1.1. unary function helper
184 // ---------------------------------------------------------------------------
185 // defualt is STL class-functions
186 template<class Function>
188  template <class Arg>
189  struct result_hint {
191  };
192  template <class Arg, class Result>
193  struct hint {
195  typedef typename std::decay<typename function_traits<Function>::template arg<0>::type>::type
197  };
201  }
202 };
203 // ----------------------------------------------------------------------------
204 // chap 1.2. unary operators: +x -x
205 // ----------------------------------------------------------------------------
206 // +x
207 // ------
208 struct unary_plus {
209  template <class T> T operator() (const T& a) const { return +a; }
210 };
211 template<>
213  template <class Arg>
214  struct result_hint {
215  typedef Arg type;
216  };
217  template <class Arg, class Result>
218  struct hint {
221  };
224  return tag;
225  }
226 };
227 // ------
228 // -x
229 // ------
230 struct negate {
231  template <class T> T operator() (const T& a) const { return -a; }
232 };
233 template<>
235  template <class Arg>
236  struct result_hint {
237  typedef Arg type;
238  };
239  template <class Arg, class Result>
240  struct hint {
243  };
246  return tag;
247  }
248 };
249 // ----------------------------------------------------------------------------
250 // chap 1.3. unary standard maths: sin(x), cos(x), ...
251 // ----------------------------------------------------------------------------
252 // specialization for is scalar generic functions, as details::sin_, details::cos_, etc
253 #define _RHEOLEF_generic_unary_scalar(F) \
254 struct F##_ { \
255  template<class T> \
256  T operator() (const T& x) const { return F(x); } \
257 }; \
258 template<> \
259 struct generic_unary_traits<F##_> { \
260  template <class Arg> \
261  struct result_hint { \
262  typedef typename scalar_traits<Arg>::type type; \
263  }; \
264  template <class Arg, class Result> \
265  struct hint { \
266  typedef typename promote< \
267  typename scalar_traits<Arg>::type \
268  ,typename scalar_traits<Result>::type>::type S; \
269  typedef S result_type; \
270  typedef S argument_type; \
271  }; \
272  static space_constant::valued_type \
273  valued_tag (space_constant::valued_type) { \
274  return space_constant::scalar; \
275  } \
276 };
277 // std::cmath
295 // rheolef extension:
297 #undef _RHEOLEF_generic_unary_scalar
298 // ----------------------------------------------------------------------------
299 // chap 1.4. unary extensions: tr(x), norm(x) norm2(x)
300 // ----------------------------------------------------------------------------
301 // tr(tau)
302 // ----------
303 struct tr_ {
304  template <class T> T operator() (const tensor_basic<T>& a) const { return tr(a); }
305 };
306 template<>
307 struct generic_unary_traits<tr_> {
308  template <class A1>
309  struct result_hint {
310  typedef typename scalar_traits<A1>::type type;
311  };
312  template <class A1, class R>
313  struct hint {
316  };
319  return space_constant::scalar;
320  }
321 };
322 // ----------
323 // trans(tau)
324 // ----------
325 struct trans_ {
326  template <class T> tensor_basic<T> operator() (const tensor_basic<T>& a) const { return trans(a); }
327 };
328 template<>
330  template <class A1>
331  struct result_hint {
333  };
334  template <class A1, class R>
335  struct hint {
339  };
343  }
344 };
345 // ----------
346 // norm(x)
347 // ----------
348 struct norm_ {
349  template<class T>
350  typename float_traits<T>::type operator() (const T& x) const { return fabs(x); }
351  template<class T>
352  typename float_traits<T>::type operator() (const point_basic<T>& x) const { return norm(x); }
353  template<class T>
354  typename float_traits<T>::type operator() (const tensor_basic<T>& x) const { return norm(x); }
355 };
356 template<>
358  template <class Arg>
359  struct result_hint {
360  typedef typename float_traits<Arg>::type type;
361  };
362  template <class A1, class R>
363  struct hint {
365  typedef A1 argument_type;
366  };
369  return space_constant::scalar;
370  }
371 };
372 // ----------
373 // norm2(x)
374 // ----------
375 struct norm2_ {
376  template<class T>
377  typename float_traits<T>::type operator() (const T& x) const { return sqr(x); }
378  template<class T>
379  typename float_traits<T>::type operator() (const point_basic<T>& x) const { return norm2(x); }
380  template<class T>
381  typename float_traits<T>::type operator() (const tensor_basic<T>& x) const { return norm2(x); }
382 };
383 template<>
385  template <class Arg>
386  struct result_hint {
387  typedef typename float_traits<Arg>::type type;
388  };
389  template <class A1, class R>
390  struct hint {
392  typedef A1 argument_type;
393  };
396  return space_constant::scalar;
397  }
398 };
399 // ===========================================================================
400 // part 2. binary operations
401 // ===========================================================================
402 // ---------------------------------------------------------------------------
403 // chap 2.1. binary function helper
404 // ---------------------------------------------------------------------------
405 template<class Function>
407  template <class Arg1, class Arg2>
408  struct result_hint {
410  };
411  template <class Arg1, class Arg2, class Result>
412  struct hint {
413  typedef typename std::decay<typename function_traits<Function>::template arg<0>::type>::type
415  typedef typename std::decay<typename function_traits<Function>::template arg<1>::type>::type
417  typedef typename std::decay<typename function_traits<Function>::result_type>::type
419  };
423  }
424 };
425 // ----------------------------------------------------------------------------
426 // chap 2.2. binary operators: x+y, x-y, x*y, x/y
427 // ----------------------------------------------------------------------------
428 // x+y
429 // --------
430 struct plus; // foward declaration
431 
432 // result type
433 // -----------
434 template <class A1, class A2, class Sfinae = void>
435 struct plus_result {
437 };
438 // s+s -> s
439 template <class A1, class A2>
440 struct plus_result<A1,A2,
441  typename std::enable_if<
442  is_rheolef_arithmetic<A1>::value &&
443  is_rheolef_arithmetic<A2>::value
444  >::type>
445 {
446  typedef typename promote<A1,A2>::type type;
447 };
448 // v+v -> v, t+t -> t
449 template <class A>
450 struct plus_result<A,A,
451  typename std::enable_if<
452  ! is_rheolef_arithmetic<A>::value>::type>
453 {
454  typedef A type;
455 };
456 struct plus {
457  template <class T1, class T2>
458  typename plus_result<T1,T2>::type operator() (const T1& a, const T2& b) const { return a+b; }
459 };
460 template<>
462  // --------------------------
463  // hint interface
464  // --------------------------
465  template <class A1, class A2, class R>
466  struct hint {
469  typedef R result_type;
470  };
471  // two types are known
472  // --------------------------
473  // a1+a2 -> ? : deduce r
474  template <class A1, class A2, class R>
475  struct hint<A1,A2,undeterminated_basic<R> > {
479  };
480  // ?+a2 -> r : deduce a1
481  template <class A1, class A2, class R>
482  struct hint<undeterminated_basic<A1>,A2,R> {
483  typedef typename std::conditional<
485  R,
489  typedef R result_type;
490  };
491  // a1+? -> r : deduce a2
492  template <class A1, class A2, class R>
493  struct hint<A1,undeterminated_basic<A2>,R> {
495  typedef typename std::conditional<
497  R,
500  typedef R result_type;
501  };
502  // ?+? -> r : deduce a1,a2
503  template <class A1, class A2, class R>
507  typedef R result_type;
508  };
509  // a1+? -> ? : deduce a2,r
510  template <class A1, class A2, class R>
511  struct hint<A1,undeterminated_basic<A2>,undeterminated_basic<R> > {
514  typedef A1 result_type;
515  };
516  // ?+a2 -> ? : deduce a2,r
517  template <class A1, class A2, class R>
518  struct hint<undeterminated_basic<A1>,A2, undeterminated_basic<R> > {
521  typedef A2 result_type;
522  };
523  // ?+? -> ? : deduce a1, a2,r
524  template <class A1, class A2, class R>
529  };
532  return (tag2 == space_constant::last_valued) ? tag1 : tag2;
533  }
534  typedef std::true_type is_symmetric;
535  template <class Arg1, class Arg2>
536  struct result_hint {
537  typedef typename hint<Arg1,Arg2,undeterminated_basic<Float> >::result_type type;
538  };
539 };
540 // --------
541 // x-y
542 // --------
543 struct minus {
544  template <class T1, class T2>
545  typename plus_result<T1,T2>::type operator() (const T1& a, const T2& b) const { return a-b; }
546 };
547 template<>
549  template <class A1, class A2, class R>
550  struct hint : generic_binary_traits<plus>::template hint<A1,A2,R> {};
551 
552  template <class A1, class A2>
553  struct result_hint {
554  typedef typename hint<A1,A2,undeterminated_basic<Float> >::result_type type;
555  };
558  return (tag2 == space_constant::last_valued) ? tag1 : tag2;
559  }
560  typedef std::false_type is_symmetric;
561 };
562 // --------
563 // x*y
564 // --------
565 /*
566  result: when arg1 & arg2 are given
567  1\2 s v t t3 t4
568  s s v t t3 t4
569  v v E E E E
570  t t v t E E
571  t3 t3 t t3 E E
572  t4 t4 E E E E
573 
574  arg1: deduced when arg2 & result are known
575  2\r s v t t3 t4
576  s s v t t3 t4
577  v E (st)t3 E E
578  t E E (st)t3 E st: indetermine'
579  t3 E E E s E
580  t4 E E E E s
581 
582  arg2: deduced when arg1 & result are known
583  1\r s v t t3 t4
584  s s v t t3 t4
585  v E s E E E
586  t E v (st)E E st: indetermine'
587  t3 E E v (st) E
588  t4 E E E E E
589 
590  il n'y a que deux cas ou l'arg1 est indetermine' :
591  quand arg2=v et res_t=v alors arg1=s ou t
592  quand arg2=t et res_t=t alors arg1=s ou t
593  dans tous les autres cas, on deduit l'arg1
594 
595  il n'y a qu'un cas ou l'arg2 est indetermine' :
596  quand arg1=t et res_t=t alors arg2=s ou t
597  dans tous les autres cas, on deduit l'arg2
598 */
599 struct multiplies; // foward declaration
600 
601 // result type
602 // -----------
603 // s*s -> s
604 template <class A1, class A2>
606  typedef typename promote<A1,A2>::type type;
607 };
608 // s*v -> v
609 template <class S>
612 };
613 // s*t -> t
614 template <class S>
617 };
618 // v*s -> v
619 template <class S>
622 };
623 // v*v -> err
624 template <class S1, class S2>
626  typedef typename promote<S1,S2>::type S;
628 };
629 // v*t -> err
630 template <class S1, class S2>
632  typedef typename promote<S1,S2>::type S;
634 };
635 // t*s -> t
636 template <class S>
639 };
640 // t*v -> v
641 template <class S1, class S2>
643  typedef typename promote<S1,S2>::type S;
645 };
646 // t*t -> t
647 template <class S1, class S2>
649  typedef typename promote<S1,S2>::type S;
651 };
652 // s*t3 -> t3
653 template <class S>
656 };
657 // t*s -> t
658 template <class S>
661 };
662 // t3*v -> t
663 template <class S1, class S2>
665  typedef typename promote<S1,S2>::type S;
667 };
668 // t3*t -> t3
669 template <class S1, class S2>
671  typedef typename promote<S1,S2>::type S;
673 };
674 // v*t3 -> err
675 template <class S1, class S2>
677  typedef typename promote<S1,S2>::type S;
679 };
680 // t*t3 -> err
681 template <class S1, class S2>
683  typedef typename promote<S1,S2>::type S;
685 };
686 // t3*t3 -> err
687 template <class S1, class S2>
689  typedef typename promote<S1,S2>::type S;
691 };
692 // s*t4 -> t4
693 template <class S>
696 };
697 // t4*s -> t4
698 template <class S>
701 };
702 // v*t4 -> err
703 template <class S1, class S2>
705  typedef typename promote<S1,S2>::type S;
707 };
708 // t*t4 -> err
709 template <class S1, class S2>
711  typedef typename promote<S1,S2>::type S;
713 };
714 // t3*t4 -> err
715 template <class S1, class S2>
717  typedef typename promote<S1,S2>::type S;
719 };
720 // t4*v -> err
721 template <class S1, class S2>
723  typedef typename promote<S1,S2>::type S;
725 };
726 // t4*t -> err
727 template <class S1, class S2>
729  typedef typename promote<S1,S2>::type S;
731 };
732 // t4*t3 -> err
733 template <class S1, class S2>
735  typedef typename promote<S1,S2>::type S;
737 };
738 // t4*t4 -> err
739 template <class S1, class S2>
741  typedef typename promote<S1,S2>::type S;
743 };
744 
745 struct multiplies {
746  template <class T1, class T2>
748  operator() (const T1& a, const T2& b) const { return a*b; }
749 };
750 template<>
754  return space_constant::multiplies_result_tag(tag1,tag2);
755  }
756  // --------------------------
757  // hint arg1 type
758  // --------------------------
759  // ?*s=s => a1=s
760  template <class A2, class R, class Sfinae = void>
761  struct first_argument_hint {
762  typedef typename promote<A2,R>::type type;
763  };
764  // ?*s=v => a1=v
765  template <class A2, class R>
766  struct first_argument_hint<A2,point_basic<R> > {
768  };
769  // ?*s=t => a1=t
770  template <class A2, class R>
771  struct first_argument_hint<A2,tensor_basic<R> > {
773  };
774  // ?*s=t3 => a1=t3
775  template <class A2, class R>
776  struct first_argument_hint<A2,tensor3_basic<R> > {
778  };
779  // ?*s=t4 => a1=t4
780  template <class A2, class R>
781  struct first_argument_hint<A2,tensor4_basic<R>,
782  typename std::enable_if<is_rheolef_arithmetic<A2>::value>::type> {
784  };
785  // ?*v=s => a1=err
786  template <class A2, class R>
787  struct first_argument_hint<point_basic<A2>,R> {
789  };
790  // ?*v=v => a1={s,t}=undeterminated
791  template <class A2, class R>
792  struct first_argument_hint<point_basic<A2>,point_basic<R> > {
794  };
795  // ?*v=t => a1=t3
796  template <class A2, class R>
797  struct first_argument_hint<point_basic<A2>,tensor_basic<R> > {
799  };
800  // ?*v=t3 => a1=err
801  template <class A2, class R>
802  struct first_argument_hint<point_basic<A2>,tensor3_basic<R> > {
804  };
805  // ?*v=t4 => a1=err
806  template <class A2, class R>
807  struct first_argument_hint<point_basic<A2>,tensor4_basic<R> > {
809  };
810  // ?*t=s => a1=err
811  template <class A2, class R>
812  struct first_argument_hint<tensor_basic<A2>,R> {
814  };
815  // ?*t=v => a1=err
816  template <class A2, class R>
817  struct first_argument_hint<tensor_basic<A2>,point_basic<R> > {
819  };
820  // ?*t=t => a1={s,t}=undeterminated
821  template <class A2, class R>
822  struct first_argument_hint<tensor_basic<A2>,tensor_basic<R> > {
824  };
825  // ?*t=t3 => a1=t3
826  template <class A2, class R>
827  struct first_argument_hint<tensor_basic<A2>,tensor3_basic<R> > {
829  };
830  // ?*t3=s => a1=err
831  template <class A2, class R>
832  struct first_argument_hint<tensor3_basic<A2>,R> {
834  };
835  // ?*t3=v => a1=err
836  template <class A2, class R>
837  struct first_argument_hint<tensor3_basic<A2>,point_basic<R> > {
839  };
840  // ?*t3=t => a1=err
841  template <class A2, class R>
842  struct first_argument_hint<tensor3_basic<A2>,tensor_basic<R> > {
844  };
845  // ?*t3=t3 => a1=s
846  template <class A2, class R>
847  struct first_argument_hint<tensor3_basic<A2>,tensor3_basic<R> > {
848  typedef typename promote<A2,R>::type type;
849  };
850  // ?*t4=s => a1=E
851  template <class A2, class R>
852  struct first_argument_hint<tensor4_basic<A2>,R,
853  typename std::enable_if<is_rheolef_arithmetic<R>::value>::type> {
854  typedef typename promote<A2,R>::type S;
856  };
857  // ?*t4=v => a1=E
858  template <class A2, class R>
859  struct first_argument_hint<tensor4_basic<A2>,point_basic<R> > {
860  typedef typename promote<A2,R>::type S;
862  };
863  // ?*t4=t => a1=E
864  template <class A2, class R>
865  struct first_argument_hint<tensor4_basic<A2>,tensor_basic<R> > {
866  typedef typename promote<A2,R>::type S;
868  };
869  // ?*t4=t3 => a1=E
870  template <class A2, class R>
871  struct first_argument_hint<tensor4_basic<A2>,tensor3_basic<R> > {
872  typedef typename promote<A2,R>::type S;
874  };
875  // ?*t4=t4 => a1=s
876  template <class A2, class R>
877  struct first_argument_hint<tensor4_basic<A2>,tensor4_basic<R> > {
878  typedef typename promote<A2,R>::type type;
879  };
880  // --------------------------
881  // hint arg2 type
882  // --------------------------
883  // s*?=s => a2=s
884  template <class A1, class R, class Sfinae = void>
885  struct second_argument_hint {
886  typedef typename promote<A1,R>::type type;
887  };
888  // s*?=v => a2=v
889  template <class A1, class R>
890  struct second_argument_hint<A1,point_basic<R> > {
892  };
893  // s*?=t => a2=t
894  template <class A1, class R>
895  struct second_argument_hint<A1,tensor_basic<R> > {
897  };
898  // s*?=t3 => a2=t3
899  template <class A1, class R>
900  struct second_argument_hint<A1,tensor3_basic<R> > {
902  };
903  // s*?=t4 => a2=t4
904  template <class A1, class R>
905  struct second_argument_hint<A1,tensor4_basic<R>,
906  typename std::enable_if<is_rheolef_arithmetic<A1>::value>::type> {
908  };
909  // v*?=s => a2=err
910  template <class A1, class R>
911  struct second_argument_hint<point_basic<A1>,R> {
913  };
914  // v*?=v => a2=s
915  template <class A1, class R>
916  struct second_argument_hint<point_basic<A1>,point_basic<R> > {
917  typedef typename promote<A1,R>::type type;
918  };
919  // v*?=t => a2=err
920  template <class A1, class R>
921  struct second_argument_hint<point_basic<A1>,tensor_basic<R> > {
923  };
924  // t*?=s => a2=err
925  template <class A1, class R>
926  struct second_argument_hint<tensor_basic<A1>,R> {
928  };
929  // t*?=v => a2=v
930  template <class A1, class R>
931  struct second_argument_hint<tensor_basic<A1>,point_basic<R> > {
933  };
934  // t*?=t => a2={s,t}=undeterminated
935  template <class A1, class R>
936  struct second_argument_hint<tensor_basic<A1>,tensor_basic<R> > {
938  };
939  // v*?=t3 => a2=err
940  template <class A1, class R>
941  struct second_argument_hint<point_basic<A1>,tensor3_basic<R> > {
943  };
944  // t*?=t3 => a2=err
945  template <class A1, class R>
946  struct second_argument_hint<tensor_basic<A1>,tensor3_basic<R> > {
948  };
949  // t3*?=s => a2=err
950  template <class A1, class R>
951  struct second_argument_hint<tensor3_basic<A1>,R > {
953  };
954  // t3*?=v => a2=err
955  template <class A1, class R>
956  struct second_argument_hint<tensor3_basic<A1>,point_basic<R> > {
958  };
959  // t3*?=t => a2=v
960  template <class A1, class R>
961  struct second_argument_hint<tensor3_basic<A1>,tensor_basic<R> > {
963  };
964  // t3*?=t3 => a2={st}
965  template <class A1, class R>
966  struct second_argument_hint<tensor3_basic<A1>,tensor3_basic<R> > {
968  };
969  // t4*?=s => a2=err
970  template <class A1, class R>
971  struct second_argument_hint<tensor4_basic<A1>,R,
972  typename std::enable_if<is_rheolef_arithmetic<R>::value>::type> {
974  };
975  // t4*?=v => a2=err
976  template <class A1, class R>
977  struct second_argument_hint<tensor4_basic<A1>,point_basic<R> > {
979  };
980  // t4*?=t => a2=err
981  template <class A1, class R>
982  struct second_argument_hint<tensor4_basic<A1>,tensor_basic<R> > {
984  };
985  // t4*?=t3 => a2=err
986  template <class A1, class R>
987  struct second_argument_hint<tensor4_basic<A1>,tensor3_basic<R> > {
989  };
990  // t4*?=t4 => a2=err
991  template <class A1, class R>
992  struct second_argument_hint<tensor4_basic<A1>,tensor4_basic<R> > {
993  typedef typename promote<A1,R>::type S;
994  typedef S type;
995  };
996  // --------------------------
997  // hint interface
998  // --------------------------
999  template <class A1, class A2, class R>
1000  struct hint {
1003  typedef R result_type;
1004  };
1005  // two types are known
1006  // --------------------------
1007  // a1*a2 -> ? : deduce r
1008  template <class A1, class A2, class R>
1009  struct hint<A1,A2,undeterminated_basic<R> > {
1013  };
1014  // ?*a2 -> r : deduce a1
1015  template <class A1, class A2, class R>
1016  struct hint<undeterminated_basic<A1>,A2,R> {
1017  // TODO: promote scalar_type of first arg: tensor<Float>*point<complex> -> point<complex>
1018  // promote_valued<Arg,Scalar>::type
1019  // e.g. promote_valued<point_basic<Float>,complex<Float> >::type -> point_basic<cmplex<Float>>
1022  typedef R result_type;
1023  };
1024  // a1*? -> r : deduce a2
1025  template <class A1, class A2, class R>
1026  struct hint<A1,undeterminated_basic<A2>,R> {
1029  typedef R result_type;
1030  };
1031  // only one type is known
1032  // -----------------------
1033  // ?*? -> s : deduce a1=a2=s
1034  template <class A1, class A2, class R>
1038  typedef R result_type;
1039  };
1040  // ?*? -> v : deduce (a1,a2)={(s,v),(v,s),(t,v)}=?
1041  template <class A1, class A2, class R>
1046  };
1047  // ?*? -> t : deduce (a1,a2)={(s,t),(t,s),(t,t)}=?
1048  template <class A1, class A2, class R>
1053  };
1054  // ?*? -> t3 : deduce (a1,a2)={(s,t3),(t3,s),(t3,t)}=?
1055  template <class A1, class A2, class R>
1060  };
1061  // ?*? -> t4 : deduce (a1,a2)={(s,t4),(t4,s)}=?
1062  template <class A1, class A2, class R>
1067  };
1068  // s*? -> ? : deduce (a2,r)={(s,s),(v,v),(t,t)}=?
1069  template <class A1, class A2, class R>
1070  struct hint<A1,undeterminated_basic<A2>,undeterminated_basic<R> > {
1074  };
1075  // v*? -> ? : deduce (a2,r)=(s,v)
1076  template <class A1, class A2, class R>
1081  };
1082  // t*? -> ? : deduce (a2,r)={(v,v),(t,t),(s,t)}=?
1083  template <class A1, class A2, class R>
1088  };
1089  // t3*? -> ? : deduce (a2,r)={(s,t3),(v,t),(t3,t3)}=?
1090  template <class A1, class A2, class R>
1095  };
1096  // ?*s -> ? : deduce (a1,r)={(s,s),(v,v),(t,t)}=?
1097  template <class A1, class A2, class R>
1098  struct hint<undeterminated_basic<A1>,A2,undeterminated_basic<R> > {
1102  };
1103  // ?*v -> ? : deduce (a1,r)={(s,v),(t,v)}=?
1104  template <class A1, class A2, class R>
1109  };
1110  // ?*t -> ? : deduce (a1,r)={(s,t),(t,t)}=?
1111  template <class A1, class A2, class R>
1116  };
1117  // ?*t3 -> ? : deduce (a1,r)=(s,t3)
1118  template <class A1, class A2, class R>
1123  };
1124  // ?*t4 -> ? : deduce (a1,r)=(s,t4)
1125  template <class A1, class A2, class R>
1130  };
1131  // t4*? -> ? : deduce (a2,r)=(s,t4)
1132  template <class A1, class A2, class R>
1137  };
1138  // none types are known
1139  // -----------------------
1140  // ?*? -> ? : deduce (a1,a2,r)=?
1141  template <class A1, class A2, class R>
1146  };
1147  // short interface
1148  template <class Arg1, class Arg2>
1149  struct result_hint {
1150  typedef typename hint<Arg1,Arg2,undeterminated_basic<Float> >::result_type type;
1151  };
1152  typedef std::false_type is_symmetric; // tensor*vector do not commute
1153 }; // generic_binary_traits<multiplies>
1154 // --------
1155 // x/y
1156 // --------
1157 struct divides; // foward declaration
1158 
1159 template <class T1, class T2, class Sfinae = void>
1162 };
1163 // s/s -> s
1164 template <class T1, class T2>
1165 struct divides_result<T1,T2,
1166  typename std::enable_if<
1167  is_rheolef_arithmetic<T1>::value &&
1168  is_rheolef_arithmetic<T2>::value
1169  >::type>
1170 {
1171  typedef typename promote<T1,T2>::type type;
1172 };
1173 // undef/undef -> undef
1174 template <class T1, class T2>
1175 struct divides_result<T1,T2,
1176  typename std::enable_if<
1177  is_undeterminated<T1>::value &&
1178  is_undeterminated<T2>::value
1179  >::type>
1180 {
1182 };
1183 // v/v -> err ; t/t -> err
1184 template <class T>
1186  typename std::enable_if<
1187  ! is_rheolef_arithmetic<T>::value
1188  && ! is_undeterminated<T>::value
1189 >::type>
1190 {
1191  typedef typename scalar_traits<T>::type S;
1193 };
1194 template <class T>
1197 };
1198 template <class T>
1201 };
1202 template <class T>
1205 };
1206 template <class T>
1209 };
1210 template <class T1, class T2>
1212  typedef typename promote<T1,T2>::type S;
1214 };
1215 template <class T1, class T2>
1217  typedef typename promote<T1,T2>::type S;
1219 };
1220 template <class T>
1223 };
1224 template <class T>
1227 };
1228 template <class T>
1231 };
1232 template <class T1, class T2>
1234  typedef typename promote<T1,T2>::type S;
1236 };
1237 template <class T1, class T2>
1239  typedef typename promote<T1,T2>::type S;
1241 };
1242 template <class T1, class T2>
1244  typedef typename promote<T1,T2>::type S;
1246 };
1247 template <class T1, class T2>
1249  typedef typename promote<T1,T2>::type S;
1251 };
1252 template <class T>
1255 };
1256 template <class T1, class T2>
1258  typedef typename promote<T1,T2>::type S;
1260 };
1261 template <class T1, class T2>
1263  typedef typename promote<T1,T2>::type S;
1265 };
1266 template <class T1, class T2>
1268  typedef typename promote<T1,T2>::type S;
1270 };
1271 struct divides {
1272  template <class T1, class T2>
1274  operator() (const T1& a, const T2& b) const { return a/b; }
1275 };
1276 template<>
1278  template <class Arg1, class Arg2>
1279  struct result_hint {
1281  };
1282  template <class Arg1, class Arg2, class Result>
1283  struct hint {
1284  typedef Arg1 first_argument_type;
1285  typedef Arg2 second_argument_type;
1286  typedef Result result_type;
1287  };
1288  // two types are known
1289  // --------------------------
1290  // a1/a2 -> ? : deduce r=a1 when a2=s (error otherwise)
1291  template <class A1, class A2, class R>
1292  struct hint<A1,A2,undeterminated_basic<R> > {
1296  };
1297  // ?/a2 -> r : deduce a1=r when a2=s (error otherwise)
1298  template <class A1, class A2, class R>
1299  struct hint<undeterminated_basic<A1>,A2,R> {
1300  typedef typename scalar_traits<A2>::type S2;
1301  typedef typename std::conditional<
1303  R,
1306  typedef R result_type;
1307  };
1308  // a1/? -> r : deduce a2=s when a1=r (error otherwise)
1309  template <class A1, class A2, class R>
1310  struct hint<A1,undeterminated_basic<A2>,R> {
1311  typedef typename promote<
1312  typename scalar_traits<A1>::type,
1315  typedef typename std::conditional<
1317  S,
1319  typedef R result_type;
1320  };
1321  // two types are unknown
1322  // --------------------------
1323  // ?/? -> r : deduce a1=r and a2=s
1324  template <class A1, class A2, class R>
1328  typedef R result_type;
1329  };
1330  // a1/? -> ? : deduce r=a1 and a2=s
1331  template <class A1, class A2, class R>
1332  struct hint<A1,undeterminated_basic<A2>,undeterminated_basic<R> > {
1335  typedef A1 result_type;
1336  };
1337  // ?/a2 -> ? : deduce r=a1=? and a2=s
1338  template <class A1, class A2, class R>
1339  struct hint<undeterminated_basic<A1>,A2,undeterminated_basic<R> > {
1340  typedef typename scalar_traits<A2>::type S2;
1341  typedef typename std::conditional<
1347  };
1348  // three types are unknown
1349  // -----------------------
1350  // ?/? -> ? : deduce a1=r=? and a2=s
1351  template <class A1, class A2, class R>
1356  };
1359  return space_constant::divides_result_tag(tag1,tag2);
1360  }
1361  typedef std::false_type is_symmetric;
1362 };
1363 // ----------------------------------------------------------------------------
1364 // chap 2.3. binary standard maths: pow(x,y), atan2(x,y),...
1365 // ----------------------------------------------------------------------------
1366 // specialization for scalar generic functions, as details::pow_, details::atan2_, etc
1367 //ICI
1368 template<class F>
1372  return space_constant::scalar;
1373  }
1374  template <class Arg1, class Arg2>
1375  struct result_hint {
1377  };
1378  template <class A1, class A2, class R>
1379  struct hint {
1380  typedef typename scalar_traits<A1>::type S1;
1381  typedef typename scalar_traits<A2>::type S2;
1382  typedef typename scalar_traits<R>::type S;
1383  typedef typename details::and_type<
1387  >
1391  >
1395  >
1397  typedef typename std::conditional<
1399  ,typename std::conditional<
1400  is_good::value
1401  ,S1
1403  >::type
1404  ,A1
1406  typedef typename std::conditional<
1408  ,typename std::conditional<
1409  is_good::value
1410  ,S2
1412  >::type
1413  ,A2
1415  typedef typename std::conditional<
1417  ,typename std::conditional<
1418  is_good::value
1419  ,S
1421  >::type
1422  ,R
1424  };
1425  typedef std::false_type is_symmetric;
1426 };
1427 #define _RHEOLEF_generic_binary_scalar(F) \
1428 struct F##_ { \
1429  template<class A1, class A2> \
1430  typename promote<A1,A2>::type \
1431  operator() (const A1& x, const A2& y) const { \
1432  typedef typename promote<A1,A2>::type R; \
1433  return F(R(x),R(y)); } \
1434 }; \
1435 template<> \
1436 struct generic_binary_traits<F##_> : scalar_binary_traits<F##_> {}; \
1437 
1443 #undef _RHEOLEF_generic_binary_scalar
1444 // ----------------------------------------------------------------------------
1445 // chap 2.4. binary extensions: dot(x,y), ddot(x,y)
1446 // ----------------------------------------------------------------------------
1447 // dot(x,y)
1448 // ------------
1449 struct dot_ {
1450  template<class T>
1451  T operator() (const point_basic<T>& x, const point_basic<T>& y) const { return dot(x,y); }
1452 };
1453 template<>
1457  return space_constant::scalar;
1458  }
1459  template <class Arg1, class Arg2>
1460  struct result_hint {
1462  };
1463  template <class A1, class A2, class R>
1464  struct hint {
1465  typedef typename scalar_traits<A1>::type S1;
1466  typedef typename scalar_traits<A2>::type S2;
1467  typedef typename scalar_traits<R>::type S;
1468  typedef typename details::and_type<
1472  >
1476  >
1480  >
1482  typedef typename std::conditional<
1484  ,typename std::conditional<
1485  is_good::value
1488  >::type
1489  ,A1
1491  typedef typename std::conditional<
1493  ,typename std::conditional<
1494  is_good::value
1497  >::type
1498  ,A2
1500  typedef typename std::conditional<
1502  ,typename std::conditional<
1503  is_good::value
1504  ,S
1506  >::type
1507  ,R
1509  };
1510  typedef std::true_type is_symmetric;
1511 };
1512 // ------------
1513 // ddot(x,y)
1514 // ------------
1515 /*
1516  result: when arg1 & arg2 are given
1517  1\2 t t4
1518  t s t
1519  t4 t E
1520 */
1521 struct ddot_;
1522 template <class A1, class A2>
1523 struct ddot_result {
1526 };
1527 template <class A1, class A2>
1530  typedef S type;
1531 };
1532 template <class A1, class A2>
1536 };
1537 template <class A1, class A2>
1541 };
1542 struct ddot_ {
1543  template<class A1, class A2>
1544  typename ddot_result<A1,A2>::type
1545  operator() (const A1& x, const A2& y) const { return ddot(x,y); }
1546 };
1547 template<>
1551  return space_constant::scalar;
1552  }
1553  template <class A1, class A2, class R>
1554  struct hint {
1556  typedef typename std::conditional<is_undeterminated<A1>::value,T,A1>::type first_argument_type;
1557  typedef typename std::conditional<is_undeterminated<A2>::value,T,A2>::type second_argument_type;
1558  typedef typename std::conditional<is_undeterminated<R>::value, T,R> ::type result_type;
1559  };
1560  // a:b -> ?
1561  template <class A1, class A2, class R>
1562  struct hint<A1,A2,undeterminated_basic<R> > {
1564  typedef typename std::conditional<
1567  ,result_type
1569  typedef typename std::conditional<
1572  ,result_type
1574  };
1575  // ====================
1576  // A1 xor A2 is unknown
1577  // ====================
1578  // ?:t -> s => a=t
1579  template <class A1, class A2, class R>
1580  struct hint<undeterminated_basic<A1>,tensor_basic<A2>,R> {
1582  typedef typename std::conditional<is_scalar<R>::value,tensor_basic<A1>,E>::type
1585  typedef R result_type;
1586  };
1587  // t:? -> s => b=t
1588  template <class A1, class A2, class R>
1589  struct hint<tensor_basic<A1>,undeterminated_basic<A2>,R> {
1592  typedef typename std::conditional<is_scalar<R>::value,tensor_basic<A2>,E>::type
1594  typedef R result_type;
1595  };
1596  // ?:t4 -> t => a=t
1597  template <class A1, class A2, class R>
1602  };
1603  // t4:? -> t => b=t
1604  template <class A1, class A2, class R>
1609  };
1610  // =====================
1611  // A1 and A2 are unknown
1612  // =====================
1613  // ?:? -> s => a=b=t
1614  template <class A1, class A2, class R>
1617  typedef typename std::conditional<is_scalar<R>::value,tensor_basic<A1>,E>::type
1619  typedef typename std::conditional<is_scalar<R>::value,tensor_basic<A2>,E>::type
1621  typedef R result_type;
1622  };
1623  // ?:? -> t => (a,b)={(t,t4),(t4,t)}
1624  // =====================
1625  // A1 and R are unknown
1626  // =====================
1627  // ?:t -> ? => (a,r)={(t,s),(t4,t)}
1628  template <class A1, class A2, class R>
1633  };
1634  // ?:t4 -> ? => (a,r)=(t,t)
1635  template <class A1, class A2, class R>
1640  };
1641  // =====================
1642  // A2 and R are unknown
1643  // =====================
1644  // t:? -> ? => (b,r)={(t,s),(t4,t)}
1645  template <class A1, class A2, class R>
1650  };
1651  // t4:? -> ? => (b,r)=(t,t)
1652  template <class A1, class A2, class R>
1657  };
1658  // ========================
1659  // A1, A2 and R are unknown
1660  // ========================
1661  // ?:? -> ? => a,b,r=?
1662  template <class A1, class A2, class R>
1667  };
1668  // short interface
1669  template <class Arg1, class Arg2>
1670  struct result_hint {
1671  typedef typename hint<Arg1,Arg2,undeterminated_basic<Float> >::result_type type;
1672  };
1673  typedef std::true_type is_symmetric;
1674 };
1675 // ===========================================================================
1676 // part 3. binders
1677 // ===========================================================================
1678 // similar to std::binder1st, std::binder2nd, but for generic operators
1679 
1680 // ----------------------------------------------------------------------------
1681 // chap 3.1. binder_first
1682 // ----------------------------------------------------------------------------
1683 template<class BinaryFunction, class A1>
1685  binder_first (const BinaryFunction& f, const A1& x1) : _f(f), _x1(x1) {}
1686  template<class A2>
1687  typename generic_binary_traits<BinaryFunction>::template result_hint<A1,A2>::type
1688  operator() (const A2& x2) const { return _f(_x1,x2); }
1689 protected:
1691  A1 _x1;
1692 };
1693 template<class BinaryFunction, class A1>
1695  template <class A2>
1696  struct result_hint {
1698  };
1699  template <class A2, class Result>
1700  struct hint {
1701  typedef Result result_type;
1702  typedef A2 argument_type;
1703  };
1704  // result unknown:
1705  template <class A2, class T>
1706  struct hint<A2,undeterminated_basic<T> > {
1708  typedef A1 argument_type;
1709  };
1710  // A2 unknown:
1711  template <class R, class T>
1712  struct hint<undeterminated_basic<T>,R> {
1713  typedef R result_type;
1714  typedef typename generic_binary_traits<BinaryFunction>::template hint<A1,undeterminated_basic<T>,R>::second_argument_type
1716  };
1717  // A2 & R unknown:
1718  template <class T1, class T>
1720  typedef typename generic_binary_traits<BinaryFunction>::template hint<A1,undeterminated_basic<T1>,undeterminated_basic<T> >::second_argument_type
1722  typedef typename generic_binary_traits<BinaryFunction>::template hint<A1,undeterminated_basic<T>,undeterminated_basic<T> >::result_type
1724  };
1728  return generic_binary_traits<BinaryFunction>::valued_tag (arg1_tag, arg_tag) ;
1729  }
1730 };
1731 // ----------------------------------------------------------------------------
1732 // chap 3.2. binder_second
1733 // ----------------------------------------------------------------------------
1734 template<class BinaryFunction, class A2>
1736  binder_second (const BinaryFunction& f, const A2& x2) : _f(f), _x2(x2) {}
1737  template<class A1>
1738  typename generic_binary_traits<BinaryFunction>::template result_hint<A1,A2>::type
1739  operator() (const A1& x1) const { return _f(x1,_x2); }
1740 protected:
1742  A2 _x2;
1743 };
1744 template<class BinaryFunction, class A2>
1746  template <class A1>
1747  struct result_hint {
1749  };
1750  template <class A1, class Result>
1751  struct hint {
1752  typedef Result result_type;
1753  typedef A1 argument_type;
1754  };
1755  // result unknown:
1756  template <class A1, class T>
1757  struct hint<A1,undeterminated_basic<T> > {
1759  typedef A1 argument_type;
1760  };
1761  // A1 unknown:
1762  template <class R, class T>
1763  struct hint<undeterminated_basic<T>,R> {
1764  typedef R result_type;
1765  typedef typename generic_binary_traits<BinaryFunction>::template hint<undeterminated_basic<T>,A2,R>::first_argument_type
1767  };
1768  // A1 & R unknown:
1769  template <class T1, class T>
1771  typedef typename generic_binary_traits<BinaryFunction>::template hint<undeterminated_basic<T1>,A2,undeterminated_basic<T> >::first_argument_type
1773  typedef typename generic_binary_traits<BinaryFunction>::template hint<undeterminated_basic<T>,A2,undeterminated_basic<T> >::result_type
1775  };
1779  return generic_binary_traits<BinaryFunction>::valued_tag (arg_tag, arg2_tag) ;
1780  }
1781 };
1782 // ---------------------------------------------------------------------------
1783 // chap 3.3. binary swapper
1784 // ---------------------------------------------------------------------------
1785 // as details::mutiplies, for field_vf_bind_bf
1786 // swap is equivalet to binder_second, but with a field instead of a constant
1787 template<class BinaryFunction>
1788 struct swapper {
1789  swapper (const BinaryFunction& f) : _f(f) {}
1790  template<class A1, class A2>
1791  typename generic_binary_traits<BinaryFunction>::template result_hint<A2,A1>::type
1792  operator() (const A1& x1, const A2& x2) const { return _f(x2,x1); }
1793 protected:
1795 };
1796 template<class BinaryFunction>
1798  template <class A1, class A2>
1799  struct result_hint : generic_binary_traits<BinaryFunction>::template result_hint<A2,A1> {};
1800 
1801  template <class A1, class A2, class Result>
1802  struct hint {
1803  typedef typename generic_binary_traits<BinaryFunction>::template hint<A2,A1,Result> base;
1804  typedef typename base::second_argument_type first_argument_type;
1805  typedef typename base::first_argument_type second_argument_type;
1806  typedef typename base::result_type result_type;
1807  };
1810  return generic_binary_traits<BinaryFunction>::valued_tag (arg2_tag, arg1_tag) ;
1811  }
1812 };
1813 // ---------------------------------------------------------------------------
1814 // chap 3.4. unary & binary function wrapper, for compose
1815 // ---------------------------------------------------------------------------
1816 // TODO: use std::function<F> ?
1817 template<class Function>
1819  typedef Function type;
1820 };
1821 template<class Result, class Arg>
1822 struct function_wrapper<Result(Arg)> {
1823  typedef std::function<Result(Arg)> type;
1824 };
1825 template<class Result, class Arg1, class Arg2>
1826 struct function_wrapper<Result(Arg1,Arg2)> {
1827  typedef std::function<Result(Arg1,Arg2)> type;
1828 };
1829 
1830 template<class Function>
1831 inline
1832 Function
1834 {
1835  return f;
1836 }
1837 template<class Result, class Arg>
1838 inline
1839 std::pointer_to_unary_function<Arg,Result>
1840 function_wrap (Result(*f)(Arg))
1841 {
1842  return std::ptr_fun(f);
1843 }
1844 template<class Result, class Arg1, class Arg2>
1845 inline
1846 std::pointer_to_binary_function<Arg1,Arg2,Result>
1847 function_wrap (Result(*f)(Arg1,Arg2))
1848 {
1849  return std::ptr_fun(f);
1850 }
1851 
1852 }} // namespace rheolef::details
1853 #endif // _RHEOLEF_EXPRESSION_H
rheolef::std type
rheolef::std BinaryFunction
rheolef::std value
rheolef::std Function
Expr1::float_type T
Definition: field_expr.h:261
_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:278
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:1438
Function function_wrap(Function f)
Definition: expression.h:1833
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.
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:1688
binder_first(const BinaryFunction &f, const A1 &x1)
Definition: expression.h:1685
binder_second(const BinaryFunction &f, const A2 &x2)
Definition: expression.h:1736
generic_binary_traits< BinaryFunction >::template result_hint< A1, A2 >::type operator()(const A1 &x1) const
Definition: expression.h:1739
ddot_result< A1, A2 >::type operator()(const A1 &x, const A2 &y) const
Definition: expression.h:1545
promote< typename float_traits< A1 >::type, typename float_traits< A2 >::type >::type S
Definition: expression.h:1534
promote< typename float_traits< A1 >::type, typename float_traits< A2 >::type >::type S
Definition: expression.h:1539
promote< typename float_traits< A1 >::type, typename float_traits< A2 >::type >::type S
Definition: expression.h:1529
promote< typename float_traits< A1 >::type, typename float_traits< A2 >::type >::type S
Definition: expression.h:1524
binop_error< ddot_, A1, A2, undeterminated_basic< S > > type
Definition: expression.h:1525
binop_error< details::divides, T, point_basic< T >, undeterminated_basic< T > > type
Definition: expression.h:1204
binop_error< details::divides, T, tensor3_basic< T >, undeterminated_basic< T > > type
Definition: expression.h:1230
binop_error< details::divides, T, tensor4_basic< T >, undeterminated_basic< T > > type
Definition: expression.h:1254
binop_error< details::divides, T, tensor_basic< T >, undeterminated_basic< T > > type
Definition: expression.h:1208
binop_error< details::divides, point_basic< T1 >, tensor3_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1235
binop_error< details::divides, point_basic< T1 >, tensor4_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1259
binop_error< details::divides, point_basic< T1 >, tensor_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1213
binop_error< details::divides, tensor3_basic< T1 >, point_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1245
binop_error< details::divides, tensor3_basic< T1 >, tensor4_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1269
binop_error< details::divides, tensor3_basic< T1 >, tensor_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1250
binop_error< details::divides, tensor_basic< T1 >, point_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1218
binop_error< details::divides, tensor_basic< T1 >, tensor3_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1240
binop_error< details::divides, tensor_basic< T1 >, tensor4_basic< T2 >, undeterminated_basic< S > > type
Definition: expression.h:1264
undeterminated_basic< typename promote< typename scalar_traits< T1 >::type, typename scalar_traits< T2 >::type >::type > type
Definition: expression.h:1161
divides_result< T1, T2 >::type operator()(const T1 &a, const T2 &b) const
Definition: expression.h:1274
std::decay< typename function_traits< Function >::template arg< 0 >::type >::type first_argument_type
Definition: expression.h:414
std::decay< typename function_traits< Function >::template arg< 1 >::type >::type second_argument_type
Definition: expression.h:416
std::decay< typename function_traits< Function >::result_type >::type result_type
Definition: expression.h:418
function_traits< Function >::result_type type
Definition: expression.h:409
std::conditional< is_undeterminated< A2 >::value &&is_error< result_type >::value,result_type,A2 >::type second_argument_type
Definition: expression.h:1573
std::conditional< is_undeterminated< A1 >::value &&is_error< result_type >::value,result_type,A1 >::type first_argument_type
Definition: expression.h:1568
std::conditional< is_scalar< R >::value, tensor_basic< A2 >, E >::type second_argument_type
Definition: expression.h:1593
std::conditional< is_scalar< R >::value, tensor_basic< A1 >, E >::type first_argument_type
Definition: expression.h:1583
std::conditional< is_scalar< R >::value, tensor_basic< A2 >, E >::type second_argument_type
Definition: expression.h:1620
std::conditional< is_scalar< R >::value, tensor_basic< A1 >, E >::type first_argument_type
Definition: expression.h:1618
std::conditional< is_undeterminated< A1 >::value, T, A1 >::type first_argument_type
Definition: expression.h:1556
std::conditional< is_undeterminated< A2 >::value, T, A2 >::type second_argument_type
Definition: expression.h:1557
hint< Arg1, Arg2, undeterminated_basic< Float > >::result_type type
Definition: expression.h:1671
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:1550
promote< typename scalar_traits< A1 >::type, typename scalar_traits< R >::type >::type S
Definition: expression.h:1313
std::conditional< details::is_equal< A1, R >::value, S, binop_error< details::divides, A1, A2, R > >::type second_argument_type
Definition: expression.h:1318
std::conditional< details::is_scalar< A2 >::value, undeterminated_basic< A1 >, binop_error< details::divides, A1, A2, R > >::type first_argument_type
Definition: expression.h:1344
std::conditional< details::is_scalar< A2 >::value, R, binop_error< details::divides, A1, A2, R > >::type first_argument_type
Definition: expression.h:1304
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:1358
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:1508
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:1499
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:1481
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:1490
promote< typename float_traits< Arg1 >::type, typename float_traits< Arg2 >::type >::type type
Definition: expression.h:1461
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:1456
hint< A1, A2, undeterminated_basic< Float > >::result_type type
Definition: expression.h:554
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:557
binop_error< details::multiplies, undeterminated_basic< A2 >, tensor3_basic< A2 >, point_basic< R > > type
Definition: expression.h:838
binop_error< details::multiplies, undeterminated_basic< A2 >, point_basic< A2 >, tensor3_basic< R > > type
Definition: expression.h:803
binop_error< details::multiplies, undeterminated_basic< A2 >, tensor_basic< A2 >, point_basic< R > > type
Definition: expression.h:818
binop_error< details::multiplies, undeterminated_basic< S >, tensor4_basic< A2 >, tensor3_basic< R > > type
Definition: expression.h:873
binop_error< details::multiplies, undeterminated_basic< S >, tensor4_basic< A2 >, point_basic< R > > type
Definition: expression.h:861
binop_error< details::multiplies, undeterminated_basic< A2 >, tensor3_basic< A2 >, tensor_basic< R > > type
Definition: expression.h:843
binop_error< details::multiplies, undeterminated_basic< S >, tensor4_basic< A2 >, tensor_basic< R > > type
Definition: expression.h:867
binop_error< details::multiplies, undeterminated_basic< A2 >, point_basic< A2 >, tensor4_basic< R > > type
Definition: expression.h:808
hint< Arg1, Arg2, undeterminated_basic< Float > >::result_type type
Definition: expression.h:1150
binop_error< details::multiplies, tensor_basic< A1 >, undeterminated_basic< A1 >, tensor3_basic< R > > type
Definition: expression.h:947
binop_error< details::multiplies, tensor4_basic< A1 >, undeterminated_basic< A1 >, point_basic< R > > type
Definition: expression.h:978
binop_error< details::multiplies, tensor4_basic< A1 >, undeterminated_basic< A1 >, tensor_basic< R > > type
Definition: expression.h:983
binop_error< details::multiplies, tensor3_basic< A1 >, undeterminated_basic< A1 >, point_basic< R > > type
Definition: expression.h:957
binop_error< details::multiplies, tensor4_basic< A1 >, undeterminated_basic< A1 >, tensor3_basic< R > > type
Definition: expression.h:988
binop_error< details::multiplies, point_basic< A1 >, undeterminated_basic< A1 >, tensor3_basic< R > > type
Definition: expression.h:942
binop_error< details::multiplies, tensor_basic< A1 >, undeterminated_basic< A1 >, tensor_basic< R > > type
Definition: expression.h:922
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:753
std::conditional< details::is_equal< A1, R >::value, R, binop_error< details::plus, A1, A2, R > >::type second_argument_type
Definition: expression.h:499
std::conditional< details::is_equal< A2, R >::value, R, binop_error< details::plus, A1, A2, R > >::type first_argument_type
Definition: expression.h:487
hint< Arg1, Arg2, undeterminated_basic< Float > >::result_type type
Definition: expression.h:537
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:531
generic_binary_traits< BinaryFunction >::template hint< A2, A1, Result > base
Definition: expression.h:1803
static space_constant::valued_type valued_tag(space_constant::valued_type arg1_tag, space_constant::valued_type arg2_tag)
Definition: expression.h:1809
static space_constant::valued_type valued_tag(space_constant::valued_type, space_constant::valued_type)
Definition: expression.h:421
std::decay< typename function_traits< Function >::template arg< 0 >::type >::type argument_type
Definition: expression.h:196
function_traits< Function >::result_type result_type
Definition: expression.h:194
function_traits< Function >::result_type type
Definition: expression.h:190
generic_binary_traits< BinaryFunction >::template result_hint< A1, A2 >::type type
Definition: expression.h:1697
static space_constant::valued_type valued_tag(space_constant::valued_type arg_tag)
Definition: expression.h:1726
generic_binary_traits< BinaryFunction >::template hint< A1, undeterminated_basic< T >, R >::second_argument_type argument_type
Definition: expression.h:1715
generic_binary_traits< BinaryFunction >::template hint< A1, undeterminated_basic< T >, undeterminated_basic< T > >::result_type result_type
Definition: expression.h:1723
generic_binary_traits< BinaryFunction >::template hint< A1, undeterminated_basic< T1 >, undeterminated_basic< T > >::second_argument_type argument_type
Definition: expression.h:1721
generic_binary_traits< BinaryFunction >::template hint< undeterminated_basic< T >, A2, R >::first_argument_type argument_type
Definition: expression.h:1766
generic_binary_traits< BinaryFunction >::template hint< undeterminated_basic< T1 >, A2, undeterminated_basic< T > >::first_argument_type argument_type
Definition: expression.h:1772
generic_binary_traits< BinaryFunction >::template hint< undeterminated_basic< T >, A2, undeterminated_basic< T > >::result_type result_type
Definition: expression.h:1774
generic_binary_traits< BinaryFunction >::template result_hint< A1, A2 >::type type
Definition: expression.h:1748
static space_constant::valued_type valued_tag(space_constant::valued_type arg_tag)
Definition: expression.h:1777
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:245
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:395
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:368
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:318
promote< typename scalar_traits< A1 >::type, typename scalar_traits< R >::type >::type S
Definition: expression.h:336
tensor_basic< typename scalar_traits< A1 >::type > type
Definition: expression.h:332
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:341
static space_constant::valued_type valued_tag(space_constant::valued_type tag)
Definition: expression.h:223
static space_constant::valued_type valued_tag(space_constant::valued_type)
Definition: expression.h:199
plus_result< T1, T2 >::type operator()(const T1 &a, const T2 &b) const
Definition: expression.h:545
binop_error< details::multiplies, point_basic< S1 >, point_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:627
binop_error< details::multiplies, point_basic< S1 >, tensor3_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:678
binop_error< details::multiplies, point_basic< S1 >, tensor4_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:706
binop_error< details::multiplies, point_basic< S1 >, tensor_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:633
binop_error< details::multiplies, tensor3_basic< S1 >, tensor3_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:690
binop_error< details::multiplies, tensor3_basic< S1 >, tensor4_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:718
binop_error< details::multiplies, tensor4_basic< S1 >, point_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:724
binop_error< details::multiplies, tensor4_basic< S1 >, tensor3_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:736
binop_error< details::multiplies, tensor4_basic< S1 >, tensor4_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:742
binop_error< details::multiplies, tensor4_basic< S1 >, tensor_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:730
binop_error< details::multiplies, tensor_basic< S1 >, tensor3_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:684
binop_error< details::multiplies, tensor_basic< S1 >, tensor4_basic< S2 >, undeterminated_basic< S > > type
Definition: expression.h:712
promote< A1, A2 >::type type
Definition: expression.h:606
multiplies_result< T1, T2 >::type operator()(const T1 &a, const T2 &b) const
Definition: expression.h:748
T operator()(const T &a) const
Definition: expression.h:231
float_traits< T >::type operator()(const T &x) const
Definition: expression.h:377
float_traits< T >::type operator()(const T &x) const
Definition: expression.h:350
binop_error< details::plus, A1, A2, undeterminated_basic< Float > > type
Definition: expression.h:436
plus_result< T1, T2 >::type operator()(const T1 &a, const T2 &b) const
Definition: expression.h:458
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:1405
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:1396
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:1414
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:1423
promote< typename scalar_traits< Arg1 >::type, typename scalar_traits< Arg2 >::type >::type type
Definition: expression.h:1376
static space_constant::valued_type valued_tag(space_constant::valued_type tag1, space_constant::valued_type tag2)
Definition: expression.h:1371
swapper(const BinaryFunction &f)
Definition: expression.h:1789
generic_binary_traits< BinaryFunction >::template result_hint< A2, A1 >::type operator()(const A1 &x1, const A2 &x2) const
Definition: expression.h:1792
tensor_basic< T > operator()(const tensor_basic< T > &a) const
Definition: expression.h:326
T operator()(const T &a) const
Definition: expression.h:209
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>