OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
vector_dist_operators.hpp
1 /*
2  * vector_dist_operators.hpp
3  *
4  * Created on: Jun 11, 2016
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_HPP_
9 #define OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_HPP_
10 
11 #include "Vector/vector_dist.hpp"
12 
13 #define PROP_POS (unsigned int)-1
14 #define PROP_CUSTOM (unsigned int)-2
15 
16 #define VECT_SUM 1
17 #define VECT_SUB 2
18 #define VECT_MUL 3
19 #define VECT_DIV 4
20 
21 #define VECT_APPLYKER_IN 7
22 #define VECT_APPLYKER_OUT 8
23 #define VECT_APPLYKER_REDUCE 9
24 #define VECT_APPLYKER_IN_GEN 10
25 #define VECT_APPLYKER_OUT_GEN 11
26 #define VECT_APPLYKER_REDUCE_GEN 12
27 #define VECT_APPLYKER_IN_SIM 13
28 #define VECT_APPLYKER_OUT_SIM 14
29 #define VECT_APPLYKER_REDUCE_SIM 15
30 
31 #define VECT_NORM 56
32 #define VECT_NORM2 57
33 #define VECT_ABS 58
34 #define VECT_EXP 59
35 #define VECT_EXP2 60
36 #define VECT_EXPM1 61
37 #define VECT_LOG 62
38 #define VECT_LOG10 63
39 #define VECT_LOG2 64
40 #define VECT_LOG1P 65
41 #define VECT_SQRT 67
42 #define VECT_CBRT 68
43 #define VECT_SIN 69
44 #define VECT_COS 70
45 #define VECT_TAN 71
46 #define VECT_ASIN 72
47 #define VECT_ACOS 73
48 #define VECT_ATAN 74
49 #define VECT_SINH 75
50 #define VECT_COSH 76
51 #define VECT_TANH 77
52 #define VECT_ASINH 78
53 #define VECT_ACOSH 79
54 #define VECT_ATANH 80
55 #define VECT_ERF 81
56 #define VECT_ERFC 82
57 #define VECT_TGAMMA 83
58 #define VECT_LGAMMA 84
59 #define VECT_CEIL 85
60 #define VECT_FLOOR 86
61 #define VECT_TRUNC 87
62 #define VECT_ROUND 88
63 #define VECT_NEARBYINT 89
64 #define VECT_RINT 90
65 #define VECT_PMUL 91
66 #define VECT_SUB_UNI 92
67 
68 #define VECT_SUM_REDUCE 93
69 
70 
80 template<typename ObjType, typename Sfinae = void>
81 struct has_init: std::false_type {};
82 
83 template<typename ObjType>
84 struct has_init<ObjType, typename Void<typename ObjType::has_init>::type> : std::true_type
85 {};
86 
92 template <typename T, bool has_init = has_init<T>::value >
94 {
96  static inline void call(T & r_exp)
97  {
98  r_exp.init();
99  }
100 };
101 
107 template <typename T>
108 struct call_init_if_needed<T,false>
109 {
111  static inline void call(T & r_exp)
112  {
113  }
114 };
115 
116 
117 
124 template <typename exp1, typename exp2, unsigned int op>
126 {
127 
128 };
129 
136 template <typename exp1, typename exp2>
137 class vector_dist_expression_op<exp1,exp2,VECT_SUM>
138 {
140  const exp1 o1;
141 
143  const exp2 o2;
144 
145 public:
146 
148  inline vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
149  :o1(o1),o2(o2)
150  {}
151 
157  inline void init() const
158  {
159  o1.init();
160  o2.init();
161  }
162 
170  template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) + o2.value(vect_dist_key_dx()))>::type >
171  inline r_type value(const vect_dist_key_dx & key) const
172  {
173  return o1.value(key) + o2.value(key);
174  }
175 
176 };
177 
184 template <typename exp1, typename exp2>
186 {
188  const exp1 o1;
189 
191  const exp2 o2;
192 
193 public:
194 
196  inline vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
197  :o1(o1),o2(o2)
198  {}
199 
205  inline void init() const
206  {
207  o1.init();
208  o2.init();
209  }
210 
218  template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) - o2.value(vect_dist_key_dx()))>::type > inline r_type value(const vect_dist_key_dx & key) const
219  {
220  return o1.value(key) - o2.value(key);
221  }
222 };
223 
230 template <typename exp1, typename exp2>
232 {
234  const exp1 o1;
235 
237  const exp2 o2;
238 
239 public:
240 
242  vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
243  :o1(o1),o2(o2)
244  {}
245 
251  inline void init() const
252  {
253  o1.init();
254  o2.init();
255  }
256 
264  template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) * o2.value(vect_dist_key_dx()))>::type > inline r_type value(const vect_dist_key_dx & key) const
265  {
266  return o1.value(key) * o2.value(key);
267  }
268 };
269 
276 template <typename exp1, typename exp2>
278 {
280  const exp1 o1;
281 
283  const exp2 o2;
284 
285 public:
286 
288  vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
289  :o1(o1),o2(o2)
290  {}
291 
297  inline void init() const
298  {
299  o1.init();
300  o2.init();
301  }
302 
310  template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) / o2.value(vect_dist_key_dx()))>::type > inline r_type value(const vect_dist_key_dx & key) const
311  {
312  return o1.value(key) / o2.value(key);
313  }
314 };
315 
323 template <typename vector, unsigned int prp>
325 {
327  static inline auto value(vector & v, const vect_dist_key_dx & k) -> decltype(v.template getProp<prp>(k))
328  {
329  return v.template getProp<prp>(k);
330  }
331 };
332 
340 template <typename vector, unsigned int prp>
342 {
344  static inline auto value(vector & v, const vect_dist_key_dx & k) -> decltype(v.template getProp<prp>(k))
345  {
346  return v.template getProp<prp>(k);
347  }
348 };
349 
357 template <typename vector>
359 {
360 #ifdef SE_CLASS3
361 
363  static inline auto value(vector & v, const vect_dist_key_dx & k) -> decltype(getExprL(v.getPos(k).getReference()))
364  {
365  return getExprL(v.getPos(k).getReference());
366  }
367 
368 #else
369 
371  static inline auto value(vector & v, const vect_dist_key_dx & k) -> decltype(getExprL(v.getPos(k)))
372  {
373  return getExprL(v.getPos(k));
374  }
375 
376 #endif
377 };
378 
386 template <typename vector>
388 {
390  static inline auto value(vector & v, const vect_dist_key_dx & k) -> decltype(getExprR(v.getPos(k)))
391  {
392  return getExprR(v.getPos(k));
393  }
394 };
395 
400 template <typename exp1>
402 {
404  const exp1 o1;
405 
406 public:
407 
409  vector_dist_expression_op(const exp1 & o1)
410  :o1(o1)
411  {}
412 
414  inline void init() const
415  {
416  o1.init();
417  }
418 
420  template<typename r_type=typename std::remove_reference<decltype(-(o1.value(vect_dist_key_dx(0))))>::type > inline r_type value(const vect_dist_key_dx & key) const
421  {
422  return -(o1.value(key));
423  }
424 };
425 
432 template<unsigned int prp, typename vector>
434 {
436  vector & v;
437 
438 public:
439 
441  typedef vector vtype;
442 
444  static const unsigned int prop = prp;
445 
448  :v(v)
449  {}
450 
458  vector & getVector()
459  {
460  return v;
461  }
462 
468  inline void init() const
469  {}
470 
478  inline auto value(const vect_dist_key_dx & k) const -> decltype(pos_or_propR<vector,prp>::value(v,k))
479  {
481  }
482 
490  template<unsigned int prp2> vector & operator=(const vector_dist_expression<prp2,vector> & v_exp)
491  {
492  v_exp.init();
493 
494  auto it = v.getDomainIterator();
495 
496  while (it.isNext())
497  {
498  auto key = it.get();
499 
501 
502  ++it;
503  }
504 
505  return v;
506  }
507 
515  template<typename exp1, typename exp2, unsigned int op> vector & operator=(const vector_dist_expression_op<exp1,exp2,op> & v_exp)
516  {
517  v_exp.init();
518 
519  auto it = v.getDomainIterator();
520 
521  while (it.isNext())
522  {
523  auto key = it.get();
524 
525  pos_or_propL<vector,prp>::value(v,key) = v_exp.value(key);
526 
527  ++it;
528  }
529 
530  return v;
531  }
532 
540  vector & operator=(double d)
541  {
542  auto it = v.getDomainIterator();
543 
544  while (it.isNext())
545  {
546  auto key = it.get();
547 
549 
550  ++it;
551  }
552 
553  return v;
554  }
555 };
556 
563 template <unsigned int prp,typename vector> inline vector_dist_expression<prp,vector > getV(vector & v)
564 {
566 
567  return exp_v;
568 }
569 
575 template<unsigned int prp>
576 class vector_dist_expression<prp,double>
577 {
579  double d;
580 
581 public:
582 
584  inline vector_dist_expression(const double & d)
585  :d(d)
586  {}
587 
593  inline void init() const
594  {}
595 
605  inline double value(const vect_dist_key_dx & k) const
606  {
607  return d;
608  }
609 };
610 
616 template<unsigned int prp>
617 class vector_dist_expression<prp,float>
618 {
620  float d;
621 
622 public:
623 
625  typedef float vtype;
626 
628  inline vector_dist_expression(const float & d)
629  :d(d)
630  {}
631 
637  inline void init() const
638  {}
639 
649  inline float value(const vect_dist_key_dx & k) const
650  {
651  return d;
652  }
653 };
654 
655 /* \brief sum two distributed vector expression
656  *
657  * \param va vector expression one
658  * \param vb vector expression two
659  *
660  * \return an object that encapsulate the expression
661  *
662  */
663 template<unsigned int p1, unsigned int p2, typename v1, typename v2>
665 operator+(const vector_dist_expression<p1,v1> & va, const vector_dist_expression<p2,v2> & vb)
666 {
667  vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression<p2,v2>,VECT_SUM> exp_sum(va,vb);
668 
669  return exp_sum;
670 }
671 
672 /* \brief sum two distributed vector expression
673  *
674  * \param va vector expression one
675  * \param vb vector expression two
676  *
677  * \return an object that encapsulate the expression
678  *
679  */
680 template<typename exp1 , typename exp2, unsigned int op1, unsigned int prp1, typename v1>
682 operator+(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression<prp1,v1> & vb)
683 {
684  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<prp1,v1>,VECT_SUM> exp_sum(va,vb);
685 
686  return exp_sum;
687 }
688 
689 /* \brief sum two distributed vector expression
690  *
691  * \param va vector expression one
692  * \param vb vector expression two
693  *
694  * \return an object that encapsulate the expression
695  *
696  */
697 template<typename exp1 , typename exp2, unsigned int op1, unsigned int prp1, typename v1>
699 operator+(const vector_dist_expression<prp1,v1> & va, const vector_dist_expression_op<exp1,exp2,op1> & vb)
700 {
701  vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression_op<exp1,exp2,op1>,VECT_SUM> exp_sum(va,vb);
702 
703  return exp_sum;
704 }
705 
706 /* \brief sum two distributed vector expression
707  *
708  * \param va vector expression one
709  * \param vb vector expression two
710  *
711  * \return an object that encapsulate the expression
712  *
713  */
714 template<typename exp1 , typename exp2, unsigned int op1, typename exp3 , typename exp4, unsigned int op2>
715 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_SUM>
716 operator+(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression_op<exp3,exp4,op2> & vb)
717 {
718  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_SUM> exp_sum(va,vb);
719 
720  return exp_sum;
721 }
722 
723 /* \brief sum two distributed vector expression
724  *
725  * \param va vector expression one
726  * \param vb vector expression two
727  *
728  * \return an object that encapsulate the expression
729  *
730  */
731 template<unsigned int prp1 , typename v1>
732 inline vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<0,double>,VECT_SUM>
733 operator+(const vector_dist_expression<prp1,v1> & va, double d)
734 {
735  vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<0,double>,VECT_SUM> exp_sum(va,vector_dist_expression<0,double>(d));
736 
737  return exp_sum;
738 }
739 
740 /* \brief sum two distributed vector expression
741  *
742  * \param va vector expression one
743  * \param vb vector expression two
744  *
745  * \return an object that encapsulate the expression
746  *
747  */
748 template<unsigned int prp1 , typename v1>
749 inline vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<prp1,v1>,VECT_SUM>
750 operator+(double d, const vector_dist_expression<prp1,v1> & vb)
751 {
752  vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<prp1,v1>,VECT_SUM> exp_sum(vector_dist_expression<0,double>(d),vb);
753 
754  return exp_sum;
755 }
756 
757 /* \brief sum two distributed vector expression
758  *
759  * \param va vector expression one
760  * \param vb vector expression two
761  *
762  * \return an object that encapsulate the expression
763  *
764  */
765 template<typename exp1 , typename exp2, unsigned int op1>
766 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_SUM>
767 operator+(const vector_dist_expression_op<exp1,exp2,op1> & va, double d)
768 {
769  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_SUM> exp_sum(va,vector_dist_expression<0,double>(d));
770 
771  return exp_sum;
772 }
773 
774 
775 /* \brief subtract two distributed vector expression
776  *
777  * \param va vector expression one
778  * \param vb vector expression two
779  *
780  * \return an object that encapsulate the expression
781  *
782  */
783 template<unsigned int p1, unsigned int p2, typename v1, typename v2>
784 inline vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression<p2,v2>,VECT_SUB>
785 operator-(const vector_dist_expression<p1,v1> & va, const vector_dist_expression<p2,v2> & vb)
786 {
787  vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression<p2,v2>,VECT_SUB> exp_sum(va,vb);
788 
789  return exp_sum;
790 }
791 
792 
793 /* \brief subtract two distributed vector expression
794  *
795  * \param va vector expression one
796  * \param vb vector expression two
797  *
798  * \return an object that encapsulate the expression
799  *
800  */
801 template<typename exp1, typename exp2, unsigned int op1, unsigned int p2, typename v2>
802 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<p2,v2>,VECT_SUB>
803 operator-(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression<p2,v2> & vb)
804 {
805  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<p2,v2>,VECT_SUB> exp_sum(va,vb);
806 
807  return exp_sum;
808 }
809 
810 /* \brief minus of a distributed vector expression operator
811  *
812  * \param va vector expression one
813  *
814  * \return an object that encapsulate the expression
815  *
816  */
817 template<typename exp1, typename exp2_, unsigned int op1>
819 operator-(const vector_dist_expression_op<exp1,exp2_,op1> & va)
820 {
821  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2_,op1>,void,VECT_SUB_UNI> exp_sum(va);
822 
823  return exp_sum;
824 }
825 
826 /* \brief minus of a distributed vector expression
827  *
828  * \param va vector expression one
829  *
830  * \return an object that encapsulate the expression
831  *
832  */
833 template<unsigned int p1, typename v1>
834 inline vector_dist_expression_op<vector_dist_expression<p1,v1>,void,VECT_SUB_UNI>
835 operator-(const vector_dist_expression<p1,v1> & va)
836 {
837  vector_dist_expression_op<vector_dist_expression<p1,v1>,void,VECT_SUB_UNI> exp_sum(va);
838 
839  return exp_sum;
840 }
841 
842 
843 /* \brief subtract two distributed vector expression
844  *
845  * \param va vector expression one
846  * \param vb vector expression two
847  *
848  * \return an object that encapsulate the expression
849  *
850  */
851 template<typename exp1, typename exp2, unsigned int op1, unsigned int p2, typename v2>
852 inline vector_dist_expression_op<vector_dist_expression<p2,v2>,vector_dist_expression_op<exp1,exp2,op1>,VECT_SUB>
853 operator-(const vector_dist_expression<p2,v2> & va, const vector_dist_expression_op<exp1,exp2,op1> & vb)
854 {
855  vector_dist_expression_op<vector_dist_expression<p2,v2>, vector_dist_expression_op<exp1,exp2,op1>,VECT_SUB> exp_sum(va,vb);
856 
857  return exp_sum;
858 }
859 
860 /* \brief subtract two distributed vector expression
861  *
862  * \param va vector expression one
863  * \param vb vector expression two
864  *
865  * \return an object that encapsulate the expression
866  *
867  */
868 template<typename exp1, typename exp2, unsigned int op1, typename exp3, typename exp4, unsigned int op2>
869 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_SUB>
870 operator-(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression_op<exp3,exp4,op2> & vb)
871 {
872  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_SUB> exp_sum(va,vb);
873 
874  return exp_sum;
875 }
876 
877 /* \brief subtract two distributed vector expression
878  *
879  * \param va vector expression one
880  * \param vb vector expression two
881  *
882  * \return an object that encapsulate the expression
883  *
884  */
885 template<unsigned int prp1, typename v1>
886 inline vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<0,double>,VECT_SUB>
887 operator-(const vector_dist_expression<prp1,v1> & va, double d)
888 {
889  vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<0,double>,VECT_SUB> exp_sum(va,vector_dist_expression<0,double>(d));
890 
891  return exp_sum;
892 }
893 
894 /* \brief subtract two distributed vector expression
895  *
896  * \param va vector expression one
897  * \param vb vector expression two
898  *
899  * \return an object that encapsulate the expression
900  *
901  */
902 template<unsigned int prp1, typename v1>
903 inline vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<prp1,v1>,VECT_SUB>
904 operator-(double d, const vector_dist_expression<prp1,v1> & vb)
905 {
906  vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<prp1,v1>,VECT_SUB> exp_sum(vector_dist_expression<0,double>(d),vb);
907 
908  return exp_sum;
909 }
910 
911 /* \brief Multiply two distributed vector expression
912  *
913  * \param va vector expression one
914  * \param vb vector expression two
915  *
916  * \return an object that encapsulate the expression
917  *
918  */
919 template<unsigned int p2, typename v2>
920 inline vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<p2,v2>,VECT_MUL>
921 operator*(double d, const vector_dist_expression<p2,v2> & vb)
922 {
923  vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<p2,v2>,VECT_MUL> exp_sum(vector_dist_expression<0,double>(d),vb);
924 
925  return exp_sum;
926 }
927 
928 /* \brief Multiply two distributed vector expression
929  *
930  * \param va vector expression one
931  * \param vb vector expression two
932  *
933  * \return an object that encapsulate the expression
934  *
935  */
936 template<unsigned int p2, typename v2>
937 inline vector_dist_expression_op<vector_dist_expression<p2,v2>,vector_dist_expression<0,double>,VECT_MUL>
938 operator*(const vector_dist_expression<p2,v2> & va, double d)
939 {
940  vector_dist_expression_op<vector_dist_expression<p2,v2>,vector_dist_expression<0,double>,VECT_MUL> exp_sum(va,vector_dist_expression<0,double>(d));
941 
942  return exp_sum;
943 }
944 
945 /* \brief Multiply two distributed vector expression
946  *
947  * \param va vector expression one
948  * \param vb vector expression two
949  *
950  * \return an object that encapsulate the expression
951  *
952  */
953 template<unsigned int p1, typename v1,unsigned int p2, typename v2>
954 inline vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression<p2,v2>,VECT_MUL>
955 operator*(const vector_dist_expression<p1,v1> & va, const vector_dist_expression<p2,v2> & vb)
956 {
957  vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression<p2,v2>,VECT_MUL> exp_sum(va,vb);
958 
959  return exp_sum;
960 }
961 
962 /* \brief Multiply two distributed vector expression
963  *
964  * \param va vector expression one
965  * \param vb vector expression two
966  *
967  * \return an object that encapsulate the expression
968  *
969  */
970 template<unsigned int p1, typename v1, typename exp1, typename exp2, unsigned int op1>
971 inline vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression_op<exp1,exp2,op1>,VECT_MUL>
972 operator*(const vector_dist_expression<p1,v1> & va, const vector_dist_expression_op<exp1,exp2,op1> & vb)
973 {
974  vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression_op<exp1,exp2,op1>,VECT_MUL> exp_sum(va,vb);
975 
976  return exp_sum;
977 }
978 
979 /* \brief Multiply two distributed vector expression
980  *
981  * \param va vector expression one
982  * \param vb vector expression two
983  *
984  * \return an object that encapsulate the expression
985  *
986  */
987 template<unsigned int p1, typename v1, typename exp1, typename exp2, unsigned int op1>
988 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<p1,v1>,VECT_MUL>
989 operator*(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression<p1,v1> & vb)
990 {
991  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<p1,v1>,VECT_MUL> exp_sum(va,vb);
992 
993  return exp_sum;
994 }
995 
996 /* \brief Multiply two distributed vector expression
997  *
998  * \param va vector expression one
999  * \param vb vector expression two
1000  *
1001  * \return an object that encapsulate the expression
1002  *
1003  */
1004 template<typename exp1, typename exp2, unsigned int op1, typename exp3 , typename exp4, unsigned int op2>
1005 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_MUL>
1006 operator*(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression_op<exp3,exp4,op2> & vb)
1007 {
1008  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_MUL> exp_sum(va,vb);
1009 
1010  return exp_sum;
1011 }
1012 
1013 /* \brief Multiply a distributed vector expression by a number
1014  *
1015  * \param va vector expression
1016  * \param d number
1017  *
1018  * \return an object that encapsulate the expression
1019  *
1020  */
1021 template<typename exp1 , typename exp2, unsigned int op1>
1022 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_MUL>
1023 operator*(const vector_dist_expression_op<exp1,exp2,op1> & va, double d)
1024 {
1025  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_MUL> exp_sum(va,vector_dist_expression<0,double>(d));
1026 
1027  return exp_sum;
1028 }
1029 
1030 /* \brief Multiply a distributed vector expression by a number
1031  *
1032  * \param d number
1033  * \param vb vector expression
1034  *
1035  * \return an object that encapsulate the expression
1036  *
1037  */
1038 template<typename exp1 , typename exp2, unsigned int op1>
1039 inline vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression_op<exp1,exp2,op1>,VECT_MUL>
1040 operator*(double d, const vector_dist_expression_op<exp1,exp2,op1> & vb)
1041 {
1042  vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression_op<exp1,exp2,op1>,VECT_MUL> exp_sum(vector_dist_expression<0,double>(d),vb);
1043 
1044  return exp_sum;
1045 }
1046 
1047 /* \brief Divide two distributed vector expression
1048  *
1049  * \param va vector expression one
1050  * \param vb vector expression two
1051  *
1052  * \return an object that encapsulate the expression
1053  *
1054  */
1055 template<typename exp1, typename exp2, unsigned int op1>
1056 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_DIV>
1057 operator/(const vector_dist_expression_op<exp1,exp2,op1> & va, double d)
1058 {
1059  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_DIV> exp_sum(va,vector_dist_expression<0,double>(d));
1060 
1061  return exp_sum;
1062 }
1063 
1064 
1065 /* \brief Divide two distributed vector expression
1066  *
1067  * \param va vector expression one
1068  * \param vb vector expression two
1069  *
1070  * \return an object that encapsulate the expression
1071  *
1072  */
1073 template<typename exp1, typename exp2, unsigned int op1>
1074 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_DIV>
1075 operator/(double d, const vector_dist_expression_op<exp1,exp2,op1> & va)
1076 {
1077  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_DIV> exp_sum(vector_dist_expression<0,double>(d),va);
1078 
1079  return exp_sum;
1080 }
1081 
1082 /* \brief Divide two distributed vector expression
1083  *
1084  * \param va vector expression one
1085  * \param vb vector expression two
1086  *
1087  * \return an object that encapsulate the expression
1088  *
1089  */
1090 template<unsigned int prp1, typename v1>
1091 inline vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<0,double>,VECT_DIV>
1092 operator/(const vector_dist_expression<prp1,v1> & va, double d)
1093 {
1094  vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<0,double>,VECT_DIV> exp_sum(va,vector_dist_expression<0,double>(d));
1095 
1096  return exp_sum;
1097 }
1098 
1099 /* \brief Divide two distributed vector expression
1100  *
1101  * \param va vector expression one
1102  * \param vb vector expression two
1103  *
1104  * \return an object that encapsulate the expression
1105  *
1106  */
1107 template<unsigned int prp1, typename v1>
1108 inline vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<prp1,v1>,VECT_DIV>
1109 operator/(double d, const vector_dist_expression<prp1,v1> & va)
1110 {
1111  vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<prp1,v1>,VECT_DIV> exp_sum(vector_dist_expression<0,double>(d),va);
1112 
1113  return exp_sum;
1114 }
1115 
1116 /* \brief Divide two distributed vector expression
1117  *
1118  * \param va vector expression one
1119  * \param vb vector expression two
1120  *
1121  * \return an object that encapsulate the expression
1122  *
1123  */
1124 template<unsigned int prp1, typename v1, unsigned int prp2, typename v2>
1125 inline vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<prp2,v2>,VECT_DIV>
1126 operator/(const vector_dist_expression<prp1,v1> & va, const vector_dist_expression<prp2,v2> & vb)
1127 {
1128  vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<prp2,v2>,VECT_DIV> exp_sum(va,vb);
1129 
1130  return exp_sum;
1131 }
1132 
1133 /* \brief Divide two distributed vector expression
1134  *
1135  * \param va vector expression one
1136  * \param vb vector expression two
1137  *
1138  * \return an object that encapsulate the expression
1139  *
1140  */
1141 template<unsigned int prp1, typename v1, typename exp1,typename exp2, unsigned int op1>
1142 inline vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression_op<exp1,exp2,op1>,VECT_DIV>
1143 operator/(const vector_dist_expression<prp1,v1> & va, const vector_dist_expression_op<exp1,exp2,op1> & vb)
1144 {
1145  vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression_op<exp1,exp2,op1>,VECT_DIV> exp_sum(va,vb);
1146 
1147  return exp_sum;
1148 }
1149 
1150 /* \brief Divide two distributed vector expression
1151  *
1152  * \param va vector expression one
1153  * \param vb vector expression two
1154  *
1155  * \return an object that encapsulate the expression
1156  *
1157  */
1158 template<unsigned int prp1, typename v1, typename exp1,typename exp2, unsigned int op1>
1159 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<prp1,v1>,VECT_DIV>
1160 operator/(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression<prp1,v1> & vb)
1161 {
1162  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<prp1,v1>,VECT_DIV> exp_sum(va,vb);
1163 
1164  return exp_sum;
1165 }
1166 
1167 /* \brief Divide two distributed vector expression
1168  *
1169  * \param va vector expression one
1170  * \param vb vector expression two
1171  *
1172  * \return an object that encapsulate the expression
1173  *
1174  */
1175 template<typename exp1,typename exp2, unsigned int op1, typename exp3, typename exp4, unsigned int op2>
1176 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_DIV>
1177 operator/(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression_op<exp3,exp4,op2> & vb)
1178 {
1179  vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_DIV> exp_sum(va,vb);
1180 
1181  return exp_sum;
1182 }
1183 
1184 #include "vector_dist_operators_apply_kernel.hpp"
1185 #include "vector_dist_operators_functions.hpp"
1186 #include "vector_dist_operators_extensions.hpp"
1187 #include "Operators/Vector/vector_dist_operator_assign.hpp"
1188 
1189 #endif /* OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_HPP_ */
selector for position or properties right side
void init() const
This function must be called before value.
float vtype
type of object the structure return then evaluated
vector_dist_expression_op(const exp1 &o1, const exp2 &o2)
constructor from two expressions
r_type value(const vect_dist_key_dx &key) const
Evaluate the expression.
vector_dist_expression(const double &d)
constructor from a constant expression
vector & operator=(const vector_dist_expression_op< exp1, exp2, op > &v_exp)
Fill the vector property with the evaluated expression.
float value(const vect_dist_key_dx &k) const
Evaluate the expression.
void init() const
This function must be called before value.
static auto value(vector &v, const vect_dist_key_dx &k) -> decltype(v.template getProp< prp >(k))
return the value (position or property) of the particle k in the vector v
vector_dist_expression_op(const exp1 &o1, const exp2 &o2)
constructor of the expression to sum two expression
static auto value(vector &v, const vect_dist_key_dx &k) -> decltype(getExprR(v.getPos(k)))
return the value (position or property) of the particle k in the vector v
void init() const
initialize the expression tree
selector for position or properties left side expression
r_type value(const vect_dist_key_dx &key) const
Evaluate the expression.
has_init check if a type has defined a method called init
selector for position or properties left side
static auto value(vector &v, const vect_dist_key_dx &k) -> decltype(getExprL(v.getPos(k)))
return the value (position or property) of the particle k in the vector v
vector vtype
The type of the internal vector.
Grid key for a distributed grid.
r_type value(const vect_dist_key_dx &key) const
Evaluate the expression.
static void call(T &r_exp)
it call the function init for r_exp if T has the function init
selector for position or properties right side position
void init() const
This function must be called before value.
Unknown operation specialization.
vector & getVector()
Return the vector on which is acting.
vector_dist_expression(const float &d)
constrictor from constant value
r_type value(const vect_dist_key_dx &key) const
return the result of the expression
auto value(const vect_dist_key_dx &k) const -> decltype(pos_or_propR< vector, prp >::value(v, k))
Evaluate the expression.
void init() const
This function must be called before value.
vector_dist_expression_op(const exp1 &o1, const exp2 &o2)
Costruct a subtraction expression out of two expressions.
vector & operator=(const vector_dist_expression< prp2, vector > &v_exp)
Fill the vector property with the evaluated expression.
Main class that encapsulate a vector properties operand to be used for expressions construction...
vector & operator=(double d)
Fill the vector property with the double.
Void structure.
Definition: common.hpp:63
This class is a trick to indicate the compiler a specific specialization pattern. ...
Definition: memory_c.hpp:201
vector_dist_expression_op(const exp1 &o1, const exp2 &o2)
constructor from two expressions
Call the init function if a type T has the function init.
r_type value(const vect_dist_key_dx &key) const
Evaluate the expression.
it take an expression and create the negatove of this expression
void init() const
This function must be called before value.
static const unsigned int prop
Property id of the point.
double value(const vect_dist_key_dx &k) const
Evaluate the expression.
static auto value(vector &v, const vect_dist_key_dx &k) -> decltype(v.template getProp< prp >(k))
return the value (position or property) of the particle k in the vector v
vector_dist_expression(vector &v)
constructor for an external vector
void init() const
This function must be called before value.
void init() const
This function must be called before value.
vector_dist_expression_op(const exp1 &o1)
constructor from an expresssion
static void call(T &r_exp)
it call the function init for r_exp if T has the function init