OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
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 #include "lib/pdata.hpp"
13 #include "cuda/vector_dist_operators_cuda.cuh"
14 
15 #define PROP_CUSTOM (unsigned int)-2
16 
17 #define VECT_SUM 1
18 #define VECT_SUB 2
19 #define VECT_MUL 3
20 #define VECT_DIV 4
21 
22 #define VECT_APPLYKER_IN 7
23 #define VECT_APPLYKER_OUT 8
24 #define VECT_APPLYKER_REDUCE 9
25 #define VECT_APPLYKER_IN_GEN 10
26 #define VECT_APPLYKER_OUT_GEN 11
27 #define VECT_APPLYKER_REDUCE_GEN 12
28 #define VECT_APPLYKER_IN_SIM 13
29 #define VECT_APPLYKER_OUT_SIM 14
30 #define VECT_APPLYKER_REDUCE_SIM 15
31 
32 #define VECT_APPLYKER_IN_GEN_SORT 16
33 #define VECT_APPLYKER_IN_SORT 17
34 #define VECT_APPLYKER_IN_SIM_SORT 18
35 
36 #define VECT_NORM 56
37 #define VECT_NORM2 57
38 #define VECT_ABS 58
39 #define VECT_EXP 59
40 #define VECT_EXP2 60
41 #define VECT_EXPM1 61
42 #define VECT_LOG 62
43 #define VECT_LOG10 63
44 #define VECT_LOG2 64
45 #define VECT_LOG1P 65
46 #define VECT_SQRT 67
47 #define VECT_CBRT 68
48 #define VECT_SIN 69
49 #define VECT_COS 70
50 #define VECT_TAN 71
51 #define VECT_ASIN 72
52 #define VECT_ACOS 73
53 #define VECT_ATAN 74
54 #define VECT_SINH 75
55 #define VECT_COSH 76
56 #define VECT_TANH 77
57 #define VECT_ASINH 78
58 #define VECT_ACOSH 79
59 #define VECT_ATANH 80
60 #define VECT_ERF 81
61 #define VECT_ERFC 82
62 #define VECT_TGAMMA 83
63 #define VECT_LGAMMA 84
64 #define VECT_CEIL 85
65 #define VECT_FLOOR 86
66 #define VECT_TRUNC 87
67 #define VECT_ROUND 88
68 #define VECT_NEARBYINT 89
69 #define VECT_RINT 90
70 #define VECT_PMUL 91
71 #define VECT_SUB_UNI 92
72 #define VECT_SUM_REDUCE 93
73 #define VECT_COMP 94
74 #define VECT_NORM_INF 95
75 
76 
77 #define VECT_DCPSE 100
78 #define VECT_DCPSE_V 101
79 #define VECT_DCPSE_V_SUM 102
80 #define VECT_DCPSE_V_DOT 103
81 #define VECT_DCPSE_V_DIV 104
82 #define VECT_DCPSE_V_CURL2D 105
83 #define VECT_COPY_1_TO_N 300
84 #define VECT_COPY_N_TO_N 301
85 #define VECT_COPY_N_TO_1 302
86 #define VECT_PMUL 91
87 #define VECT_SUB_UNI 92
88 
89 
90 
91 
92 template<bool cond, typename exp1, typename exp2>
94 {
95  typedef typename exp2::vtype vtype;
96 
97  static auto getVector(const exp1 & o1, const exp2 & o2) -> decltype(o2.getVector())
98  {
99  return o2.getVector();
100  }
101 };
102 
103 template<typename exp1, typename exp2>
104 struct first_or_second<true,exp1,exp2>
105 {
106  typedef typename exp1::vtype vtype;
107 
108  static auto getVector(const exp1 & o1, const exp2 & o2) -> decltype(o1.getVector())
109  {
110  return o1.getVector();
111  }
112 };
113 
114 template<typename T, typename Sfinae = void>
115 struct has_vtype: std::false_type {};
116 
126 template<typename T>
127 struct has_vtype<T, typename Void<typename T::vtype>::type> : std::true_type
128 {};
129 
130 
131 
132 
142 template<typename ObjType, typename Sfinae = void>
143 struct has_init: std::false_type {};
144 
145 template<typename ObjType>
146 struct has_init<ObjType, typename Void<typename ObjType::has_init>::type> : std::true_type
147 {};
148 
154 template <typename T, bool has_init = has_init<T>::value >
156 {
158  static inline void call(T & r_exp)
159  {
160  r_exp.init();
161  }
162 };
163 
169 template <typename T>
170 struct call_init_if_needed<T,false>
171 {
173  static inline void call(T & r_exp)
174  {
175  }
176 };
177 
178 
179 
186 template <typename exp1, typename exp2, unsigned int op>
188 {
189 
190 };
191 
192 template<typename v1_type, typename v2_type>
194 {
195  typedef v1_type type;
196 
197  template<typename exp1, typename exp2>
198  static const type & getVector(const exp1 & o1, const exp2 & o2)
199  {
200  return o1.getVector();
201  }
202 
203  template<typename exp1>
204  static const type & getVector(const exp1 & o1)
205  {
206  return o1.getVector();
207  }
208 };
209 
210 
211 template<typename v2_type>
212 struct vector_result<void,v2_type>
213 {
214  typedef v2_type type;
215 
216  template<typename exp1, typename exp2>
217  static const type & getVector(const exp1 & o1, const exp2 & o2)
218  {
219  return o2.getVector();
220  }
221 
222  template<typename exp2>
223  static const type & getVector(exp2 & o2)
224  {
225  return o2.getVector();
226  }
227 };
228 
229 template<typename NN1_type, typename NN2_type>
231 {
232  typedef NN1_type type;
233 
234  template<typename exp1, typename exp2>
235  static type * getNN(exp1 & o1, exp2 & o2)
236  {
237  return o1.getNN();
238  }
239 
240  template<typename exp1>
241  static type * getNN(exp1 & o1)
242  {
243  return o1.getNN();
244  }
245 };
246 
247 
248 template<typename NN2_type>
249 struct nn_type_result<void,NN2_type>
250 {
251  typedef NN2_type type;
252 
253  template<typename exp1, typename exp2>
254  static type * getNN(exp1 & o1, exp2 & o2)
255  {
256  return o2.getNN();
257  }
258 
259  template<typename exp2>
260  static type * getNN(exp2 & o2)
261  {
262  return o2.getNN();
263  }
264 };
265 
266 template<bool s1, bool s2>
268 {
269  typedef boost::mpl::bool_<s1 | s2> type;
270 };
271 
278 template <typename exp1, typename exp2>
279 class vector_dist_expression_op<exp1,exp2,VECT_SUM>
280 {
282  const exp1 o1;
283 
285  const exp2 o2;
286 
287 public:
288 
290  typedef typename exp1::is_ker is_ker;
291 
294 
296  typedef typename vector_is_sort_result<exp1::is_sort::value,exp2::is_sort::value>::type is_sort;
297 
299  typedef typename nn_type_result<typename exp1::NN_type,typename exp2::NN_type>::type NN_type;
300 
302  inline vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
303  :o1(o1),o2(o2)
304  {}
305 
311  inline NN_type * getNN() const
312  {
314  }
315 
321  inline void init() const
322  {
323  o1.init();
324  o2.init();
325  }
326 
334  template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) + o2.value(vect_dist_key_dx()))>::type >
335  __device__ __host__ inline r_type value(const vect_dist_key_dx & key) const
336  {
337  return o1.value(key) + o2.value(key);
338  }
339 
340  template<typename Sys_eqs, typename pmap_type, typename unordered_map_type, typename coeff_type>
341  inline void value_nz(pmap_type & p_map, const vect_dist_key_dx & key, unordered_map_type & cols, coeff_type & coeff, unsigned int comp) const
342  {
343  o1.template value_nz<Sys_eqs>(p_map,key,cols,coeff, comp);
344  o2.template value_nz<Sys_eqs>(p_map,key,cols,coeff, comp);
345  }
346 
354  const vtype & getVector()
355  {
356  return first_or_second<has_vtype<exp1>::value,exp1,exp2>::getVector(o1,o2);
357  }
358 
366  const vtype & getVector() const
367  {
368  return first_or_second<has_vtype<exp1>::value,exp1,exp2>::getVector(o1,o2);
369  }
370 
378  template<typename r_type=typename std::remove_reference<decltype(o1.value(0) + o2.value(0))>::type >
379  __device__ __host__ inline r_type value(const unsigned int & key) const
380  {
381  return o1.value(key) + o2.value(key);
382  }
383 
384 };
385 
392 template <typename exp1, typename exp2>
394 {
396  const exp1 o1;
397 
399  const exp2 o2;
400 
401 public:
402 
405 
406  typedef typename exp1::is_ker is_ker;
407 
409  typedef typename vector_is_sort_result<exp1::is_sort::value,exp2::is_sort::value>::type is_sort;
410 
412  typedef typename nn_type_result<typename exp1::NN_type,typename exp2::NN_type>::type NN_type;
413 
415  inline vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
416  :o1(o1),o2(o2)
417  {}
418 
424  inline NN_type * getNN() const
425  {
427  }
428 
429 
435  inline void init() const
436  {
437  o1.init();
438  o2.init();
439  }
440 
448  template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) - o2.value(vect_dist_key_dx()))>::type >
449  inline r_type value(const vect_dist_key_dx & key) const
450  {
451  return o1.value(key) - o2.value(key);
452  }
453 
461  template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) - o2.value(vect_dist_key_dx()))>::type >
462  __device__ __host__ inline r_type value(const unsigned int & key) const
463  {
464  return o1.value(key) - o2.value(key);
465  }
466 
474  const vtype & getVector()
475  {
476  return first_or_second<has_vtype<exp1>::value,exp1,exp2>::getVector(o1,o2);
477  }
478 
486  const vtype & getVector() const
487  {
488  return first_or_second<has_vtype<exp1>::value,exp1,exp2>::getVector(o1,o2);
489  }
490 
491  template<typename Sys_eqs,typename pmap_type, typename unordered_map_type, typename coeff_type>
492  inline void value_nz(pmap_type & p_map, const vect_dist_key_dx & key, unordered_map_type & cols, coeff_type & coeff, unsigned int comp) const
493  {
494  o1.template value_nz<Sys_eqs>(p_map,key,cols,coeff,comp);
495  coeff_type tmp = -coeff;
496  o2.template value_nz<Sys_eqs>(p_map,key,cols,tmp,comp);
497  }
498 };
499 
506 template <typename exp1, typename exp2>
507 class vector_dist_expression_op<exp1,exp2,VECT_MUL>
508 {
510  const exp1 o1;
511 
513  const exp2 o2;
514 
515 public:
516 
519 
520  typedef typename exp1::is_ker is_ker;
521 
523  typedef typename vector_is_sort_result<exp1::is_sort::value,exp2::is_sort::value>::type is_sort;
524 
526  typedef typename nn_type_result<typename exp1::NN_type,typename exp2::NN_type>::type NN_type;
527 
529  vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
530  :o1(o1),o2(o2)
531  {}
532 
538  inline void init() const
539  {
540  o1.init();
541  o2.init();
542  }
543 
551  template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) * o2.value(vect_dist_key_dx()))>::type >
552  __device__ __host__ inline r_type value(const vect_dist_key_dx & key) const
553  {
554  return o1.value(key) * o2.value(key);
555  }
556 
557  template<typename Sys_eqs,typename pmap_type, typename unordered_map_type, typename coeff_type>
558  inline void value_nz(pmap_type & p_map, const vect_dist_key_dx & key, unordered_map_type & cols, coeff_type & coeff, unsigned int comp) const
559  {
560  //o1.template value_nz<Sys_eqs>(p_map,key,cols,coeff,comp);
561  auto coeff_tmp = o1.value(key) * coeff;
562  o2.template value_nz<Sys_eqs>(p_map,key,cols,coeff_tmp,comp);
563  }
564 
572  const vtype & getVector()
573  {
574  return first_or_second<has_vtype<exp1>::value,exp1,exp2>::getVector(o1,o2);
575  }
576 
584  const vtype & getVector() const
585  {
586  return first_or_second<has_vtype<exp1>::value,exp1,exp2>::getVector(o1,o2);
587  }
588 
596  template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) * o2.value(vect_dist_key_dx()))>::type >
597  __device__ __host__ inline r_type value(const unsigned int & key) const
598  {
599  return o1.value(key) * o2.value(key);
600  }
601 };
602 
609 template <typename exp1, typename exp2>
611 {
613  const exp1 o1;
614 
616  const exp2 o2;
617 
618 public:
619 
622 
623  typedef typename exp1::is_ker is_ker;
624 
626  typedef typename vector_is_sort_result<exp1::is_sort::value,exp2::is_sort::value>::type is_sort;
627 
629  typedef typename nn_type_result<typename exp1::NN_type,typename exp2::NN_type>::type NN_type;
630 
632  vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
633  :o1(o1),o2(o2)
634  {}
635 
641  inline NN_type * getNN() const
642  {
644  }
645 
646 
652  inline void init() const
653  {
654  o1.init();
655  o2.init();
656  }
657 
665  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
666  {
667  return o1.value(key) / o2.value(key);
668  }
669 
670  template<typename Sys_eqs,typename pmap_type, typename unordered_map_type, typename coeff_type>
671  inline void value_nz(pmap_type & p_map, const vect_dist_key_dx & key, unordered_map_type & cols, coeff_type & coeff, unsigned int comp) const
672  {
673  std::cout << __FILE__ << ":" << __LINE__ << " You are trying to divide by an operator, this is not possible " << std::endl;
674  }
675 
683  const vtype & getVector()
684  {
685  return first_or_second<has_vtype<exp1>::value,exp1,exp2>::getVector(o1,o2);
686  }
687 
695  const vtype & getVector() const
696  {
697  return first_or_second<has_vtype<exp1>::value,exp1,exp2>::getVector(o1,o2);
698  }
699 
707  template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) / o2.value(vect_dist_key_dx()))>::type >
708  __device__ __host__ inline r_type value(const unsigned int & key) const
709  {
710  return o1.value(key) / o2.value(key);
711  }
712 };
713 
714 
719 template <typename exp1>
721 {
723  const exp1 o1;
724 
725 public:
726 
727 
728  typedef typename exp1::is_ker is_ker;
729 
731  typedef typename vector_result<typename exp1::vtype,void>::type vtype;
732 
734  typedef typename vector_is_sort_result<exp1::is_sort::value,false>::type is_sort;
735 
737  typedef typename nn_type_result<typename exp1::NN_type,void>::type NN_type;
738 
740  vector_dist_expression_op(const exp1 & o1)
741  :o1(o1)
742  {}
743 
749  inline NN_type * getNN() const
750  {
752  }
753 
759  const vtype & getVector()
760  {
762  }
763 
765  inline void init() const
766  {
767  o1.init();
768  }
769 
777  const vtype & getVector() const
778  {
779  return o1.getVector();
780  }
781 
782 
784  template<typename r_type=typename std::remove_reference<decltype(-(o1.value(vect_dist_key_dx(0))))>::type >
785  __device__ __host__ inline r_type value(const vect_dist_key_dx & key) const
786  {
787  return -(o1.value(key));
788  }
789 
790  template<typename Sys_eqs, typename pmap_type, typename unordered_map_type, typename coeff_type>
791  inline void value_nz(pmap_type & p_map, const vect_dist_key_dx & key, unordered_map_type & cols, coeff_type & coeff, unsigned int comp) const
792  {
793  coeff_type coeff_tmp = -coeff;
794  o1.template value_nz<Sys_eqs>(p_map,key,cols,coeff_tmp, comp);
795  }
797  template<typename r_type=typename std::remove_reference<decltype(-(o1.value(vect_dist_key_dx(0))))>::type >
798  __device__ __host__ inline r_type value(const unsigned int & key) const
799  {
800  return -(o1.value(key));
801  }
802 };
803 
808 template<int impl, bool vect_ker>
810 {
811  typedef boost::mpl::int_<impl> type;
812 };
813 
814 template<>
815 struct vector_dist_expression_comp_sel<comp_host,true>
816 {
817  typedef boost::mpl::int_<-1> type;
818 };
819 
820 template<>
821 struct vector_dist_expression_comp_sel<comp_dev,false>
822 {
823  typedef boost::mpl::int_<-1> type;
824 };
825 
826 template<typename vector, bool is_ker = has_vector_kernel<vector>::type::value>
828 {
829  typedef vector& type;
830 };
831 
832 template<typename vector>
833 struct vector_expression_transform<vector,true>
834 {
835  typedef vector type;
836 };
837 
838 template<typename vector>
840 {
841  vector v;
842 
843  v_mem_mutable(vector & v)
844  :v(v)
845  {}
846 };
847 
848 
849 
856 template<unsigned int prp, typename vector>
858 {
861 
863 
864 public:
865 
866  typedef typename has_vector_kernel<vector>::type is_ker;
867 
869  typedef vector vtype;
870 
872  typedef boost::mpl::bool_<false> is_sort;
873 
875  typedef void NN_type;
876 
878  static const unsigned int prop = prp;
879 
880  int var_id = 0;
881 
882  void setVarId(int var_id)
883  {
884  this->var_id = var_id;
885  }
886 
889  :v(v),vdl(NULL)
890  {}
891 
894  {
895  if (vdl != NULL)
896  {vdl->remove(v.v);}
897  }
898 
904  inline void * getNN() const
905  {
906  return NULL;
907  }
908 
916  __device__ __host__ const vector & getVector() const
917  {
918  return v.v;
919  }
920 
928  __device__ __host__ vector & getVector()
929  {
930  return v.v;
931  }
932 
939  {
940  vdkl.add(v.v,is_sort);
941  vdl = &vdkl;
942  }
943 
949  inline void init() const
950  {}
951 
959  __host__ __device__ inline auto value(const vect_dist_key_dx & k) const -> decltype(pos_or_propR<vector,prp>::value(v.v,k))
960  {
962  }
963 
971  __host__ __device__ inline auto value(const vect_dist_key_dx & k) -> decltype(pos_or_propR<vector,prp>::value(v.v,k))
972  {
974  }
975 
983  __device__ __host__ inline auto value(const unsigned int & k) const -> decltype(pos_or_propR<vector,prp>::value(v.v,k))
984  {
986  }
987 
995  __device__ __host__ inline auto value(const unsigned int & k) -> decltype(pos_or_propR<vector,prp>::value(v.v,k))
996  {
998  }
999 
1000  inline auto get(const vect_dist_key_dx & key) const -> decltype(value(key))
1001  {
1002  return this->value(key);
1003  }
1004 
1012  template<unsigned int prp2> vector & operator=(const vector_dist_expression<prp2,vector> & v_exp)
1013  {
1014  if (v_exp.getVector().isSubset() == true)
1015  {
1016  std::cout << __FILE__ << ":" << __LINE__ << " error on the right hand side of the expression you have to use non-subset properties" << std::endl;
1017  return v.v;
1018  }
1019 
1021  {
1024  ::compute_expr(v.v,v_exp);
1025  }
1026  else
1027  {
1030  ::compute_expr(v.v,v_exp);
1031  }
1032 
1033  return v.v;
1034  }
1035 
1043  template<typename T> vector & operator=(const vector_dist_expression<0,openfpm::vector<aggregate<T>>> & v_exp)
1044  {
1047  ::compute_expr(v.v,v_exp);
1048 
1049  return v.v;
1050  }
1051 
1059  template<typename exp1, typename exp2, unsigned int op>
1061  {
1062  if (v_exp.getVector().isSubset() == true)
1063  {
1064  std::cout << __FILE__ << ":" << __LINE__ << " error on the right hand side of the expression you have to use non-subset properties" << std::endl;
1065  return v.v;
1066  }
1067 
1069  {
1074  ::compute_expr(v.v,v_exp);
1075  }
1076  else
1077  {
1082  ::compute_expr(v.v,v_exp);
1083  }
1084 
1085  return v.v;
1086  }
1087 
1095  vector & operator=(double d)
1096  {
1098  {
1100  false,
1103  ::compute_const(v.v,d);
1104  }
1105  else
1106  {
1108  false,
1111  ::compute_const(v.v,d);
1112  }
1113 
1114  return v.v;
1115  }
1116 
1117 
1118  template<typename Sys_eqs, typename pmap_type, typename unordered_map_type, typename coeff_type>
1119  inline void value_nz(pmap_type & p_map, const vect_dist_key_dx & key, unordered_map_type & cols, coeff_type & coeff, unsigned int comp) const
1120  {
1121  cols[p_map. template getProp<0>(key)*Sys_eqs::nvar + var_id + comp] += coeff;
1122  }
1123 
1124  inline vector_dist_expression_op<vector_dist_expression<prp,vector>,boost::mpl::int_<1>,VECT_COMP> operator[](int comp)
1125  {
1126  int comp_n[1];
1127 
1128  comp_n[0] = comp;
1129 
1130  vector_dist_expression_op<vector_dist_expression<prp,vector>,boost::mpl::int_<1>,VECT_COMP> v_exp(*this,comp_n,var_id);
1131 
1132  return v_exp;
1133  }
1134 };
1135 
1142 template<typename T>
1143 class vector_dist_expression<0,openfpm::vector<aggregate<T>> >
1144 {
1147 
1149  mutable vector v;
1150 
1151 public:
1152 
1153  typedef T * iterator;
1154  typedef const T * const_iterator;
1155 
1156  typedef typename has_vector_kernel<vector>::type is_ker;
1157 
1159  typedef vector vtype;
1160 
1162  typedef T value_type;
1163 
1165  typedef boost::mpl::bool_<false> is_sort;
1166 
1168  typedef void NN_type;
1169 
1171  static const unsigned int prop = 0;
1172 
1173  int var_id = 0;
1174 
1175  void setVarId(int var_id)
1176  {
1177  this->var_id = var_id;
1178  }
1179 
1181  iterator begin()
1182  { return &v.template get<0>(0); }
1183 
1184  const_iterator begin() const
1185  { return &v.template get<0>(0); }
1186 
1187  iterator end()
1188  { return &v.template get<0>(v.size()-1)+1; }
1189 
1190  const_iterator end() const
1191  { return &v.template get<0>(v.size()-1)+1; }
1192 
1193  size_t size() const
1194  { return v.size(); }
1195 
1196  void resize(size_t n)
1197  {
1198  // Here
1199 
1200  v.resize(n);
1201  }
1202 
1203 /* T * begin() {
1204  return &v.template get<0>(0);
1205  }
1206 
1207  T * end() {
1208  return &v.template get<0>(v.size()-1);
1209  }*/
1210 
1211  // ... [ implement container interface ]
1212 //]
1213  //const double & operator[]( const size_t n ) const
1214  //{ return m_v[n]; }
1215 
1216  //double & operator[]( const size_t n )
1217  //{ return m_v[n]; }
1218 
1219 
1221 
1223  {}
1224 
1225  template<typename exp1, typename exp2, unsigned int op>
1227  {
1228  this->operator=(v_exp);
1229  }
1230 
1236  inline void * getNN() const
1237  {
1238  return NULL;
1239  }
1240 
1248  __device__ __host__ const vector & getVector() const
1249  {
1250  return v;
1251  }
1252 
1260  __device__ __host__ vector & getVector()
1261  {
1262  return v;
1263  }
1264 
1270  inline void init() const
1271  {}
1272 
1280  __host__ inline auto value(const vect_dist_key_dx & k) const -> decltype(v.template get<0>(k.getKey()))
1281  {
1282  return v.template get<0>(k.getKey());
1283  }
1284 
1285 
1293  template<unsigned int prp2, typename vector2> vector & operator=(const vector_dist_expression<prp2,vector2> & v_exp)
1294  {
1295  if (v_exp.getVector().isSubset() == true)
1296  {
1297  std::cout << __FILE__ << ":" << __LINE__ << " error on the right hand side of the expression you have to use non-subset properties" << std::endl;
1298  return v;
1299  }
1300 
1301  v.resize(v_exp.getVector().size_local());
1302 
1304  {
1307  ::compute_expr(v,v_exp);
1308  }
1309  else
1310  {
1313  ::compute_expr(v,v_exp);
1314  }
1315 
1316  return v;
1317  }
1318 
1319 
1327  template<typename exp1, typename exp2, unsigned int op>
1329  {
1330  if (v_exp.getVector().isSubset() == true)
1331  {
1332  std::cout << __FILE__ << ":" << __LINE__ << " error on the right hand side of the expression you have to use non-subset properties" << std::endl;
1333  return v;
1334  }
1335 
1336  v.resize(v_exp.getVector().size_local());
1337 
1339  {
1344  ::compute_expr(v,v_exp);
1345  }
1346  else
1347  {
1352  ::compute_expr(v,v_exp);
1353  }
1354 
1355  return v;
1356  }
1357 
1365  vector & operator=(double d)
1366  {
1367  std::cout << __FILE__ << ":" << __LINE__ << " Error: temporal with constants is unsupported" << std::endl;
1368  }
1369 
1370 
1371  template<typename Sys_eqs, typename pmap_type, typename unordered_map_type, typename coeff_type>
1372  inline void value_nz(pmap_type & p_map, const vect_dist_key_dx & key, unordered_map_type & cols, coeff_type & coeff, unsigned int comp) const
1373  {
1374  std::cout << __FILE__ << ":" << __LINE__ << " Error: use of temporal is not supported to construct equations";
1375  }
1376 
1377  inline vector_dist_expression_op<vector_dist_expression<0,vector>,boost::mpl::int_<1>,VECT_COMP> operator[](int comp)
1378  {
1379  int comp_n[1];
1380 
1381  comp_n[0] = comp;
1382 
1383  vector_dist_expression_op<vector_dist_expression<0,vector>,boost::mpl::int_<1>,VECT_COMP> v_exp(*this,comp_n,var_id);
1384 
1385  return v_exp;
1386  }
1387 };
1388 
1389 
1390 template<typename T> using texp_v = vector_dist_expression<0,openfpm::vector<aggregate<T>> >;
1391 
1392 template<typename vector, unsigned int impl>
1394 {
1395  typedef vector type;
1396 
1397  static vector & get(vector & v) {return v;};
1398 
1399  template<typename exp_type, typename vector_klist>
1400  static void register_vector(exp_type & exp_v, vector_klist & v,bool is_sort)
1401  {
1402  }
1403 };
1404 
1405 template<typename vector>
1406 struct switcher_get_v<vector,comp_dev>
1407 {
1408  typedef decltype(std::declval<vector>().toKernel()) type;
1409 
1410  static type get(vector & v) {return v.toKernel();};
1411 
1412  template<typename exp_type, typename vector_klist>
1413  static void register_vector(exp_type & exp_v, vector_klist & v,bool is_sort)
1414  {
1415  exp_v.set_vector_dist_ker_list(v.private_get_vector_dist_ker_list(),is_sort);
1416  }
1417 };
1418 
1423 template <typename exp1,int n>
1424 class vector_dist_expression_op<exp1,boost::mpl::int_<n>,VECT_COMP>
1425 {
1427  exp1 o1;
1428 
1430  int comp[n];
1431 
1432  int var_id = 0;
1433  void setVarId(int var_id)
1434  {
1435  this->var_id = var_id;
1436  }
1437 
1438  typedef vector_dist_expression_op<exp1,boost::mpl::int_<n>,VECT_COMP> myself;
1439 
1440 public:
1441 
1442  typedef std::false_type is_ker;
1443 
1445  typedef boost::mpl::bool_<false> is_sort;
1446 
1448  typedef boost::mpl::bool_<false> NN_type;
1449 
1450  typedef typename exp1::vtype vtype;
1451 
1453 
1454  vector_dist_expression_op(const exp1 & o1, int (& comp)[n], int var_id)
1455  :o1(o1),var_id(var_id)
1456  {
1457  for (int i = 0 ; i < n ; i++)
1458  {this->comp[i] = comp[i];}
1459  }
1460 
1468  __device__ __host__ const vtype & getVector() const
1469  {
1470  return o1.getVector();
1471  }
1472 
1480  __device__ __host__ vtype & getVector()
1481  {
1482  return o1.getVector();
1483  }
1484 
1486  inline void init() const
1487  {
1488  o1.init();
1489  }
1490 
1492  //typedef typename boost::mpl::at<typename vtype::value_type::type,boost::mpl::int_<exp1::prop>>::type property_act;
1493  typedef typename pos_or_propL<vtype,exp1::prop>::property_act property_act;
1494 
1505  __host__ __device__ inline auto value(const vect_dist_key_dx & key) const -> decltype(get_vector_dist_expression_op<n,n == rank_gen<property_act>::type::value>::get(o1,vect_dist_key_dx(0),comp))
1506  {
1508  }
1509 
1520  __host__ __device__ inline auto value(const vect_dist_key_dx & key) -> decltype(get_vector_dist_expression_op<n,n == rank_gen<property_act>::type::value>::get(o1,vect_dist_key_dx(0),comp))
1521  {
1523  }
1524 
1535  inline auto get(const vect_dist_key_dx & key) const -> decltype(value(key))
1536  {
1537  return this->value(key);
1538  }
1539 
1540  template<typename Sys_eqs, typename pmap_type, typename unordered_map_type, typename coeff_type>
1541  inline void value_nz(pmap_type & p_map, const vect_dist_key_dx & key, unordered_map_type & cols, coeff_type & coeff, unsigned int comp_) const
1542  {
1543 #ifdef SE_CLASS1
1544 
1545  if (n != 1)
1546  {
1547  std::cout << __FILE__ << ":" << __LINE__ << " Error it only work for tensore of rank 1 ... like vectors " << std::endl;
1548  }
1549 
1550 #endif
1551 
1552  o1.template value_nz<Sys_eqs>(p_map,key,cols,coeff,comp_ + var_id + comp[0]);
1553  }
1554 
1555  inline vector_dist_expression_op<exp1,boost::mpl::int_<2>,VECT_COMP> operator[](int comp_)
1556  {
1557  int comp_n[n+1];
1558 
1559  for (int i = 0 ; i < n ; i++)
1560  {comp_n[i] = comp[i];}
1561  comp_n[n] = comp_;
1562 
1563  vector_dist_expression_op<exp1,boost::mpl::int_<2>,VECT_COMP> v_exp(o1,comp_n,var_id);
1564 
1565  return v_exp;
1566  }
1567 
1575  template<typename T> vtype & operator=(const vector_dist_expression<0,openfpm::vector<aggregate<T>>> & v_exp)
1576  {
1577  v_exp.init();
1578 
1579  auto & v = getVector();
1580 /*#ifdef SE_CLASS1
1581  auto &v2=v_exp.getVector();
1582 
1583  SubsetSelector_impl<std::remove_reference<decltype(v)>::type::is_it_a_subset::value>::check(v2,v);
1584 #endif*/
1585 
1586  auto it = v.getDomainIterator();
1587 
1588  while (it.isNext())
1589  {
1590  auto key = it.get();
1591  auto key_orig = v.getOriginKey(key);
1592 
1593  get_vector_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign<exp1::prop>(v_exp,v,key,key_orig,comp);
1594 
1595  ++it;
1596  }
1597 
1598  return v;
1599  }
1600 
1608  template<unsigned int prp2> vtype & operator=(const vector_dist_expression<prp2,vtype> & v_exp)
1609  {
1610  v_exp.init();
1611 
1612  auto & v = getVector();
1613 #ifdef SE_CLASS1
1614  auto &v2=v_exp.getVector();
1615 
1616  SubsetSelector_impl<std::remove_reference<decltype(v)>::type::is_it_a_subset::value>::check(v2,v);
1617 #endif
1618  auto it = v.getDomainIterator();
1619 
1620  while (it.isNext())
1621  {
1622  auto key = it.get();
1623  auto key_orig = v.getOriginKey(key);
1624 
1625  get_vector_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign<exp1::prop>(v_exp,v,key,key_orig,comp);
1626 
1627  ++it;
1628  }
1629 
1630  return v;
1631  }
1632 
1640  template<typename exp1_, typename exp2_, unsigned int op> vtype & operator=(const vector_dist_expression_op<exp1_,exp2_,op> & v_exp)
1641  {
1642  if (v_exp.getVector().isSubset() == true)
1643  {
1644  std::cout << __FILE__ << ":" << __LINE__ << " error on the right hand side of the expression you have to use non-subset properties" << std::endl;
1645  return this->getVector();
1646  }
1647 
1649  {
1652  ::compute_expr_slice(o1.getVector(),v_exp,comp);
1653  }
1654  else
1655  {
1658  ::compute_expr_slice(o1.getVector(),v_exp,comp);
1659  }
1660 
1661  return this->getVector();
1662  }
1663 
1671  vtype & operator=(double d)
1672  {
1673  auto & v = getVector();
1674 
1675  auto it = v.getDomainIterator();
1676 
1677  while (it.isNext())
1678  {
1679  auto key = it.get();
1680 
1681  //pos_or_propL<vtype,exp1::prp>::value(v,key) = d;
1682  get_vector_dist_expression_op<n,n == rank_gen<property_act>::type::value>::template assign_double<exp1::prop>(d,v,key,comp);
1683 
1684 
1685  ++it;
1686  }
1687 
1688  return v;
1689  }
1690 };
1691 
1698 template <unsigned int prp,unsigned int impl = comp_host, typename vector>
1700 {
1703 
1705 
1706  return exp_v;
1707 }
1708 
1709 
1716 template <unsigned int prp,typename vector>
1718 {
1719  auto vk = v.toKernel_sorted();
1721 
1722  exp_v.set_vector_dist_ker_list(v.private_get_vector_dist_ker_list(),true);
1723 
1724  return exp_v;
1725 }
1726 
1732 template<unsigned int prp>
1733 class vector_dist_expression<prp,double>
1734 {
1736  double d;
1737 
1738 public:
1739 
1740  typedef std::false_type is_ker;
1741 
1743  typedef boost::mpl::bool_<false> is_sort;
1744 
1745  typedef void NN_type;
1746 
1748  inline vector_dist_expression(const double & d)
1749  :d(d)
1750  {}
1751 
1757  inline void init() const
1758  {}
1759 
1769  __device__ __host__ inline double value(const vect_dist_key_dx & k) const
1770  {
1771  return d;
1772  }
1773 
1774 
1775  template<typename Sys_eqs, typename pmap_type, typename unordered_map_type, typename coeff_type>
1776  inline void value_nz(pmap_type & p_map, const vect_dist_key_dx & key, unordered_map_type & cols, coeff_type & coeff, unsigned int comp) const
1777  {
1778  cols[p_map. template getProp<0>(key)*Sys_eqs::nvar + comp] += coeff;
1779  }
1789  __host__ __device__ inline double value(const unsigned int & k) const
1790  {
1791  return d;
1792  }
1793 };
1794 
1795 
1801 template<unsigned int prp>
1803 {
1805  float d;
1806 
1807 public:
1808 
1809  typedef std::false_type is_ker;
1810 
1811 
1813  typedef boost::mpl::bool_<false> is_sort;
1814 
1815  typedef void NN_type;
1816 
1818  inline vector_dist_expression(const float & d)
1819  :d(d)
1820  {}
1821 
1827  inline void init() const
1828  {}
1829 
1839  inline float value(const vect_dist_key_dx & k) const
1840  {
1841  return d;
1842  }
1843 
1853  __device__ __host__ inline float value(const unsigned int & k) const
1854  {
1855  return d;
1856  }
1857 };
1858 
1859 /* \brief sum two distributed vector expression
1860  *
1861  * \param va vector expression one
1862  * \param vb vector expression two
1863  *
1864  * \return an object that encapsulate the expression
1865  *
1866  */
1867 template<unsigned int p1, unsigned int p2, typename v1, typename v2>
1869 operator+(const vector_dist_expression<p1,v1> & va, const vector_dist_expression<p2,v2> & vb)
1870 {
1872 
1873  return exp_sum;
1874 }
1875 
1876 /* \brief sum two distributed vector expression
1877  *
1878  * \param va vector expression one
1879  * \param vb vector expression two
1880  *
1881  * \return an object that encapsulate the expression
1882  *
1883  */
1884 template<typename exp1 , typename exp2, unsigned int op1, unsigned int prp1, typename v1>
1887 {
1889 
1890  return exp_sum;
1891 }
1892 
1893 /* \brief sum two distributed vector expression
1894  *
1895  * \param va vector expression one
1896  * \param vb vector expression two
1897  *
1898  * \return an object that encapsulate the expression
1899  *
1900  */
1901 template<typename exp1 , typename exp2, unsigned int op1, unsigned int prp1, typename v1>
1904 {
1906 
1907  return exp_sum;
1908 }
1909 
1910 /* \brief sum two distributed vector expression
1911  *
1912  * \param va vector expression one
1913  * \param vb vector expression two
1914  *
1915  * \return an object that encapsulate the expression
1916  *
1917  */
1918 template<typename exp1 , typename exp2, unsigned int op1, typename exp3 , typename exp4, unsigned int op2>
1921 {
1923 
1924  return exp_sum;
1925 }
1926 
1927 /* \brief sum two distributed vector expression
1928  *
1929  * \param va vector expression one
1930  * \param vb vector expression two
1931  *
1932  * \return an object that encapsulate the expression
1933  *
1934  */
1935 template<unsigned int prp1 , typename v1>
1937 operator+(const vector_dist_expression<prp1,v1> & va, double d)
1938 {
1940 
1941  return exp_sum;
1942 }
1943 
1944 /* \brief sum two distributed vector expression
1945  *
1946  * \param va vector expression one
1947  * \param vb vector expression two
1948  *
1949  * \return an object that encapsulate the expression
1950  *
1951  */
1952 template<unsigned int prp1 , typename v1>
1954 operator+(const vector_dist_expression<prp1,v1> & va, float d)
1955 {
1957 
1958  return exp_sum;
1959 }
1960 
1961 /* \brief sum two distributed vector expression
1962  *
1963  * \param va vector expression one
1964  * \param vb vector expression two
1965  *
1966  * \return an object that encapsulate the expression
1967  *
1968  */
1969 template<unsigned int prp1 , typename v1>
1971 operator+(double d, const vector_dist_expression<prp1,v1> & vb)
1972 {
1974 
1975  return exp_sum;
1976 }
1977 
1978 /* \brief sum two distributed vector expression
1979  *
1980  * \param va vector expression one
1981  * \param vb vector expression two
1982  *
1983  * \return an object that encapsulate the expression
1984  *
1985  */
1986 template<unsigned int prp1 , typename v1>
1988 operator+(float d, const vector_dist_expression<prp1,v1> & vb)
1989 {
1991 
1992  return exp_sum;
1993 }
1994 
1995 /* \brief sum two distributed vector expression
1996  *
1997  * \param va vector expression one
1998  * \param vb vector expression two
1999  *
2000  * \return an object that encapsulate the expression
2001  *
2002  */
2003 template<typename exp1 , typename exp2, unsigned int op1>
2005 operator+(const vector_dist_expression_op<exp1,exp2,op1> & va, double d)
2006 {
2008 
2009  return exp_sum;
2010 }
2011 
2012 /* \brief sum two distributed vector expression
2013  *
2014  * \param va vector expression one
2015  * \param vb vector expression two
2016  *
2017  * \return an object that encapsulate the expression
2018  *
2019  */
2020 template<typename exp1 , typename exp2, unsigned int op1>
2022 operator+(const vector_dist_expression_op<exp1,exp2,op1> & va, float d)
2023 {
2025 
2026  return exp_sum;
2027 }
2028 
2029 /* \brief subtract two distributed vector expression
2030  *
2031  * \param va vector expression one
2032  * \param vb vector expression two
2033  *
2034  * \return an object that encapsulate the expression
2035  *
2036  */
2037 template<unsigned int p1, unsigned int p2, typename v1, typename v2>
2039 operator-(const vector_dist_expression<p1,v1> & va, const vector_dist_expression<p2,v2> & vb)
2040 {
2042 
2043  return exp_sum;
2044 }
2045 
2046 
2047 /* \brief subtract two distributed vector expression
2048  *
2049  * \param va vector expression one
2050  * \param vb vector expression two
2051  *
2052  * \return an object that encapsulate the expression
2053  *
2054  */
2055 template<typename exp1, typename exp2, unsigned int op1, unsigned int p2, typename v2>
2058 {
2060 
2061  return exp_sum;
2062 }
2063 
2064 /* \brief minus of a distributed vector expression operator
2065  *
2066  * \param va vector expression one
2067  *
2068  * \return an object that encapsulate the expression
2069  *
2070  */
2071 template<typename exp1, typename exp2_, unsigned int op1>
2073 operator-(const vector_dist_expression_op<exp1,exp2_,op1> & va)
2074 {
2076 
2077  return exp_sum;
2078 }
2079 
2080 /* \brief minus of a distributed vector expression
2081  *
2082  * \param va vector expression one
2083  *
2084  * \return an object that encapsulate the expression
2085  *
2086  */
2087 template<unsigned int p1, typename v1>
2089 operator-(const vector_dist_expression<p1,v1> & va)
2090 {
2091  vector_dist_expression_op<vector_dist_expression<p1,v1>,void,VECT_SUB_UNI> exp_sum(va);
2092 
2093  return exp_sum;
2094 }
2095 
2096 
2097 /* \brief subtract two distributed vector expression
2098  *
2099  * \param va vector expression one
2100  * \param vb vector expression two
2101  *
2102  * \return an object that encapsulate the expression
2103  *
2104  */
2105 template<typename exp1, typename exp2, unsigned int op1, unsigned int p2, typename v2>
2108 {
2110 
2111  return exp_sum;
2112 }
2113 
2114 /* \brief subtract two distributed vector expression
2115  *
2116  * \param va vector expression one
2117  * \param vb vector expression two
2118  *
2119  * \return an object that encapsulate the expression
2120  *
2121  */
2122 template<typename exp1, typename exp2, unsigned int op1, typename exp3, typename exp4, unsigned int op2>
2125 {
2127 
2128  return exp_sum;
2129 }
2130 
2131 /* \brief subtract two distributed vector expression
2132  *
2133  * \param va vector expression one
2134  * \param vb vector expression two
2135  *
2136  * \return an object that encapsulate the expression
2137  *
2138  */
2139 template<unsigned int prp1, typename v1>
2141 operator-(const vector_dist_expression<prp1,v1> & va, double d)
2142 {
2144 
2145  return exp_sum;
2146 }
2147 
2148 /* \brief subtract two distributed vector expression
2149  *
2150  * \param va vector expression one
2151  * \param vb vector expression two
2152  *
2153  * \return an object that encapsulate the expression
2154  *
2155  */
2156 template<unsigned int prp1, typename v1>
2158 operator-(const vector_dist_expression<prp1,v1> & va, float d)
2159 {
2161 
2162  return exp_sum;
2163 }
2164 
2165 /* \brief subtract two distributed vector expression
2166  *
2167  * \param va vector expression one
2168  * \param vb vector expression two
2169  *
2170  * \return an object that encapsulate the expression
2171  *
2172  */
2173 template<unsigned int prp1, typename v1>
2175 operator-(double d, const vector_dist_expression<prp1,v1> & vb)
2176 {
2178 
2179  return exp_sum;
2180 }
2181 
2182 /* \brief subtract two distributed vector expression
2183  *
2184  * \param va vector expression one
2185  * \param vb vector expression two
2186  *
2187  * \return an object that encapsulate the expression
2188  *
2189  */
2190 template<unsigned int prp1, typename v1>
2192 operator-(float d, const vector_dist_expression<prp1,v1> & vb)
2193 {
2195 
2196  return exp_sum;
2197 }
2198 
2199 /* \brief Multiply two distributed vector expression
2200  *
2201  * \param va vector expression one
2202  * \param vb vector expression two
2203  *
2204  * \return an object that encapsulate the expression
2205  *
2206  */
2207 template<unsigned int p2, typename v2>
2209 operator*(double d, const vector_dist_expression<p2,v2> & vb)
2210 {
2212 
2213  return exp_sum;
2214 }
2215 
2216 /* \brief Multiply two distributed vector expression
2217  *
2218  * \param va vector expression one
2219  * \param vb vector expression two
2220  *
2221  * \return an object that encapsulate the expression
2222  *
2223  */
2224 template<unsigned int p2, typename v2>
2226 operator*(float d, const vector_dist_expression<p2,v2> & vb)
2227 {
2229 
2230  return exp_sum;
2231 }
2232 
2233 /* \brief Multiply two distributed vector expression
2234  *
2235  * \param va vector expression one
2236  * \param vb vector expression two
2237  *
2238  * \return an object that encapsulate the expression
2239  *
2240  */
2241 template<unsigned int p2, typename v2>
2243 operator*(const vector_dist_expression<p2,v2> & va, double d)
2244 {
2246 
2247  return exp_sum;
2248 }
2249 
2250 /* \brief Multiply two distributed vector expression
2251  *
2252  * \param va vector expression one
2253  * \param vb vector expression two
2254  *
2255  * \return an object that encapsulate the expression
2256  *
2257  */
2258 template<unsigned int p2, typename v2>
2260 operator*(const vector_dist_expression<p2,v2> & va, float d)
2261 {
2263 
2264  return exp_sum;
2265 }
2266 
2267 /* \brief Multiply two distributed vector expression
2268  *
2269  * \param va vector expression one
2270  * \param vb vector expression two
2271  *
2272  * \return an object that encapsulate the expression
2273  *
2274  */
2275 template<unsigned int p1, typename v1,unsigned int p2, typename v2>
2277 operator*(const vector_dist_expression<p1,v1> & va, const vector_dist_expression<p2,v2> & vb)
2278 {
2280 
2281  return exp_sum;
2282 }
2283 
2284 /* \brief Multiply two distributed vector expression
2285  *
2286  * \param va vector expression one
2287  * \param vb vector expression two
2288  *
2289  * \return an object that encapsulate the expression
2290  *
2291  */
2292 template<unsigned int p1, typename v1, typename exp1, typename exp2, unsigned int op1>
2295 {
2297 
2298  return exp_sum;
2299 }
2300 
2301 /* \brief Multiply two distributed vector expression
2302  *
2303  * \param va vector expression one
2304  * \param vb vector expression two
2305  *
2306  * \return an object that encapsulate the expression
2307  *
2308  */
2309 template<unsigned int p1, typename v1, typename exp1, typename exp2, unsigned int op1>
2312 {
2314 
2315  return exp_sum;
2316 }
2317 
2318 /* \brief Multiply two distributed vector expression
2319  *
2320  * \param va vector expression one
2321  * \param vb vector expression two
2322  *
2323  * \return an object that encapsulate the expression
2324  *
2325  */
2326 template<typename exp1, typename exp2, unsigned int op1, typename exp3 , typename exp4, unsigned int op2>
2329 {
2331 
2332  return exp_sum;
2333 }
2334 
2335 /* \brief Multiply a distributed vector expression by a number
2336  *
2337  * \param va vector expression
2338  * \param d number
2339  *
2340  * \return an object that encapsulate the expression
2341  *
2342  */
2343 template<typename exp1 , typename exp2, unsigned int op1>
2345 operator*(const vector_dist_expression_op<exp1,exp2,op1> & va, double d)
2346 {
2348 
2349  return exp_sum;
2350 }
2351 
2352 /* \brief Multiply a distributed vector expression by a number
2353  *
2354  * \param va vector expression
2355  * \param d number
2356  *
2357  * \return an object that encapsulate the expression
2358  *
2359  */
2360 template<typename exp1 , typename exp2, unsigned int op1>
2362 operator*(const vector_dist_expression_op<exp1,exp2,op1> & va, float d)
2363 {
2365 
2366  return exp_sum;
2367 }
2368 
2369 /* \brief Multiply a distributed vector expression by a number
2370  *
2371  * \param d number
2372  * \param vb vector expression
2373  *
2374  * \return an object that encapsulate the expression
2375  *
2376  */
2377 template<typename exp1 , typename exp2, unsigned int op1>
2379 operator*(double d, const vector_dist_expression_op<exp1,exp2,op1> & vb)
2380 {
2382 
2383  return exp_sum;
2384 }
2385 
2386 /* \brief Multiply a distributed vector expression by a number
2387  *
2388  * \param d number
2389  * \param vb vector expression
2390  *
2391  * \return an object that encapsulate the expression
2392  *
2393  */
2394 template<typename exp1 , typename exp2, unsigned int op1>
2396 operator*(float d, const vector_dist_expression_op<exp1,exp2,op1> & vb)
2397 {
2399 
2400  return exp_sum;
2401 }
2402 
2403 /* \brief Divide two distributed vector expression
2404  *
2405  * \param va vector expression one
2406  * \param vb vector expression two
2407  *
2408  * \return an object that encapsulate the expression
2409  *
2410  */
2411 template<typename exp1, typename exp2, unsigned int op1>
2413 operator/(const vector_dist_expression_op<exp1,exp2,op1> & va, double d)
2414 {
2416 
2417  return exp_sum;
2418 }
2419 
2420 /* \brief Divide two distributed vector expression
2421  *
2422  * \param va vector expression one
2423  * \param vb vector expression two
2424  *
2425  * \return an object that encapsulate the expression
2426  *
2427  */
2428 template<typename exp1, typename exp2, unsigned int op1>
2430 operator/(const vector_dist_expression_op<exp1,exp2,op1> & va, float d)
2431 {
2433 
2434  return exp_sum;
2435 }
2436 
2437 /* \brief Divide two distributed vector expression
2438  *
2439  * \param va vector expression one
2440  * \param vb vector expression two
2441  *
2442  * \return an object that encapsulate the expression
2443  *
2444  */
2445 template<typename exp1, typename exp2, unsigned int op1>
2447 operator/(double d, const vector_dist_expression_op<exp1,exp2,op1> & va)
2448 {
2450 
2451  return exp_sum;
2452 }
2453 
2454 /* \brief Divide two distributed vector expression
2455  *
2456  * \param va vector expression one
2457  * \param vb vector expression two
2458  *
2459  * \return an object that encapsulate the expression
2460  *
2461  */
2462 template<typename exp1, typename exp2, unsigned int op1>
2464 operator/(float d, const vector_dist_expression_op<exp1,exp2,op1> & va)
2465 {
2467 
2468  return exp_sum;
2469 }
2470 
2471 /* \brief Divide two distributed vector expression
2472  *
2473  * \param va vector expression one
2474  * \param vb vector expression two
2475  *
2476  * \return an object that encapsulate the expression
2477  *
2478  */
2479 template<unsigned int prp1, typename v1>
2481 operator/(const vector_dist_expression<prp1,v1> & va, double d)
2482 {
2484 
2485  return exp_sum;
2486 }
2487 
2488 /* \brief Divide two distributed vector expression
2489  *
2490  * \param va vector expression one
2491  * \param vb vector expression two
2492  *
2493  * \return an object that encapsulate the expression
2494  *
2495  */
2496 template<unsigned int prp1, typename v1>
2498 operator/(const vector_dist_expression<prp1,v1> & va, float d)
2499 {
2501 
2502  return exp_sum;
2503 }
2504 
2505 /* \brief Divide two distributed vector expression
2506  *
2507  * \param va vector expression one
2508  * \param vb vector expression two
2509  *
2510  * \return an object that encapsulate the expression
2511  *
2512  */
2513 template<unsigned int prp1, typename v1>
2515 operator/(double d, const vector_dist_expression<prp1,v1> & va)
2516 {
2518 
2519  return exp_sum;
2520 }
2521 
2522 /* \brief Divide two distributed vector expression
2523  *
2524  * \param va vector expression one
2525  * \param vb vector expression two
2526  *
2527  * \return an object that encapsulate the expression
2528  *
2529  */
2530 template<unsigned int prp1, typename v1>
2532 operator/(float d, const vector_dist_expression<prp1,v1> & va)
2533 {
2535 
2536  return exp_sum;
2537 }
2538 
2539 /* \brief Divide two distributed vector expression
2540  *
2541  * \param va vector expression one
2542  * \param vb vector expression two
2543  *
2544  * \return an object that encapsulate the expression
2545  *
2546  */
2547 template<unsigned int prp1, typename v1, unsigned int prp2, typename v2>
2549 operator/(const vector_dist_expression<prp1,v1> & va, const vector_dist_expression<prp2,v2> & vb)
2550 {
2552 
2553  return exp_sum;
2554 }
2555 
2556 /* \brief Divide two distributed vector expression
2557  *
2558  * \param va vector expression one
2559  * \param vb vector expression two
2560  *
2561  * \return an object that encapsulate the expression
2562  *
2563  */
2564 template<unsigned int prp1, typename v1, typename exp1,typename exp2, unsigned int op1>
2567 {
2569 
2570  return exp_sum;
2571 }
2572 
2573 /* \brief Divide two distributed vector expression
2574  *
2575  * \param va vector expression one
2576  * \param vb vector expression two
2577  *
2578  * \return an object that encapsulate the expression
2579  *
2580  */
2581 template<unsigned int prp1, typename v1, typename exp1,typename exp2, unsigned int op1>
2584 {
2586 
2587  return exp_sum;
2588 }
2589 
2590 /* \brief Divide two distributed vector expression
2591  *
2592  * \param va vector expression one
2593  * \param vb vector expression two
2594  *
2595  * \return an object that encapsulate the expression
2596  *
2597  */
2598 template<typename exp1,typename exp2, unsigned int op1, typename exp3, typename exp4, unsigned int op2>
2601 {
2603 
2604  return exp_sum;
2605 }
2606 
2607 #include "vector_dist_operators_apply_kernel.hpp"
2608 #include "vector_dist_operators_functions.hpp"
2609 #include "vector_dist_operators_extensions.hpp"
2610 #include "Operators/Vector/vector_dist_operator_assign.hpp"
2611 
2612 
2613 #endif /* OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_HPP_ */
convert a type into constant type
Definition: aggregate.hpp:292
r_type value(const vect_dist_key_dx &key) const
Evaluate the expression.
const vtype & getVector() const
Return the vector on which is acting.
vector_dist_expression_op(const exp1 &o1, const exp2 &o2)
constructor from two expressions
const vtype & getVector() const
Return the vector on which is acting.
nn_type_result< typename exp1::NN_type, typename exp2::NN_type >::type NN_type
NN_type.
__host__ __device__ auto value(const vect_dist_key_dx &key) const -> decltype(get_vector_dist_expression_op< n, n==rank_gen< property_act >::type::value >::get(o1, vect_dist_key_dx(0), comp))
Return the result of the expression.
first_or_second< has_vtype< exp1 >::value, exp1, exp2 >::vtype vtype
The type of the internal vector.
vector_result< typename exp1::vtype, void >::type vtype
return the vector type on which this expression operate
__device__ __host__ r_type value(const unsigned int &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.
__host__ auto value(const vect_dist_key_dx &k) const -> decltype(v.template get< 0 >(k.getKey()))
Evaluate the expression.
__host__ __device__ auto value(const vect_dist_key_dx &k) const -> decltype(pos_or_propR< vector, prp >::value(v.v, k))
Evaluate the expression.
vector & operator=(const vector_dist_expression< prp2, vector2 > &v_exp)
Fill the vector property with the evaluated expression.
vector_dist_expression_op(const exp1 &o1, const exp2 &o2)
constructor of the expression to sum two expression
first_or_second< has_vtype< exp1 >::value, exp1, exp2 >::vtype vtype
The type of the internal vector.
__device__ __host__ r_type value(const unsigned int &key) const
return the result of the expression
void add(vector_dist_ker_type &v, bool is_sorted)
Add a new vector_dist_kernel to track.
vector_is_sort_result< exp1::is_sort::value, exp2::is_sort::value >::type is_sort
result for is sort
auto get(const vect_dist_key_dx &key) const -> decltype(value(key))
Return the result of the expression.
vector_is_sort_result< exp1::is_sort::value, exp2::is_sort::value >::type is_sort
result for is sort
__device__ __host__ vtype & getVector()
Return the vector on which is acting.
vtype & operator=(const vector_dist_expression_op< exp1_, exp2_, op > &v_exp)
Fill the vector property with the evaluated expression.
__device__ __host__ const vtype & getVector() const
Return the vector on which is acting.
vtype & operator=(double d)
Fill the vector property with the double.
__device__ __host__ const vector & getVector() const
Return the vector on which is acting.
has_init check if a type has defined a method called init
__device__ __host__ r_type value(const unsigned int &key) const
Evaluate the expression.
void init() const
This function must be called before value.
const vtype & getVector() const
Return the vector on which is acting.
vector vtype
The type of the internal vector.
Grid key for a distributed grid.
first_or_second< has_vtype< exp1 >::value, exp1, exp2 >::vtype vtype
return the vector type on which this expression operate
const vtype & getVector()
Return the vector on which is acting.
nn_type_result< typename exp1::NN_type, typename exp2::NN_type >::type NN_type
NN_type.
static void call(T &r_exp)
it call the function init for r_exp if T has the function init
float value(const vect_dist_key_dx &k) const
Evaluate the expression.
vector & operator=(const vector_dist_expression_op< exp1, exp2, op > &v_exp)
Fill the vector property with the evaluated expression.
vector_is_sort_result< exp1::is_sort::value, false >::type is_sort
result for is sort
__device__ static __host__ 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
boost::mpl::bool_< false > is_sort
result for is sort
pos_or_propL< vtype, exp1::prop >::property_act property_act
property on which this view is acting
void * getNN() const
get the NN object
void init() const
This function must be called before value.
__device__ __host__ r_type value(const unsigned int &key) const
Evaluate the expression.
__device__ __host__ double value(const vect_dist_key_dx &k) const
Evaluate the expression.
selector for position or properties right side position
__device__ __host__ const vector & getVector() const
Return the vector on which is acting.
vector_is_sort_result< exp1::is_sort::value, exp2::is_sort::value >::type is_sort
result for is sort
Unknown operation specialization.
nn_type_result< typename exp1::NN_type, void >::type NN_type
NN_type.
void init() const
This function must be called before value.
nn_type_result< typename exp1::NN_type, typename exp2::NN_type >::type NN_type
NN_type.
vector_dist_expression(const float &d)
constrictor from constant value
const vtype & getVector()
Return the underlying vector.
void init() const
This function must be called before value.
void init() const
This function must be called before value.
void init() const
initialize the expression tree
vector_dist_expression_op(const exp1 &o1, const exp2 &o2)
Costruct a subtraction expression out of two expressions.
vtype & operator=(const vector_dist_expression< 0, openfpm::vector< aggregate< T >>> &v_exp)
Fill the vector property with the evaluated expression.
__device__ __host__ r_type value(const unsigned int &key) const
Evaluate the expression.
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.
__host__ __device__ double value(const unsigned int &k) const
Evaluate the expression.
boost::mpl::bool_< false > is_sort
result for is sort
r_type value(const vect_dist_key_dx &key) const
Evaluate the expression.
vector & operator=(double d)
Fill the vector property with the double.
exp1::is_ker is_ker
indicate if this vector is kernel type
vector_is_sort_result< exp1::is_sort::value, exp2::is_sort::value >::type is_sort
result for is sort
first_or_second< has_vtype< exp1 >::value, exp1, exp2 >::vtype vtype
The type of the internal vector.
Main class that encapsulate a float constant.
Expression implementation computation selector.
vector_dist_expression_op(const exp1 &o1, int(&comp)[n], int var_id)
constructor from an expresssion
vector & operator=(double d)
Fill the vector property with the double.
Void structure.
Definition: common.hpp:73
__device__ __host__ r_type value(const vect_dist_key_dx &key) const
return the result of the expression
__device__ __host__ auto value(const unsigned int &k) -> decltype(pos_or_propR< vector, prp >::value(v.v, k))
Evaluate the expression.
void init() const
This function must be called before value.
void init() const
This function must be called before value.
vtype & operator=(const vector_dist_expression< prp2, vtype > &v_exp)
Fill the vector property with the evaluated expression.
v_mem_mutable< typename vector_expression_transform< vector >::type > v
The vector.
__device__ __host__ float value(const unsigned int &k) const
Evaluate the expression.
__host__ __device__ auto value(const vect_dist_key_dx &key) -> decltype(get_vector_dist_expression_op< n, n==rank_gen< property_act >::type::value >::get(o1, vect_dist_key_dx(0), comp))
Return the result of the expression.
vector_dist_expression_op(const exp1 &o1, const exp2 &o2)
constructor from two expressions
const vtype & getVector()
Return the vector on which is acting.
vector & operator=(const vector_dist_expression< 0, openfpm::vector< aggregate< T >>> &v_exp)
Fill the vector property with the evaluated expression.
void set_vector_dist_ker_list(vector_dist_ker_list< vector > &vdkl, bool is_sort)
set vector_dist_ker_list
const vtype & getVector() const
Return the vector on which is acting.
Main class that encapsulate a vector properties operand to be used for expressions construction Tempo...
void remove(vector_dist_ker_type &v)
Remove one vector_dist_kernels entry.
Call the init function if a type T has the function init.
~vector_dist_expression()
constructor for an external vector
__device__ __host__ vector & getVector()
Return the vector on which is acting.
const vtype & getVector()
Return the vector on which is acting.
it take an expression and create the negatove of this expression
boost::mpl::bool_< false > is_sort
result for is sort
like std::rank but it also work for openfpm structures like Point where it return 1
Definition: Point.hpp:705
static const unsigned int prop
Property id of the point.
nn_type_result< typename exp1::NN_type, typename exp2::NN_type >::type NN_type
NN_type.
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:202
__host__ __device__ auto value(const vect_dist_key_dx &k) -> decltype(pos_or_propR< vector, prp >::value(v.v, k))
Evaluate the expression.
__device__ __host__ vector & getVector()
Return the vector on which is acting.
__device__ __host__ r_type value(const vect_dist_key_dx &key) const
Evaluate the expression.
openfpm::vector< aggregate< T > > vector
Internal vector.
void init() const
This function must be called before value.
vector_dist_expression(vector &v)
constructor for an external vector
__device__ __host__ r_type value(const vect_dist_key_dx &key) const
Evaluate the expression.
const vtype & getVector()
Return the vector on which is acting.
const vtype & getVector() const
Return the vector on which is acting.
vector_dist_expression_op(const exp1 &o1)
constructor from an expresssion
__device__ __host__ auto value(const unsigned int &k) const -> decltype(pos_or_propR< vector, prp >::value(v.v, k))
Evaluate the expression.
static void call(T &r_exp)
it call the function init for r_exp if T has the function init