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
73#define VECT_SUM_REDUCE 93
74
75
76/*! \brief has_init check if a type has defined a
77 * method called init
78 *
79 *
80 * return true if T::init() is a valid expression (function pointers)
81 * and produce a defined type
82 *
83 */
84
85template<typename ObjType, typename Sfinae = void>
86struct has_init: std::false_type {};
87
88template<typename ObjType>
89struct has_init<ObjType, typename Void<typename ObjType::has_init>::type> : std::true_type
90{};
91
92/*! \brief Call the init function if a type T has the function init
93 *
94 * \tparam type T
95 *
96 */
97template <typename T, bool has_init = has_init<T>::value >
98struct call_init_if_needed
99{
100 //! it call the function init for r_exp if T has the function init
101 static inline void call(T & r_exp)
102 {
103 r_exp.init();
104 }
105};
106
107/*! \brief Call the init function if a type T has the function init
108 *
109 * \tparam type T
110 *
111 */
112template <typename T>
113struct call_init_if_needed<T,false>
114{
115 //! it call the function init for r_exp if T has the function init
116 static inline void call(T & r_exp)
117 {
118 }
119};
120
121
122
123/*! \brief Unknown operation specialization
124 *
125 * \tparam exp1 expression1
126 * \tparam exp2 expression2
127 *
128 */
129template <typename exp1, typename exp2, unsigned int op>
130class vector_dist_expression_op
131{
132
133};
134
135template<typename v1_type, typename v2_type>
136struct vector_result
137{
138 typedef v1_type type;
139
140 template<typename exp1, typename exp2>
141 static const type & getVector(const exp1 & o1, const exp2 & o2)
142 {
143 return o1.getVector();
144 }
145
146 template<typename exp1>
147 static const type & getVector(const exp1 & o1)
148 {
149 return o1.getVector();
150 }
151};
152
153
154template<typename v2_type>
155struct vector_result<void,v2_type>
156{
157 typedef v2_type type;
158
159 template<typename exp1, typename exp2>
160 static const type & getVector(const exp1 & o1, const exp2 & o2)
161 {
162 return o2.getVector();
163 }
164
165 template<typename exp2>
166 static const type & getVector(exp2 & o2)
167 {
168 return o2.getVector();
169 }
170};
171
172template<typename NN1_type, typename NN2_type>
173struct nn_type_result
174{
175 typedef NN1_type type;
176
177 template<typename exp1, typename exp2>
178 static type * getNN(exp1 & o1, exp2 & o2)
179 {
180 return o1.getNN();
181 }
182
183 template<typename exp1>
184 static type * getNN(exp1 & o1)
185 {
186 return o1.getNN();
187 }
188};
189
190
191template<typename NN2_type>
192struct nn_type_result<void,NN2_type>
193{
194 typedef NN2_type type;
195
196 template<typename exp1, typename exp2>
197 static type * getNN(exp1 & o1, exp2 & o2)
198 {
199 return o2.getNN();
200 }
201
202 template<typename exp2>
203 static type * getNN(exp2 & o2)
204 {
205 return o2.getNN();
206 }
207};
208
209template<bool s1, bool s2>
210struct vector_is_sort_result
211{
212 typedef boost::mpl::bool_<s1 | s2> type;
213};
214
215/*! \brief Sum operation
216 *
217 * \tparam exp1 expression1
218 * \tparam exp2 expression2
219 *
220 */
221template <typename exp1, typename exp2>
222class vector_dist_expression_op<exp1,exp2,VECT_SUM>
223{
224 //! expression 1
225 const exp1 o1;
226
227 //! expression 2
228 const exp2 o2;
229
230public:
231
232 //! indicate if this vector is kernel type
233 typedef typename exp1::is_ker is_ker;
234
235 //! return the vector type on which this expression operate
236 typedef typename vector_result<typename exp1::vtype,typename exp2::vtype>::type vtype;
237
238 //! result for is sort
239 typedef typename vector_is_sort_result<exp1::is_sort::value,exp2::is_sort::value>::type is_sort;
240
241 //! NN_type
242 typedef typename nn_type_result<typename exp1::NN_type,typename exp2::NN_type>::type NN_type;
243
244 //! constructor of the expression to sum two expression
245 inline vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
246 :o1(o1),o2(o2)
247 {}
248
249 /*! \brief get the NN object
250 *
251 * \return the NN object
252 *
253 */
254 inline NN_type * getNN() const
255 {
256 return nn_type_result<typename exp1::NN_type,typename exp2::NN_type>::getNN(o1,o2);
257 }
258
259 /*! \brief Return the underlying vector
260 *
261 * \return the vector
262 *
263 */
264 const vtype & getVector() const
265 {
266 return vector_result<typename exp1::vtype,typename exp2::vtype>::getVector(o1,o2);
267 }
268
269 /*! \brief This function must be called before value
270 *
271 * it initialize the expression if needed
272 *
273 */
274 inline void init() const
275 {
276 o1.init();
277 o2.init();
278 }
279
280 /*! \brief Evaluate the expression
281 *
282 * \param key where to evaluate the expression
283 *
284 * \return return the result of the expression
285 *
286 */
287 template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) + o2.value(vect_dist_key_dx()))>::type >
288 __device__ __host__ inline r_type value(const vect_dist_key_dx & key) const
289 {
290 return o1.value(key) + o2.value(key);
291 }
292
293 /*! \brief Evaluate the expression
294 *
295 * \param key where to evaluate the expression
296 *
297 * \return return the result of the expression
298 *
299 */
300 template<typename r_type=typename std::remove_reference<decltype(o1.value(0) + o2.value(0))>::type >
301 __device__ __host__ inline r_type value(const unsigned int & key) const
302 {
303 return o1.value(key) + o2.value(key);
304 }
305
306};
307
308/*! \brief Subtraction operation
309 *
310 * \tparam exp1 expression1
311 * \tparam exp2 expression2
312 *
313 */
314template <typename exp1, typename exp2>
315class vector_dist_expression_op<exp1,exp2,VECT_SUB>
316{
317 //! expression 1
318 const exp1 o1;
319
320 //! expression 2
321 const exp2 o2;
322
323public:
324
325 typedef typename exp1::is_ker is_ker;
326
327 //! return the vector type on which this expression operate
328 typedef typename vector_result<typename exp1::vtype,typename exp2::vtype>::type vtype;
329
330 //! result for is sort
331 typedef typename vector_is_sort_result<exp1::is_sort::value,exp2::is_sort::value>::type is_sort;
332
333 //! NN_type
334 typedef typename nn_type_result<typename exp1::NN_type,typename exp2::NN_type>::type NN_type;
335
336 //! Costruct a subtraction expression out of two expressions
337 inline vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
338 :o1(o1),o2(o2)
339 {}
340
341 /*! \brief get the NN object
342 *
343 * \return the NN object
344 *
345 */
346 inline NN_type * getNN() const
347 {
348 return nn_type_result<typename exp1::NN_type,typename exp2::NN_type>::getNN(o1,o2);
349 }
350
351 /*! \brief Return the underlying vector
352 *
353 * \return the vector
354 *
355 */
356 const vtype & getVector()
357 {
358 return vector_result<typename exp1::vtype,typename exp2::vtype>::getVector(o1,o2);
359 }
360
361 /*! \brief This function must be called before value
362 *
363 * it initialize the expression if needed
364 *
365 */
366 inline void init() const
367 {
368 o1.init();
369 o2.init();
370 }
371
372 /*! \brief Evaluate the expression
373 *
374 * \param key where to evaluate the expression
375 *
376 * \return the result of the expression
377 *
378 */
379 template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) - o2.value(vect_dist_key_dx()))>::type >
380 inline r_type value(const vect_dist_key_dx & key) const
381 {
382 return o1.value(key) - o2.value(key);
383 }
384
385 /*! \brief Evaluate the expression
386 *
387 * \param key where to evaluate the expression
388 *
389 * \return the result of the expression
390 *
391 */
392 template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) - o2.value(vect_dist_key_dx()))>::type >
393 __device__ __host__ inline r_type value(const unsigned int & key) const
394 {
395 return o1.value(key) - o2.value(key);
396 }
397};
398
399/*! \brief Multiplication operation
400 *
401 * \tparam exp1 expression1
402 * \tparam exp2 expression2
403 *
404 */
405template <typename exp1, typename exp2>
406class vector_dist_expression_op<exp1,exp2,VECT_MUL>
407{
408 //! expression 1
409 const exp1 o1;
410
411 //! expression 2
412 const exp2 o2;
413
414public:
415
416 typedef typename exp1::is_ker is_ker;
417
418 //! return the vector type on which this expression operate
419 typedef typename vector_result<typename exp1::vtype,typename exp2::vtype>::type vtype;
420
421 //! result for is sort
422 typedef typename vector_is_sort_result<exp1::is_sort::value,exp2::is_sort::value>::type is_sort;
423
424 //! NN_type
425 typedef typename nn_type_result<typename exp1::NN_type,typename exp2::NN_type>::type NN_type;
426
427 //! constructor from two expressions
428 vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
429 :o1(o1),o2(o2)
430 {}
431
432 /*! \brief Return the underlying vector
433 *
434 * \return the vector
435 *
436 */
437 const vtype & getVector()
438 {
439 return vector_result<typename exp1::vtype,typename exp2::vtype>::getVector(o1,o2);
440 }
441
442 /*! \brief This function must be called before value
443 *
444 * it initialize the expression if needed
445 *
446 */
447 inline void init() const
448 {
449 o1.init();
450 o2.init();
451 }
452
453 /*! \brief Evaluate the expression
454 *
455 * \param key where to evaluate the expression
456 *
457 * \return the result of the expression
458 *
459 */
460 template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) * o2.value(vect_dist_key_dx()))>::type >
461 __device__ __host__ inline r_type value(const vect_dist_key_dx & key) const
462 {
463 return o1.value(key) * o2.value(key);
464 }
465
466 /*! \brief Evaluate the expression
467 *
468 * \param key where to evaluate the expression
469 *
470 * \return the result of the expression
471 *
472 */
473 template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) * o2.value(vect_dist_key_dx()))>::type >
474 __device__ __host__ inline r_type value(const unsigned int & key) const
475 {
476 return o1.value(key) * o2.value(key);
477 }
478};
479
480/*! \brief Division operation
481 *
482 * \tparam exp1 expression1
483 * \tparam exp2 expression2
484 *
485 */
486template <typename exp1, typename exp2>
487class vector_dist_expression_op<exp1,exp2,VECT_DIV>
488{
489 //! expression 1
490 const exp1 o1;
491
492 //! expression 2
493 const exp2 o2;
494
495public:
496
497 typedef typename exp1::is_ker is_ker;
498
499 //! return the vector type on which this expression operate
500 typedef typename vector_result<typename exp1::vtype,typename exp2::vtype>::type vtype;
501
502 //! result for is sort
503 typedef typename vector_is_sort_result<exp1::is_sort::value,exp2::is_sort::value>::type is_sort;
504
505 //! NN_type
506 typedef typename nn_type_result<typename exp1::NN_type,typename exp2::NN_type>::type NN_type;
507
508 //! constructor from two expressions
509 vector_dist_expression_op(const exp1 & o1, const exp2 & o2)
510 :o1(o1),o2(o2)
511 {}
512
513 /*! \brief get the NN object
514 *
515 * \return the NN object
516 *
517 */
518 inline NN_type * getNN() const
519 {
520 return nn_type_result<typename exp1::NN_type,typename exp2::NN_type>::getNN(o1,o2);
521 }
522
523 /*! \brief Return the underlying vector
524 *
525 * \return the vector
526 *
527 */
528 const vtype & getVector()
529 {
530 return vector_result<typename exp1::vtype,typename exp2::vtype>::getVector(o1,o2);
531 }
532
533 /*! \brief This function must be called before value
534 *
535 * it initialize the expression if needed
536 *
537 */
538 inline void init() const
539 {
540 o1.init();
541 o2.init();
542 }
543
544 /*! \brief Evaluate the expression
545 *
546 * \param key where to evaluate the expression
547 *
548 * \return the result of the expression
549 *
550 */
551 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
552 {
553 return o1.value(key) / o2.value(key);
554 }
555
556 /*! \brief Evaluate the expression
557 *
558 * \param key where to evaluate the expression
559 *
560 * \return the result of the expression
561 *
562 */
563 template<typename r_type=typename std::remove_reference<decltype(o1.value(vect_dist_key_dx()) / o2.value(vect_dist_key_dx()))>::type >
564 __device__ __host__ inline r_type value(const unsigned int & key) const
565 {
566 return o1.value(key) / o2.value(key);
567 }
568};
569
570/*! \brief it take an expression and create the negatove of this expression
571 *
572 *
573 */
574template <typename exp1>
575class vector_dist_expression_op<exp1,void,VECT_SUB_UNI>
576{
577 //! expression 1
578 const exp1 o1;
579
580public:
581
582 typedef typename exp1::is_ker is_ker;
583
584 //! return the vector type on which this expression operate
585 typedef typename vector_result<typename exp1::vtype,void>::type vtype;
586
587 //! result for is sort
588 typedef typename vector_is_sort_result<exp1::is_sort::value,false>::type is_sort;
589
590 //! NN_type
591 typedef typename nn_type_result<typename exp1::NN_type,void>::type NN_type;
592
593 //! constructor from an expresssion
594 vector_dist_expression_op(const exp1 & o1)
595 :o1(o1)
596 {}
597
598 /*! \brief get the NN object
599 *
600 * \return the NN object
601 *
602 */
603 inline NN_type * getNN() const
604 {
605 return nn_type_result<typename exp1::NN_type,void>::getNN(o1);
606 }
607
608 /*! \brief Return the underlying vector
609 *
610 * \return the vector
611 *
612 */
613 const vtype & getVector()
614 {
615 return vector_result<typename exp1::vtype,void>::getVector(o1);
616 }
617
618 //! initialize the expression tree
619 inline void init() const
620 {
621 o1.init();
622 }
623
624 //! return the result of the expression
625 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
626 {
627 return -(o1.value(key));
628 }
629
630 //! return the result of the expression
631 template<typename r_type=typename std::remove_reference<decltype(-(o1.value(vect_dist_key_dx(0))))>::type >
632 __device__ __host__ inline r_type value(const unsigned int & key) const
633 {
634 return -(o1.value(key));
635 }
636};
637
638/*! \brief Expression implementation computation selector
639 *
640 *
641 */
642template<int impl, bool vect_ker>
643struct vector_dist_expression_comp_sel
644{
645 typedef boost::mpl::int_<impl> type;
646};
647
648template<>
649struct vector_dist_expression_comp_sel<comp_host,true>
650{
651 typedef boost::mpl::int_<-1> type;
652};
653
654template<>
655struct vector_dist_expression_comp_sel<comp_dev,false>
656{
657 typedef boost::mpl::int_<-1> type;
658};
659
660template<typename vector, bool is_ker = has_vector_kernel<vector>::type::value>
661struct vector_expression_transform
662{
663 typedef vector& type;
664};
665
666template<typename vector>
667struct vector_expression_transform<vector,true>
668{
669 typedef vector type;
670};
671
672template<typename vector>
673struct v_mem_mutable
674{
675 vector v;
676
677 v_mem_mutable(vector & v)
678 :v(v)
679 {}
680};
681
682/*! \brief Main class that encapsulate a vector properties operand to be used for expressions construction
683 *
684 * \tparam prp property involved
685 * \tparam vector involved
686 *
687 */
688template<unsigned int prp, typename vector>
689class vector_dist_expression
690{
691 //! The vector
692 mutable v_mem_mutable<typename vector_expression_transform<vector>::type> v;
693
694 vector_dist_ker_list<vector> * vdl;
695
696public:
697
698 typedef typename has_vector_kernel<vector>::type is_ker;
699
700 //! The type of the internal vector
701 typedef vector vtype;
702
703 //! result for is sort
704 typedef boost::mpl::bool_<false> is_sort;
705
706 //! NN_type
707 typedef void NN_type;
708
709 //! Property id of the point
710 static const unsigned int prop = prp;
711
712
713 //! constructor for an external vector
714 vector_dist_expression(vector & v)
715 :v(v),vdl(NULL)
716 {}
717
718 //! constructor for an external vector
719 ~vector_dist_expression()
720 {
721 if (vdl != NULL)
722 {vdl->remove(v.v);}
723 }
724
725 /*! \brief get the NN object
726 *
727 * \return the NN object
728 *
729 */
730 inline void * getNN() const
731 {
732 return NULL;
733 }
734
735 /*! \brief Return the vector on which is acting
736 *
737 * It return the vector used in getVExpr, to get this object
738 *
739 * \return the vector
740 *
741 */
742 __device__ __host__ const vector & getVector() const
743 {
744 return v.v;
745 }
746
747 /*! \brief Return the vector on which is acting
748 *
749 * It return the vector used in getVExpr, to get this object
750 *
751 * \return the vector
752 *
753 */
754 __device__ __host__ vector & getVector()
755 {
756 return v.v;
757 }
758
759 /*! \brief set vector_dist_ker_list
760 *
761 * \param vdkl vector_dist_ker_list
762 *
763 */
764 void set_vector_dist_ker_list(vector_dist_ker_list<vector> & vdkl, bool is_sort)
765 {
766 vdkl.add(v.v,is_sort);
767 vdl = &vdkl;
768 }
769
770 /*! \brief This function must be called before value
771 *
772 * it initialize the expression if needed
773 *
774 */
775 inline void init() const
776 {}
777
778 /*! \brief Evaluate the expression
779 *
780 * \param k where to evaluate the expression
781 *
782 * \return the result of the expression
783 *
784 */
785 __host__ __device__ inline auto value(const vect_dist_key_dx & k) const -> decltype(pos_or_propR<vector,prp>::value(v.v,k))
786 {
787 return pos_or_propR<vector,prp>::value(v.v,k);
788 }
789
790 /*! \brief Evaluate the expression
791 *
792 * \param k where to evaluate the expression
793 *
794 * \return the result of the expression
795 *
796 */
797 __device__ inline auto value(const unsigned int & k) const -> decltype(pos_or_propR<vector,prp>::value(v.v,k))
798 {
799 return pos_or_propR<vector,prp>::value(v.v,k);
800 }
801
802 /*! \brief Fill the vector property with the evaluated expression
803 *
804 * \param v_exp expression to evaluate
805 *
806 * \return itself
807 *
808 */
809 template<unsigned int prp2> vector & operator=(const vector_dist_expression<prp2,vector> & v_exp)
810 {
811
812 vector_dist_op_compute_op<prp,false,vector_dist_expression_comp_sel<comp_host + (has_vector_kernel<vector>::type::value == true),
813 has_vector_kernel<vector>::type::value>::type::value>
814 ::compute_expr(v.v,v_exp);
815
816 return v.v;
817 }
818
819 /*! \brief Fill the vector property with the evaluated expression
820 *
821 * \param v_exp expression to evaluate
822 *
823 * \return itself
824 *
825 */
826 template<typename exp1, typename exp2, unsigned int op>
827 vector & operator=(const vector_dist_expression_op<exp1,exp2,op> & v_exp)
828 {
829 vector_dist_op_compute_op<prp,
830 vector_dist_expression_op<exp1,exp2,op>::is_sort::value,
831 vector_dist_expression_comp_sel<comp_host + (has_vector_kernel<vector>::type::value == true),
832 has_vector_kernel<vector>::type::value>::type::value>
833 ::compute_expr(v.v,v_exp);
834
835 return v.v;
836 }
837
838 /*! \brief Fill the vector property with the double
839 *
840 * \param d value to fill
841 *
842 * \return the internal vector
843 *
844 */
845 vector & operator=(double d)
846 {
847
848 vector_dist_op_compute_op<prp,
849 false,
850 vector_dist_expression_comp_sel<comp_host + (has_vector_kernel<vector>::type::value == true),
851 has_vector_kernel<vector>::type::value>::type::value>
852 ::compute_const(v.v,d);
853
854 return v.v;
855 }
856};
857
858template<typename vector, unsigned int impl>
859struct switcher_get_v
860{
861 typedef vector type;
862
863 static vector & get(vector & v) {return v;};
864
865 template<typename exp_type, typename vector_klist>
866 static void register_vector(exp_type & exp_v, vector_klist & v,bool is_sort)
867 {
868 }
869};
870
871template<typename vector>
872struct switcher_get_v<vector,comp_dev>
873{
874 typedef decltype(std::declval<vector>().toKernel()) type;
875
876 static type get(vector & v) {return v.toKernel();};
877
878 template<typename exp_type, typename vector_klist>
879 static void register_vector(exp_type & exp_v, vector_klist & v,bool is_sort)
880 {
881 exp_v.set_vector_dist_ker_list(v.private_get_vector_dist_ker_list(),is_sort);
882 }
883};
884
885/*! \Create an expression from a vector property
886 *
887 * \tpatam prp property
888 * \param v
889 *
890 */
891template <unsigned int prp,unsigned int impl = comp_host, typename vector>
892inline vector_dist_expression<prp,typename switcher_get_v<vector,impl>::type > getV(vector & v)
893{
894 decltype(switcher_get_v<vector,impl>::get(v)) vk = switcher_get_v<vector,impl>::get(v);
895 vector_dist_expression<prp,typename switcher_get_v<vector,impl>::type > exp_v(vk);
896
897 switcher_get_v<vector,impl>::register_vector(exp_v,v,false);
898
899 return exp_v;
900}
901
902
903/*! \Create an expression from a vector property
904 *
905 * \tpatam prp property
906 * \param v
907 *
908 */
909template <unsigned int prp,typename vector>
910inline vector_dist_expression<prp, typename switcher_get_v<vector,comp_dev>::type > getV_sort(vector & v)
911{
912 auto vk = v.toKernel_sorted();
913 vector_dist_expression<prp,typename switcher_get_v<vector, comp_dev>::type > exp_v(vk);
914
915 exp_v.set_vector_dist_ker_list(v.private_get_vector_dist_ker_list(),true);
916
917 return exp_v;
918}
919
920/*! \brief Main class that encapsulate a double constant
921 *
922 * \param prp no meaning
923 *
924 */
925template<unsigned int prp>
926class vector_dist_expression<prp,double>
927{
928 //! constant parameter
929 double d;
930
931public:
932
933 typedef std::false_type is_ker;
934
935 typedef void vtype;
936
937 //! result for is sort
938 typedef boost::mpl::bool_<false> is_sort;
939
940 typedef void NN_type;
941
942 //! constructor from a constant expression
943 inline vector_dist_expression(const double & d)
944 :d(d)
945 {}
946
947 /*! \brief This function must be called before value
948 *
949 * it initialize the expression if needed
950 *
951 */
952 inline void init() const
953 {}
954
955 /*! \brief Evaluate the expression
956 *
957 * \param k ignored position in the vector
958 *
959 * It just return the value set in the constructor
960 *
961 * \return the constant value
962 *
963 */
964 __device__ __host__ inline double value(const vect_dist_key_dx & k) const
965 {
966 return d;
967 }
968
969 /*! \brief Evaluate the expression
970 *
971 * \param k ignored position in the vector
972 *
973 * It just return the value set in the constructor
974 *
975 * \return the constant value
976 *
977 */
978 __host__ __device__ inline double value(const unsigned int & k) const
979 {
980 return d;
981 }
982};
983
984/*! \brief Main class that encapsulate a float constant
985 *
986 * \param prp no meaning
987 *
988 */
989template<unsigned int prp>
990class vector_dist_expression<prp,float>
991{
992 //! constant value
993 float d;
994
995public:
996
997 typedef std::false_type is_ker;
998
999 //! type of object the structure return then evaluated
1000 typedef void vtype;
1001
1002 //! result for is sort
1003 typedef boost::mpl::bool_<false> is_sort;
1004
1005 typedef void NN_type;
1006
1007 //! constrictor from constant value
1008 inline vector_dist_expression(const float & d)
1009 :d(d)
1010 {}
1011
1012 /*! \brief This function must be called before value
1013 *
1014 * it initialize the expression if needed
1015 *
1016 */
1017 inline void init() const
1018 {}
1019
1020 /*! \brief Evaluate the expression
1021 *
1022 * \param k ignored position in the vector
1023 *
1024 * It just return the value set in the constructor
1025 *
1026 * \return the constant value set in the constructor
1027 *
1028 */
1029 inline float value(const vect_dist_key_dx & k) const
1030 {
1031 return d;
1032 }
1033
1034 /*! \brief Evaluate the expression
1035 *
1036 * \param k ignored position in the vector
1037 *
1038 * It just return the value set in the constructor
1039 *
1040 * \return the constant value set in the constructor
1041 *
1042 */
1043 __device__ __host__ inline float value(const unsigned int & k) const
1044 {
1045 return d;
1046 }
1047};
1048
1049/* \brief sum two distributed vector expression
1050 *
1051 * \param va vector expression one
1052 * \param vb vector expression two
1053 *
1054 * \return an object that encapsulate the expression
1055 *
1056 */
1057template<unsigned int p1, unsigned int p2, typename v1, typename v2>
1058inline vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression<p2,v2>,VECT_SUM>
1059operator+(const vector_dist_expression<p1,v1> & va, const vector_dist_expression<p2,v2> & vb)
1060{
1061 vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression<p2,v2>,VECT_SUM> exp_sum(va,vb);
1062
1063 return exp_sum;
1064}
1065
1066/* \brief sum two distributed vector expression
1067 *
1068 * \param va vector expression one
1069 * \param vb vector expression two
1070 *
1071 * \return an object that encapsulate the expression
1072 *
1073 */
1074template<typename exp1 , typename exp2, unsigned int op1, unsigned int prp1, typename v1>
1075inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<prp1,v1>,VECT_SUM>
1076operator+(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression<prp1,v1> & vb)
1077{
1078 vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<prp1,v1>,VECT_SUM> exp_sum(va,vb);
1079
1080 return exp_sum;
1081}
1082
1083/* \brief sum two distributed vector expression
1084 *
1085 * \param va vector expression one
1086 * \param vb vector expression two
1087 *
1088 * \return an object that encapsulate the expression
1089 *
1090 */
1091template<typename exp1 , typename exp2, unsigned int op1, unsigned int prp1, typename v1>
1092inline vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression_op<exp1,exp2,op1>,VECT_SUM>
1093operator+(const vector_dist_expression<prp1,v1> & va, const vector_dist_expression_op<exp1,exp2,op1> & vb)
1094{
1095 vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression_op<exp1,exp2,op1>,VECT_SUM> exp_sum(va,vb);
1096
1097 return exp_sum;
1098}
1099
1100/* \brief sum two distributed vector expression
1101 *
1102 * \param va vector expression one
1103 * \param vb vector expression two
1104 *
1105 * \return an object that encapsulate the expression
1106 *
1107 */
1108template<typename exp1 , typename exp2, unsigned int op1, typename exp3 , typename exp4, unsigned int op2>
1109inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_SUM>
1110operator+(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression_op<exp3,exp4,op2> & vb)
1111{
1112 vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_SUM> exp_sum(va,vb);
1113
1114 return exp_sum;
1115}
1116
1117/* \brief sum two distributed vector expression
1118 *
1119 * \param va vector expression one
1120 * \param vb vector expression two
1121 *
1122 * \return an object that encapsulate the expression
1123 *
1124 */
1125template<unsigned int prp1 , typename v1>
1126inline vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<0,double>,VECT_SUM>
1127operator+(const vector_dist_expression<prp1,v1> & va, double d)
1128{
1129 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));
1130
1131 return exp_sum;
1132}
1133
1134/* \brief sum two distributed vector expression
1135 *
1136 * \param va vector expression one
1137 * \param vb vector expression two
1138 *
1139 * \return an object that encapsulate the expression
1140 *
1141 */
1142template<unsigned int prp1 , typename v1>
1143inline vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<prp1,v1>,VECT_SUM>
1144operator+(double d, const vector_dist_expression<prp1,v1> & vb)
1145{
1146 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);
1147
1148 return exp_sum;
1149}
1150
1151/* \brief sum two distributed vector expression
1152 *
1153 * \param va vector expression one
1154 * \param vb vector expression two
1155 *
1156 * \return an object that encapsulate the expression
1157 *
1158 */
1159template<typename exp1 , typename exp2, unsigned int op1>
1160inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_SUM>
1161operator+(const vector_dist_expression_op<exp1,exp2,op1> & va, double d)
1162{
1163 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));
1164
1165 return exp_sum;
1166}
1167
1168
1169/* \brief subtract two distributed vector expression
1170 *
1171 * \param va vector expression one
1172 * \param vb vector expression two
1173 *
1174 * \return an object that encapsulate the expression
1175 *
1176 */
1177template<unsigned int p1, unsigned int p2, typename v1, typename v2>
1178inline vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression<p2,v2>,VECT_SUB>
1179operator-(const vector_dist_expression<p1,v1> & va, const vector_dist_expression<p2,v2> & vb)
1180{
1181 vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression<p2,v2>,VECT_SUB> exp_sum(va,vb);
1182
1183 return exp_sum;
1184}
1185
1186
1187/* \brief subtract two distributed vector expression
1188 *
1189 * \param va vector expression one
1190 * \param vb vector expression two
1191 *
1192 * \return an object that encapsulate the expression
1193 *
1194 */
1195template<typename exp1, typename exp2, unsigned int op1, unsigned int p2, typename v2>
1196inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<p2,v2>,VECT_SUB>
1197operator-(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression<p2,v2> & vb)
1198{
1199 vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<p2,v2>,VECT_SUB> exp_sum(va,vb);
1200
1201 return exp_sum;
1202}
1203
1204/* \brief minus of a distributed vector expression operator
1205 *
1206 * \param va vector expression one
1207 *
1208 * \return an object that encapsulate the expression
1209 *
1210 */
1211template<typename exp1, typename exp2_, unsigned int op1>
1212inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2_,op1>,void,VECT_SUB_UNI>
1213operator-(const vector_dist_expression_op<exp1,exp2_,op1> & va)
1214{
1215 vector_dist_expression_op<vector_dist_expression_op<exp1,exp2_,op1>,void,VECT_SUB_UNI> exp_sum(va);
1216
1217 return exp_sum;
1218}
1219
1220/* \brief minus of a distributed vector expression
1221 *
1222 * \param va vector expression one
1223 *
1224 * \return an object that encapsulate the expression
1225 *
1226 */
1227template<unsigned int p1, typename v1>
1228inline vector_dist_expression_op<vector_dist_expression<p1,v1>,void,VECT_SUB_UNI>
1229operator-(const vector_dist_expression<p1,v1> & va)
1230{
1231 vector_dist_expression_op<vector_dist_expression<p1,v1>,void,VECT_SUB_UNI> exp_sum(va);
1232
1233 return exp_sum;
1234}
1235
1236
1237/* \brief subtract two distributed vector expression
1238 *
1239 * \param va vector expression one
1240 * \param vb vector expression two
1241 *
1242 * \return an object that encapsulate the expression
1243 *
1244 */
1245template<typename exp1, typename exp2, unsigned int op1, unsigned int p2, typename v2>
1246inline vector_dist_expression_op<vector_dist_expression<p2,v2>,vector_dist_expression_op<exp1,exp2,op1>,VECT_SUB>
1247operator-(const vector_dist_expression<p2,v2> & va, const vector_dist_expression_op<exp1,exp2,op1> & vb)
1248{
1249 vector_dist_expression_op<vector_dist_expression<p2,v2>, vector_dist_expression_op<exp1,exp2,op1>,VECT_SUB> exp_sum(va,vb);
1250
1251 return exp_sum;
1252}
1253
1254/* \brief subtract two distributed vector expression
1255 *
1256 * \param va vector expression one
1257 * \param vb vector expression two
1258 *
1259 * \return an object that encapsulate the expression
1260 *
1261 */
1262template<typename exp1, typename exp2, unsigned int op1, typename exp3, typename exp4, unsigned int op2>
1263inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_SUB>
1264operator-(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression_op<exp3,exp4,op2> & vb)
1265{
1266 vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_SUB> exp_sum(va,vb);
1267
1268 return exp_sum;
1269}
1270
1271/* \brief subtract two distributed vector expression
1272 *
1273 * \param va vector expression one
1274 * \param vb vector expression two
1275 *
1276 * \return an object that encapsulate the expression
1277 *
1278 */
1279template<unsigned int prp1, typename v1>
1280inline vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<0,double>,VECT_SUB>
1281operator-(const vector_dist_expression<prp1,v1> & va, double d)
1282{
1283 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));
1284
1285 return exp_sum;
1286}
1287
1288/* \brief subtract two distributed vector expression
1289 *
1290 * \param va vector expression one
1291 * \param vb vector expression two
1292 *
1293 * \return an object that encapsulate the expression
1294 *
1295 */
1296template<unsigned int prp1, typename v1>
1297inline vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<prp1,v1>,VECT_SUB>
1298operator-(double d, const vector_dist_expression<prp1,v1> & vb)
1299{
1300 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);
1301
1302 return exp_sum;
1303}
1304
1305/* \brief Multiply two distributed vector expression
1306 *
1307 * \param va vector expression one
1308 * \param vb vector expression two
1309 *
1310 * \return an object that encapsulate the expression
1311 *
1312 */
1313template<unsigned int p2, typename v2>
1314inline vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<p2,v2>,VECT_MUL>
1315operator*(double d, const vector_dist_expression<p2,v2> & vb)
1316{
1317 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);
1318
1319 return exp_sum;
1320}
1321
1322/* \brief Multiply two distributed vector expression
1323 *
1324 * \param va vector expression one
1325 * \param vb vector expression two
1326 *
1327 * \return an object that encapsulate the expression
1328 *
1329 */
1330template<unsigned int p2, typename v2>
1331inline vector_dist_expression_op<vector_dist_expression<p2,v2>,vector_dist_expression<0,double>,VECT_MUL>
1332operator*(const vector_dist_expression<p2,v2> & va, double d)
1333{
1334 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));
1335
1336 return exp_sum;
1337}
1338
1339/* \brief Multiply two distributed vector expression
1340 *
1341 * \param va vector expression one
1342 * \param vb vector expression two
1343 *
1344 * \return an object that encapsulate the expression
1345 *
1346 */
1347template<unsigned int p1, typename v1,unsigned int p2, typename v2>
1348inline vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression<p2,v2>,VECT_MUL>
1349operator*(const vector_dist_expression<p1,v1> & va, const vector_dist_expression<p2,v2> & vb)
1350{
1351 vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression<p2,v2>,VECT_MUL> exp_sum(va,vb);
1352
1353 return exp_sum;
1354}
1355
1356/* \brief Multiply two distributed vector expression
1357 *
1358 * \param va vector expression one
1359 * \param vb vector expression two
1360 *
1361 * \return an object that encapsulate the expression
1362 *
1363 */
1364template<unsigned int p1, typename v1, typename exp1, typename exp2, unsigned int op1>
1365inline vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression_op<exp1,exp2,op1>,VECT_MUL>
1366operator*(const vector_dist_expression<p1,v1> & va, const vector_dist_expression_op<exp1,exp2,op1> & vb)
1367{
1368 vector_dist_expression_op<vector_dist_expression<p1,v1>,vector_dist_expression_op<exp1,exp2,op1>,VECT_MUL> exp_sum(va,vb);
1369
1370 return exp_sum;
1371}
1372
1373/* \brief Multiply two distributed vector expression
1374 *
1375 * \param va vector expression one
1376 * \param vb vector expression two
1377 *
1378 * \return an object that encapsulate the expression
1379 *
1380 */
1381template<unsigned int p1, typename v1, typename exp1, typename exp2, unsigned int op1>
1382inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<p1,v1>,VECT_MUL>
1383operator*(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression<p1,v1> & vb)
1384{
1385 vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<p1,v1>,VECT_MUL> exp_sum(va,vb);
1386
1387 return exp_sum;
1388}
1389
1390/* \brief Multiply two distributed vector expression
1391 *
1392 * \param va vector expression one
1393 * \param vb vector expression two
1394 *
1395 * \return an object that encapsulate the expression
1396 *
1397 */
1398template<typename exp1, typename exp2, unsigned int op1, typename exp3 , typename exp4, unsigned int op2>
1399inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_MUL>
1400operator*(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression_op<exp3,exp4,op2> & vb)
1401{
1402 vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_MUL> exp_sum(va,vb);
1403
1404 return exp_sum;
1405}
1406
1407/* \brief Multiply a distributed vector expression by a number
1408 *
1409 * \param va vector expression
1410 * \param d number
1411 *
1412 * \return an object that encapsulate the expression
1413 *
1414 */
1415template<typename exp1 , typename exp2, unsigned int op1>
1416inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_MUL>
1417operator*(const vector_dist_expression_op<exp1,exp2,op1> & va, double d)
1418{
1419 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));
1420
1421 return exp_sum;
1422}
1423
1424/* \brief Multiply a distributed vector expression by a number
1425 *
1426 * \param d number
1427 * \param vb vector expression
1428 *
1429 * \return an object that encapsulate the expression
1430 *
1431 */
1432template<typename exp1 , typename exp2, unsigned int op1>
1433inline vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression_op<exp1,exp2,op1>,VECT_MUL>
1434operator*(double d, const vector_dist_expression_op<exp1,exp2,op1> & vb)
1435{
1436 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);
1437
1438 return exp_sum;
1439}
1440
1441/* \brief Divide two distributed vector expression
1442 *
1443 * \param va vector expression one
1444 * \param vb vector expression two
1445 *
1446 * \return an object that encapsulate the expression
1447 *
1448 */
1449template<typename exp1, typename exp2, unsigned int op1>
1450inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_DIV>
1451operator/(const vector_dist_expression_op<exp1,exp2,op1> & va, double d)
1452{
1453 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));
1454
1455 return exp_sum;
1456}
1457
1458
1459/* \brief Divide two distributed vector expression
1460 *
1461 * \param va vector expression one
1462 * \param vb vector expression two
1463 *
1464 * \return an object that encapsulate the expression
1465 *
1466 */
1467template<typename exp1, typename exp2, unsigned int op1>
1468inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<0,double>,VECT_DIV>
1469operator/(double d, const vector_dist_expression_op<exp1,exp2,op1> & va)
1470{
1471 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);
1472
1473 return exp_sum;
1474}
1475
1476/* \brief Divide two distributed vector expression
1477 *
1478 * \param va vector expression one
1479 * \param vb vector expression two
1480 *
1481 * \return an object that encapsulate the expression
1482 *
1483 */
1484template<unsigned int prp1, typename v1>
1485inline vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<0,double>,VECT_DIV>
1486operator/(const vector_dist_expression<prp1,v1> & va, double d)
1487{
1488 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));
1489
1490 return exp_sum;
1491}
1492
1493/* \brief Divide two distributed vector expression
1494 *
1495 * \param va vector expression one
1496 * \param vb vector expression two
1497 *
1498 * \return an object that encapsulate the expression
1499 *
1500 */
1501template<unsigned int prp1, typename v1>
1502inline vector_dist_expression_op<vector_dist_expression<0,double>,vector_dist_expression<prp1,v1>,VECT_DIV>
1503operator/(double d, const vector_dist_expression<prp1,v1> & va)
1504{
1505 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);
1506
1507 return exp_sum;
1508}
1509
1510/* \brief Divide two distributed vector expression
1511 *
1512 * \param va vector expression one
1513 * \param vb vector expression two
1514 *
1515 * \return an object that encapsulate the expression
1516 *
1517 */
1518template<unsigned int prp1, typename v1, unsigned int prp2, typename v2>
1519inline vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<prp2,v2>,VECT_DIV>
1520operator/(const vector_dist_expression<prp1,v1> & va, const vector_dist_expression<prp2,v2> & vb)
1521{
1522 vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression<prp2,v2>,VECT_DIV> exp_sum(va,vb);
1523
1524 return exp_sum;
1525}
1526
1527/* \brief Divide two distributed vector expression
1528 *
1529 * \param va vector expression one
1530 * \param vb vector expression two
1531 *
1532 * \return an object that encapsulate the expression
1533 *
1534 */
1535template<unsigned int prp1, typename v1, typename exp1,typename exp2, unsigned int op1>
1536inline vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression_op<exp1,exp2,op1>,VECT_DIV>
1537operator/(const vector_dist_expression<prp1,v1> & va, const vector_dist_expression_op<exp1,exp2,op1> & vb)
1538{
1539 vector_dist_expression_op<vector_dist_expression<prp1,v1>,vector_dist_expression_op<exp1,exp2,op1>,VECT_DIV> exp_sum(va,vb);
1540
1541 return exp_sum;
1542}
1543
1544/* \brief Divide two distributed vector expression
1545 *
1546 * \param va vector expression one
1547 * \param vb vector expression two
1548 *
1549 * \return an object that encapsulate the expression
1550 *
1551 */
1552template<unsigned int prp1, typename v1, typename exp1,typename exp2, unsigned int op1>
1553inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<prp1,v1>,VECT_DIV>
1554operator/(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression<prp1,v1> & vb)
1555{
1556 vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression<prp1,v1>,VECT_DIV> exp_sum(va,vb);
1557
1558 return exp_sum;
1559}
1560
1561/* \brief Divide two distributed vector expression
1562 *
1563 * \param va vector expression one
1564 * \param vb vector expression two
1565 *
1566 * \return an object that encapsulate the expression
1567 *
1568 */
1569template<typename exp1,typename exp2, unsigned int op1, typename exp3, typename exp4, unsigned int op2>
1570inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_DIV>
1571operator/(const vector_dist_expression_op<exp1,exp2,op1> & va, const vector_dist_expression_op<exp3,exp4,op2> & vb)
1572{
1573 vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,vector_dist_expression_op<exp3,exp4,op2>,VECT_DIV> exp_sum(va,vb);
1574
1575 return exp_sum;
1576}
1577
1578#include "vector_dist_operators_apply_kernel.hpp"
1579#include "vector_dist_operators_functions.hpp"
1580#include "vector_dist_operators_extensions.hpp"
1581#include "Operators/Vector/vector_dist_operator_assign.hpp"
1582
1583
1584#endif /* OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_HPP_ */
1585