OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
Point_operators.hpp
1/*
2 * Point_operators.hpp
3 *
4 * Created on: Jun 14, 2016
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_DATA_SRC_SPACE_SHAPE_POINT_OPERATORS_HPP_
9#define OPENFPM_DATA_SRC_SPACE_SHAPE_POINT_OPERATORS_HPP_
10
11#include "util/multi_array_openfpm/array_openfpm.hpp"
12
13template<unsigned int dim ,typename T> class Point;
14
15#define POINT_SUM 1
16#define POINT_SUB 2
17#define POINT_MUL 3
18#define POINT_DIV 4
19#define POINT_MUL_POINT 5
20#define POINT_NORM 6
21#define POINT_NORM2 7
22
23// Functions
24
25#define POINT_ABS 8
26#define POINT_EXP 9
27#define POINT_EXP2 10
28#define POINT_EXPM1 11
29#define POINT_LOG 12
30#define POINT_LOG10 13
31#define POINT_LOG2 14
32#define POINT_LOG1P 15
33#define POINT_SQRT 17
34#define POINT_CBRT 18
35#define POINT_SIN 19
36#define POINT_COS 20
37#define POINT_TAN 21
38#define POINT_ASIN 22
39#define POINT_ACOS 23
40#define POINT_ATAN 24
41#define POINT_SINH 25
42#define POINT_COSH 26
43#define POINT_TANH 27
44#define POINT_ASINH 28
45#define POINT_ACOSH 29
46#define POINT_ATANH 30
47#define POINT_ERF 31
48#define POINT_ERFC 32
49#define POINT_TGAMMA 33
50#define POINT_LGAMMA 34
51#define POINT_CEIL 35
52#define POINT_FLOOR 36
53#define POINT_TRUNC 37
54#define POINT_ROUND 38
55#define POINT_NEARBYINT 39
56#define POINT_RINT 40
57#define POINT_SUB_UNI 41
58#define POINT_NORM_INF 42
59
60
62
63template<bool cond, typename exp1, typename exp2>
65{
66 typedef typename exp2::coord_type coord_type;
67};
68
69template<typename exp1, typename exp2>
70struct first_or_second_pt<true,exp1,exp2>
71{
72 typedef typename exp1::coord_type coord_type;
73};
74
75template<typename T, typename Sfinae = void>
76struct has_coordtype: std::false_type {};
77
87template<typename T>
88struct has_coordtype<T, typename Void<typename T::coord_type>::type> : std::true_type
89{};
90
91template<typename source1, typename source2>
93{
94 typedef source1 type;
95};
96
97template<typename source2>
98struct best_conv_impl<int,source2>
99{
100 typedef source2 type;
101};
102
103template<typename source2>
104struct best_conv_impl<long int,source2>
105{
106 typedef source2 type;
107};
108
109template<typename source2>
110struct best_conv_impl<unsigned int,source2>
111{
112 typedef source2 type;
113};
114
115template<typename source2>
116struct best_conv_impl<unsigned long int,source2>
117{
118 typedef source2 type;
119};
120
121template<typename source1>
122struct best_conv_impl<source1,int>
123{
124 typedef source1 type;
125};
126
127template<typename source1>
128struct best_conv_impl<source1,long int>
129{
130 typedef source1 type;
131};
132
133template<typename source1>
134struct best_conv_impl<source1,unsigned int>
135{
136 typedef source1 type;
137};
138
139template<typename source1>
140struct best_conv_impl<source1,unsigned long int>
141{
142 typedef source1 type;
143};
144
145template<typename source1, typename source2>
147{
148 typedef typename best_conv_impl<typename std::remove_const<source1>::type,typename std::remove_const<source2>::type>::type type;
149};
150
152
153constexpr unsigned int max_expr(unsigned int dim1, unsigned int dim2)
154{
155 return (dim1 > dim2)?dim1:dim2;
156}
157
167template <unsigned int op1_dim, unsigned int op2_dim, unsigned int op>
169{
171 enum
172 {
173 value = max_expr(op1_dim,op2_dim),
174 };
175};
176
178template <>
179struct r_type_dim<1,1,POINT_SUM>
180{
182 enum
183 {
184 value = 1,
185 };
186};
187
189template <>
190struct r_type_dim<1,1,POINT_SUB>
191{
193 enum
194 {
195 value = 1,
196 };
197};
198
200template <unsigned int op1_dim, unsigned int op2_dim>
201struct r_type_dim<op1_dim,op2_dim,POINT_MUL_POINT>
202{
204 enum
205 {
206 value = 1,
207 };
208};
209
211template <>
212struct r_type_dim<1,1,POINT_MUL>
213{
215 enum
216 {
217 value = 1,
218 };
219};
220
222template <>
223struct r_type_dim<1,1,POINT_DIV>
224{
226 enum
227 {
228 value = 1,
229 };
230};
231
238template <unsigned int r, typename orig>
240{
242 typedef orig type;
243};
244
250template <typename orig>
251struct r_type_p<1,orig>
252{
254 typedef typename orig::coord_type type;
255};
256
257
262template<typename T>
264{
266 T d;
267
268public:
269
271 typedef int has_init;
272
274 typedef int is_expression;
275
277 static const unsigned int nvals = 1;
278
279 typedef T coord_type;
280
286 __device__ __host__ inline point_expression(T & d)
287 :d(d)
288 {}
289
295 __device__ __host__ inline void init() const
296 {
297 }
298
306 __device__ __host__ inline const T & value(const int k) const
307 {
308 return d;
309 }
310
318 __device__ __host__ inline T & value(const int k)
319 {
320 return d;
321 }
322};
323
324
325
334template <typename orig, typename exp1, typename exp2, unsigned int op>
336{
337
338};
339
347template <typename orig, typename exp1, typename exp2>
348class point_expression_op<orig,exp1,exp2,POINT_SUM>
349{
351 const exp1 o1;
353 const exp2 o2;
354
355public:
356
358 typedef typename first_or_second_pt<has_coordtype<exp1>::value,exp1,exp2>::coord_type coord_type;
359
361 typedef orig orig_type;
362
364 typedef int is_expression;
365
367 typedef int has_init;
368
371
374
381 __device__ __host__ inline point_expression_op(const exp1 & o1, const exp2 & o2)
382 :o1(o1),o2(o2)
383 {}
384
390 __device__ __host__ inline void init() const
391 {
392 o1.init();
393 o2.init();
394 }
395
403 template<typename r_type=typename best_conv<typename std::remove_reference<decltype(o1.value(0))>::type,
404 typename std::remove_reference<decltype(o2.value(0))>::type>::type >
405 __device__ __host__ inline r_type value(size_t k) const
406 {
407 return o1.value(k) + o2.value(k);
408 }
409
414 template<typename T, typename test=typename boost::disable_if_c< std::is_same<T,orig>::value || exp1::nvals != 1 || exp2::nvals != 1 >::type >
415 __device__ __host__ inline operator T() const
416 {
417 init();
418 return o1.value(0) + o2.value(0);
419 }
420
428 template<typename r_type=typename best_conv<typename std::remove_reference<decltype(o1.value(0))>::type,
429 typename std::remove_reference<decltype(o2.value(0))>::type>::type >
430 __device__ __host__ inline r_type operator[](size_t i)
431 {
432 return o1.value(i) + o2.value(i);
433 }
434};
435
442template <typename orig,typename exp1, typename exp2>
444{
446 const exp1 o1;
448 const exp2 o2;
449
450public:
451
453 typedef typename first_or_second_pt<has_coordtype<exp1>::value,exp1,exp2>::coord_type coord_type;
454
456 typedef orig orig_type;
457
459 typedef int has_init;
460
462 typedef int is_expression;
463
465 typedef orig return_type;
466
469
476 __device__ __host__ inline point_expression_op(const exp1 & o1, const exp2 & o2)
477 :o1(o1),o2(o2)
478 {}
479
485 __device__ __host__ inline void init() const
486 {
487 o1.init();
488 o2.init();
489 }
490
498 template<typename r_type=typename best_conv<typename std::remove_reference<decltype(o1.value(0))>::type,
499 typename std::remove_reference<decltype(o2.value(0))>::type>::type >
500 __device__ __host__ inline r_type value(size_t k) const
501 {
502 return o1.value(k) - o2.value(k);
503 }
504
509 template<typename T, typename test=typename boost::disable_if_c< std::is_same<T,orig>::value || exp1::nvals != 1 || exp2::nvals != 1 >::type >
510 __device__ __host__ operator T() const
511 {
512 init();
513 return o1.value(0) - o2.value(0);
514 }
515
516
517};
518
526template <typename orig, typename exp1, typename exp2>
528{
530 const exp1 o1;
531
533 mutable typename orig::coord_type scal;
534
535public:
536
538 typedef orig orig_type;
539
541 typedef int is_expression;
542
544 typedef int has_init;
545
547 typedef typename orig::coord_type return_type;
548
550 static const unsigned int nvals = exp1::nvals;
551
553 typedef typename first_or_second_pt<has_coordtype<exp1>::value,exp1,exp2>::coord_type coord_type;
554
560 __device__ __host__ inline point_expression_op(const exp1 & o1)
561 :o1(o1),scal(0.0)
562 {}
563
565 __device__ __host__ inline void init() const
566 {
567 o1.init();
568 }
569
577 template<typename r_type=typename std::remove_reference<decltype(o1.value(0))>::type >
578 __device__ __host__ inline r_type value(size_t k) const
579 {
580 return -(o1.value(k));
581 }
582
584 template <typename T, typename check = typename std::enable_if<!std::is_same<T,orig>::value >::type >
585 __device__ __host__ operator T() const
586 {
587 init();
588 return -(o1.value(0));
589 }
590};
591
592
601template <typename orig, typename exp1, typename exp2>
602class point_expression_op<orig,exp1,exp2,POINT_MUL_POINT>
603{
605 const exp1 o1;
607 const exp2 o2;
608
610 mutable typename std::remove_const<typename orig::coord_type>::type scal;
611
612public:
613
615 typedef typename first_or_second_pt<has_coordtype<exp1>::value,exp1,exp2>::coord_type coord_type;
616
618 typedef orig orig_type;
619
621 typedef int has_init;
622
624 typedef int is_expression;
625
627 typedef typename orig::coord_type return_type;
628
630 static const unsigned int nvals = 1;
631
638 __device__ __host__ inline point_expression_op(const exp1 & o1, const exp2 & o2)
639 :o1(o1),o2(o2),scal(0.0)
640 {}
641
647 __device__ __host__ inline void init() const
648 {
649 o1.init();
650 o2.init();
651
652 for (size_t i = 0 ; i < orig::dims ; i++)
653 scal += o1.value(i) * o2.value(i);
654 }
655
663 template<typename r_type=typename best_conv<typename std::remove_reference<decltype(o1.value(0))>::type,
664 typename std::remove_reference<decltype(o2.value(0))>::type>::type >
665 __device__ __host__ inline r_type value(size_t k) const
666 {
667 return scal;
668 }
669
671 template<typename T, typename test=typename boost::disable_if_c< std::is_same<T,orig>::value >::type >
672 __device__ __host__ operator T() const
673 {
674 init();
675 return scal;
676 }
677};
678
679
687template <typename orig, typename exp1, typename exp2>
689{
691 const exp1 o1;
693 const exp2 o2;
694
695public:
696
698 typedef typename first_or_second_pt<has_coordtype<exp1>::value,exp1,exp2>::coord_type coord_type;
699
701 typedef orig orig_type;
702
704 typedef int has_init;
705
707 typedef int is_expression;
708
710 typedef orig return_type;
711
714
721 __device__ __host__ inline point_expression_op(const exp1 & o1, const exp2 & o2)
722 :o1(o1),o2(o2)
723 {}
724
730 __device__ __host__ inline void init() const
731 {
732 o1.init();
733 o2.init();
734 }
735
741 template<typename r_type=typename best_conv<typename std::remove_reference<decltype(o1.value(0))>::type,
742 typename std::remove_reference<decltype(o2.value(0))>::type>::type >
743 __device__ __host__ inline r_type value(size_t k) const
744 {
745 return o1.value(k) * o2.value(k);
746 }
747
752 template<typename T, typename test=typename boost::disable_if_c< std::is_same<T,orig>::value || exp1::nvals != 1 || exp2::nvals != 1 >::type >
753 __device__ __host__ operator T() const
754 {
755 init();
756 return o1.value(0) * o2.value(0);
757 }
758
759};
760
767template <typename orig, typename exp1, typename exp2>
769{
771 const exp1 o1;
773 const exp2 o2;
774
775public:
776
777
779 typedef typename first_or_second_pt<has_coordtype<exp1>::value,exp1,exp2>::coord_type coord_type;
780
782 typedef orig orig_type;
783
785 typedef int is_expression;
786
788 typedef int has_init;
789
791 typedef orig return_type;
792
795
802 __device__ __host__ inline point_expression_op(const exp1 & o1, const exp2 & o2)
803 :o1(o1),o2(o2)
804 {}
805
811 __device__ __host__ inline void init() const
812 {
813 o1.init();
814 o2.init();
815 }
816
824 template<typename r_type=typename best_conv<typename std::remove_reference<decltype(o1.value(0))>::type,
825 typename std::remove_reference<decltype(o2.value(0))>::type>::type >
826 __device__ __host__ inline r_type value(size_t k) const
827 {
828 return o1.value(k) / o2.value(k);
829 }
830
831
836 template<typename T, typename test=typename boost::disable_if_c< std::is_same<T,orig>::value || exp1::nvals != 1 || exp2::nvals != 1 >::type > __device__ __host__ operator T() const
837 {
838 init();
839 return o1.value(0) / o2.value(0);
840 }
841};
842
850template<unsigned int dim, typename T> __device__ __host__ point_expression<T[dim]> getExprL(T (& a)[dim])
851{
852 return point_expression<T[dim]>(a);
853}
854
862template<unsigned int dim, typename T> __device__ __host__ point_expression<const T[dim]> getExprR(T (& a)[dim])
863{
865}
866
867template<unsigned int dim, typename T>
868struct ger
869{
870 template<typename vmpl> __device__ __host__
873 {
875 }
876
877 __device__ __host__ static point_expression<const T[dim]>
878 getExprR(T (& a)[dim])
879 {
881 }
882
883 template<typename vmpl> __device__ __host__
886 {
888 }
889
890 __device__ __host__ static point_expression<T[dim]>
891 getExprL(T (& a)[dim])
892 {
893 return point_expression<T[dim]>(a);
894 }
895};
896
897
903#define CREATE_POINT_OPERATOR(operator_name,OP_ID) \
904\
905\
906template<unsigned int dim, typename T>\
907__device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<const T[dim]>,OP_ID>\
908operator_name(const Point<dim,T> & va, const point_expression<const T[(unsigned int)dim]> & vb)\
909{\
910 point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<const T[dim]>,OP_ID> exp_sum(va,vb);\
911\
912 return exp_sum;\
913}\
914\
915template<unsigned int dim, typename T, typename vmpl>\
916__device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,OP_ID>\
917operator_name(const Point<dim,T> & va, const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & vb)\
918{\
919 point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,OP_ID> exp_sum(va,vb);\
920\
921 return exp_sum;\
922}\
923\
924template<unsigned int dim, typename T>\
925__device__ __host__ inline point_expression_op<Point<dim,T>,point_expression<const T[dim]>,Point<dim,T>,OP_ID>\
926operator_name(const point_expression<const T[(unsigned int)dim]> & va, const Point<dim,T> & vb)\
927{\
928 point_expression_op<Point<dim,T>,point_expression<const T[dim]>,Point<dim,T>,OP_ID> exp_sum(va,vb);\
929\
930 return exp_sum;\
931}\
932\
933template<unsigned int dim, typename T, typename vmpl>\
934__device__ __host__ inline point_expression_op<Point<dim,T>,point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,Point<dim,T>,OP_ID>\
935operator_name(const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & va,\
936 const Point<dim,T> & vb)\
937{\
938 point_expression_op<Point<dim,T>,point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,Point<dim,T>,OP_ID> exp_sum(va,vb);\
939\
940 return exp_sum;\
941}\
942\
943template<unsigned int dim, typename T>\
944__device__ __host__ inline point_expression_op<Point<dim,T>,point_expression<const T[dim]>,point_expression<double>,OP_ID>\
945operator_name(const point_expression<const T[dim]> & va, double d)\
946{\
947 point_expression_op<Point<dim,T>,point_expression<const T[dim]>,point_expression<double>,OP_ID> exp_sum(va,point_expression<double>(d));\
948\
949 return exp_sum;\
950}\
951\
952template<typename T, typename vmpl>\
953__device__ __host__ inline point_expression_op<Point<subar_dim<vmpl>::type::value,T>,\
954 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
955 point_expression<double>,\
956 OP_ID>\
957operator_name(const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & va, double d)\
958{\
959 point_expression_op<Point<subar_dim<vmpl>::type::value,T>,\
960 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
961 point_expression<double>,\
962 OP_ID>\
963 exp_sum(va,point_expression<double>(d));\
964\
965 return exp_sum;\
966}\
967\
968template<unsigned int dim, typename T>\
969__device__ __host__ inline point_expression_op<Point<dim,T>,point_expression<double>,point_expression<const T[dim]>,OP_ID>\
970operator_name(double d, const point_expression<const T[dim]> & va)\
971{\
972 point_expression_op<Point<dim,T>,point_expression<double>,point_expression<const T[dim]>,OP_ID> exp_sum(point_expression<double>(d),va);\
973\
974 return exp_sum;\
975}\
976\
977template<typename T, typename vmpl>\
978__device__ __host__ inline point_expression_op<Point<subar_dim<vmpl>::type::value,T>,\
979 point_expression<double>,\
980 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
981 OP_ID>\
982operator_name(double d, const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & va)\
983{\
984 point_expression_op<Point<subar_dim<vmpl>::type::value,T>,\
985 point_expression<double>,\
986 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
987 OP_ID>\
988 exp_sum(point_expression<double>(d),va);\
989\
990 return exp_sum;\
991}\
992\
993template<unsigned int dim, typename T>\
994__device__ __host__ inline point_expression_op<Point<dim,T>,point_expression<const T[dim]>,point_expression<const T[dim]>,OP_ID>\
995operator_name(const point_expression<const T[dim]> & va, const point_expression<const T[dim]> & vb)\
996{\
997 point_expression_op<Point<dim,T>,point_expression<const T[dim]>,point_expression<const T[dim]>,OP_ID> exp_sum(va,vb);\
998\
999 return exp_sum;\
1000}\
1001\
1002template<typename T, typename vmpl>\
1003__device__ __host__ inline point_expression_op<Point<subar_dim<vmpl>::type::value,T>,\
1004 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
1005 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
1006 OP_ID>\
1007operator_name(const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & va,\
1008 const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & vb)\
1009{\
1010 point_expression_op<Point<subar_dim<vmpl>::type::value,T>,\
1011 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
1012 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
1013 OP_ID> exp_sum(va,vb);\
1014\
1015 return exp_sum;\
1016}\
1017\
1018template<unsigned int dim, typename T>\
1019__device__ __host__ inline point_expression_op<Point<dim,T>,point_expression<const T[dim]>,point_expression<T[dim]>,OP_ID>\
1020operator_name(const point_expression<const T[dim]> & va, const point_expression<T[dim]> & vb)\
1021{\
1022 point_expression_op<Point<dim,T>,point_expression<const T[dim]>,point_expression<T[dim]>,OP_ID> exp_sum(va,vb);\
1023\
1024 return exp_sum;\
1025}\
1026\
1027template<typename orig, typename exp1 , typename exp2, unsigned int op1, unsigned int dim, typename T>\
1028__device__ __host__ inline point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<T[dim]>,OP_ID>\
1029operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, const point_expression<T[dim]> & vb)\
1030{\
1031 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<T[dim]>,OP_ID> exp_sum(va,vb);\
1032\
1033 return exp_sum;\
1034}\
1035\
1036template<typename orig, typename exp1 , typename exp2, unsigned int op1, typename T, typename vmpl>\
1037__device__ __host__ inline point_expression_op<orig,\
1038 point_expression_op<orig,exp1,exp2,op1>,\
1039 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
1040 OP_ID>\
1041operator_name(const point_expression_op<orig,exp1,exp2,op1> & va,\
1042 const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & vb)\
1043{\
1044 point_expression_op<orig,\
1045 point_expression_op<orig,exp1,exp2,op1>,\
1046 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
1047 OP_ID> exp_sum(va,vb);\
1048\
1049 return exp_sum;\
1050}\
1051\
1052template<typename orig, typename exp1 , typename exp2, unsigned int op1, unsigned int dim, typename T>\
1053__device__ __host__ inline point_expression_op<orig,point_expression<T[dim]>,point_expression_op<orig,exp1,exp2,op1>,OP_ID>\
1054operator_name(const point_expression<T[dim]> & va, const point_expression_op<orig,exp1,exp2,op1> & vb)\
1055{\
1056 point_expression_op<orig,point_expression<T[dim]>,point_expression_op<orig,exp1,exp2,op1>,OP_ID> exp_sum(va,vb);\
1057\
1058 return exp_sum;\
1059}\
1060\
1061template<typename orig, typename exp1 , typename exp2, unsigned int op1, typename T, typename vmpl>\
1062__device__ __host__ inline point_expression_op<orig,\
1063 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
1064 point_expression_op<orig,exp1,exp2,op1>,\
1065 OP_ID>\
1066operator_name(const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & va,\
1067 const point_expression_op<orig,exp1,exp2,op1> & vb)\
1068{\
1069 point_expression_op<orig,\
1070 point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>,\
1071 point_expression_op<orig,exp1,exp2,op1>,\
1072 OP_ID> exp_sum(va,vb);\
1073\
1074 return exp_sum;\
1075}\
1076\
1077\
1078template<unsigned int dim, typename T>\
1079__device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,Point<dim,T>,OP_ID>\
1080operator_name(const Point<dim,T> & va, const Point<dim,T> & vb)\
1081{\
1082 point_expression_op<Point<dim,T>,Point<dim,T>,Point<dim,T>,OP_ID> exp_sum(va,vb);\
1083\
1084 return exp_sum;\
1085}\
1086\
1087template<typename orig, typename exp1 , typename exp2, unsigned int op1, unsigned int dim, typename T>\
1088__device__ __host__ inline point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,Point<dim,T>,OP_ID>\
1089operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, const Point<dim,T> & vb)\
1090{\
1091 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,Point<dim,T>,OP_ID> exp_sum(va,vb);\
1092\
1093 return exp_sum;\
1094}\
1095\
1096template<typename orig,typename exp1 , typename exp2, unsigned int op1, unsigned int dim, typename T>\
1097__device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,point_expression_op<orig,exp1,exp2,op1>,OP_ID>\
1098operator_name(const Point<dim,T> & va, const point_expression_op<orig,exp1,exp2,op1> & vb)\
1099{\
1100 point_expression_op<Point<dim,T>,Point<dim,T>,point_expression_op<orig,exp1,exp2,op1>,OP_ID> exp_sum(va,vb);\
1101\
1102 return exp_sum;\
1103}\
1104\
1105template<typename orig, typename exp1 , typename exp2, unsigned int op1, typename T>\
1106__device__ __host__ inline point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<T>,OP_ID>\
1107operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, T d)\
1108{\
1109 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<T>,OP_ID> exp_sum(va,d);\
1110\
1111 return exp_sum;\
1112}\
1113\
1114template<typename orig,typename exp1 , typename exp2, unsigned int op1, typename T>\
1115__device__ __host__ inline point_expression_op<orig,point_expression<T>,point_expression_op<orig,exp1,exp2,op1>,OP_ID>\
1116operator_name(T d, const point_expression_op<orig,exp1,exp2,op1> & vb)\
1117{\
1118 point_expression_op<orig,point_expression<T>,point_expression_op<orig,exp1,exp2,op1>,OP_ID> exp_sum(d,vb);\
1119\
1120 return exp_sum;\
1121}\
1122\
1123template<typename orig,typename exp1 , typename exp2, unsigned int op1, typename exp3 , typename exp4, unsigned int op2>\
1124__device__ __host__ inline point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression_op<orig,exp3,exp4,op2>,OP_ID>\
1125operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, const point_expression_op<orig,exp3,exp4,op2> & vb)\
1126{\
1127 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression_op<orig,exp3,exp4,op2>,OP_ID> exp_sum(va,vb);\
1128\
1129 return exp_sum;\
1130}\
1131\
1132template<unsigned int dim , typename T, typename check=typename std::enable_if< !std::is_same<T,double>::value >::type >\
1133__device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<T>,OP_ID>\
1134operator_name(const Point<dim,T> & va, T d)\
1135{\
1136 point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<T>,OP_ID> exp_sum(va,point_expression<T>(d));\
1137\
1138 return exp_sum;\
1139}\
1140\
1141template<unsigned int dim , typename T>\
1142__device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<double>,OP_ID>\
1143operator_name(const Point<dim,T> & va, double d)\
1144{\
1145 point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<double>,OP_ID> exp_sum(va,point_expression<double>(d));\
1146\
1147 return exp_sum;\
1148}\
1149\
1150template<unsigned int dim , typename T, typename check=typename std::enable_if< !std::is_same<T,double>::value >::type >\
1151__device__ __host__ inline point_expression_op<Point<dim,T>,point_expression<T>,Point<dim,T>,OP_ID>\
1152operator_name(T d, const Point<dim,T> & vb)\
1153{\
1154 point_expression_op<Point<dim,T>,point_expression<T>,Point<dim,T>,OP_ID> exp_sum(point_expression<T>(d),vb);\
1155\
1156 return exp_sum;\
1157}\
1158\
1159template<unsigned int dim, typename T, typename check=typename std::enable_if< !std::is_same<T,double>::value >::type>\
1160__device__ __host__ inline point_expression_op<Point<dim,T>,point_expression<T[dim]>,Point<dim,T>,OP_ID>\
1161operator_name(T (& d)[dim], const Point<dim,T> & vb)\
1162{\
1163 point_expression_op<Point<dim,T>,point_expression<T[dim]>,Point<dim,T>,OP_ID> exp_sum(point_expression<T[dim]>(d),vb);\
1164\
1165 return exp_sum;\
1166}\
1167\
1168template<unsigned int dim , typename T>\
1169__device__ __host__ inline point_expression_op<Point<dim,T>,point_expression<double>,Point<dim,T>,OP_ID>\
1170operator_name(double d, const Point<dim,T> & vb)\
1171{\
1172 point_expression_op<Point<dim,T>,point_expression<double>,Point<dim,T>,OP_ID> exp_sum(point_expression<double>(d),vb);\
1173\
1174 return exp_sum;\
1175}\
1176\
1177template<typename orig, typename exp1 , typename exp2, unsigned int op1, typename T, typename check=typename std::enable_if< !std::is_same<T,double>::value >::type >\
1178__device__ __host__ inline point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<T>,OP_ID>\
1179operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, T d)\
1180{\
1181 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<T>,OP_ID> exp_sum(va,point_expression<T>(d));\
1182\
1183 return exp_sum;\
1184}\
1185\
1186template<typename orig, typename exp1 , typename exp2, unsigned int op1, typename T>\
1187__device__ __host__ inline point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<double>,OP_ID>\
1188operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, double d)\
1189{\
1190 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<double>,OP_ID> exp_sum(va,point_expression<double>(d));\
1191\
1192 return exp_sum;\
1193}
1194
1195
1196CREATE_POINT_OPERATOR(operator+,POINT_SUM)
1197CREATE_POINT_OPERATOR(operator-,POINT_SUB)
1198CREATE_POINT_OPERATOR(operator/,POINT_DIV)
1199
1200/* \brief sum two points expression
1201 *
1202 * \param va point expression one
1203 * \param vb point expression two
1204 *
1205 * \return an object that encapsulate the expression
1206 *
1207 */
1208template<typename orig, typename exp1 , typename exp2, unsigned int op1, typename T, typename check=typename std::enable_if< ! std::is_same<T,orig>::value >::type >
1209__device__ __host__ inline T &
1210operator+=(T & d, const point_expression_op<orig,exp1,exp2,op1> & va)
1211{
1212 va.init();
1213 d += va.value(0);
1214
1215 return d;
1216}
1217
1218
1219
1220/* \brief sum two points expression
1221 *
1222 * \param va point expression one
1223 * \param vb point expression two
1224 *
1225 * \return an object that encapsulate the expression
1226 *
1227 */
1228template<typename orig, typename exp1 , typename exp2, unsigned int op1, typename T>
1229__device__ __host__ inline T &
1230operator+=(orig & d, const point_expression_op<orig,exp1,exp2,op1> & va)
1231{
1232 va.init();
1233
1234 d = d + va;
1235
1236 return d;
1237}
1238
1239/* \brief minus points expression
1240 *
1241 * \param va point expression one
1242 *
1243 * \return an object that encapsulate the expression
1244 *
1245 */
1246template<typename orig, typename exp1, typename exp2, unsigned int op1>
1247__device__ __host__ inline point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,void, POINT_SUB_UNI >
1248operator-(const point_expression_op<orig,exp1,exp2,op1> & va)
1249{
1251
1252 return exp_sum;
1253}
1254
1255/* \brief minus points expression
1256 *
1257 * \param va point expression one
1258 *
1259 * \return an object that encapsulate the expression
1260 *
1261 */
1262template<unsigned int dim, typename T>
1263__device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,void, POINT_SUB_UNI >
1264operator-(const Point<dim,T> & va)
1265{
1266 point_expression_op<Point<dim,T>,Point<dim,T>,void,POINT_SUB_UNI> exp_sum(va);
1267
1268 return exp_sum;
1269}
1270
1271
1275
1276
1277template<unsigned int dim, typename T>
1279operator*(const point_expression<T[dim]> & va, double d)
1280{
1282
1283 return exp_sum;
1284}
1285
1286template<typename T, typename vmpl>
1287__device__ __host__ inline point_expression_op<Point<subar_dim<vmpl>::type::value,T>,
1290 POINT_MUL>
1292 double d)
1293{
1297 POINT_MUL> exp_sum(va,point_expression<double>(d));
1298
1299 return exp_sum;
1300}
1301
1302template<unsigned int dim, typename T>
1304operator*(double d,
1305 const point_expression<T[dim]> & va)
1306{
1308
1309 return exp_sum;
1310}
1311
1312template<typename T, typename vmpl>
1313__device__ __host__ inline point_expression_op<Point<subar_dim<vmpl>::type::value,T>,
1316 POINT_MUL>
1317operator*(double d,
1319{
1323 POINT_MUL> exp_sum(point_expression<double>(d),va);
1324
1325 return exp_sum;
1326}
1327
1328template<unsigned int dim, typename T>
1330operator*(const point_expression<T[dim]> & va, const point_expression<T[dim]> & vb)
1331{
1333
1334 return exp_sum;
1335}
1336
1337template<typename T, typename vmpl>
1338__device__ __host__ inline point_expression_op<Point<subar_dim<vmpl>::type::value,T>,
1341 POINT_MUL_POINT>
1344{
1348 POINT_MUL_POINT> exp_sum(va,vb);
1349
1350 return exp_sum;
1351}
1352
1353template<unsigned int dim, typename T, typename check=typename std::enable_if< !std::is_same<T,double>::value >::type>
1354__device__ __host__ inline point_expression_op<Point<dim,T>,point_expression<T>,Point<dim,T>,POINT_MUL>
1355operator*(T d, const Point<dim,T> & vb)
1356{
1358
1359 return exp_sum;
1360}
1361
1363
1364template<typename orig,
1365 typename exp1 ,
1366 typename exp2,
1367 unsigned int op1,
1368 unsigned int dim,
1369 typename T,
1370 typename sfinae = typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == dim >::type >
1371__device__ __host__ inline point_expression_op<orig,
1374 POINT_MUL_POINT>
1375operator*(const point_expression_op<orig,exp1,exp2,op1> & va, const point_expression<T[dim]> & vb)
1376{
1380 POINT_MUL_POINT> exp_sum(va,vb);
1381
1382 return exp_sum;
1383}
1384
1385template<typename orig,
1386 typename exp1 ,
1387 typename exp2,
1388 unsigned int op1,
1389 typename T,
1390 typename vmpl,
1391 typename sfinae = typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == subar_dim<vmpl>::type::value >::type >
1392__device__ __host__ inline point_expression_op<orig,
1395 POINT_MUL_POINT>
1397{
1401 POINT_MUL_POINT> exp_sum(va,vb);
1402
1403 return exp_sum;
1404}
1405
1406template<typename orig,
1407 typename exp1 ,
1408 typename exp2,
1409 unsigned int op1,
1410 unsigned int dim,
1411 typename T,
1412 typename sfinae = typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == 1 >::type >
1414operator*(const point_expression_op<orig,exp1,exp2,op1> & va, const point_expression<T[dim]> & vb)
1415{
1417
1418 return exp_sum;
1419}
1420
1421template<typename orig,
1422 typename exp1 ,
1423 typename exp2,
1424 unsigned int op1,
1425 typename T,
1426 typename vmpl,
1427 typename sfinae = typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == 1 >::type >
1428__device__ __host__ inline point_expression_op<orig,
1431 POINT_MUL>
1433{
1437 POINT_MUL> exp_sum(va,vb);
1438
1439 return exp_sum;
1440}
1441
1443
1444template<typename orig,
1445 typename exp1,
1446 typename exp2,
1447 unsigned int op1,
1448 unsigned int dim,
1449 typename T,
1450 typename sfinae = typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == dim >::type >
1452operator*(const point_expression<T[dim]> & va, const point_expression_op<orig,exp1,exp2,op1> & vb)
1453{
1455
1456 return exp_sum;
1457}
1458
1459template<typename orig,
1460 typename exp1,
1461 typename exp2,
1462 unsigned int op1,
1463 typename T,
1464 typename vmpl,
1465 typename sfinae = typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == subar_dim<vmpl>::type::value >::type >
1466__device__ __host__ inline point_expression_op<orig,
1469 POINT_MUL_POINT>
1471{
1475 POINT_MUL_POINT> exp_sum(va,vb);
1476
1477 return exp_sum;
1478}
1479
1480template<typename orig,
1481 typename exp1,
1482 typename exp2,
1483 unsigned int op1,
1484 unsigned int dim,
1485 typename T,
1486 typename sfinae = typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == 1 >::type >
1488operator*(const point_expression<T[dim]> & va, const point_expression_op<orig,exp1,exp2,op1> & vb)
1489{
1491
1492 return exp_sum;
1493}
1494
1495template<typename orig,
1496 typename exp1,
1497 typename exp2,
1498 unsigned int op1,
1499 typename T,
1500 typename vmpl,
1501 typename sfinae = typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == 1 >::type >
1502__device__ __host__ inline point_expression_op<orig,
1505 POINT_MUL>
1507{
1511 POINT_MUL> exp_sum(va,vb);
1512
1513 return exp_sum;
1514}
1515
1517
1518/* \brief Multiply two points expression
1519 *
1520 * \param va vector expression one
1521 * \param vb vector expression two
1522 *
1523 * \return an object that encapsulate the expression
1524 *
1525 */
1526template<unsigned int dim, typename T>
1528operator*(double d, const Point<dim,T> & vb)
1529{
1531
1532 return exp_sum;
1533}
1534
1535/* \brief Multiply two points expression
1536 *
1537 * \param va point expression one
1538 * \param vb point expression two
1539 *
1540 * \return an object that encapsulate the expression
1541 *
1542 */
1543template<unsigned int dim, typename T, typename check=typename std::enable_if< !std::is_same<T,double>::value >::type >
1544__device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<T>,POINT_MUL>
1545operator*(const Point<dim,T> & va, T d)
1546{
1548
1549 return exp_sum;
1550}
1551
1552/* \brief Multiply two points expression
1553 *
1554 * \param va point expression one
1555 * \param vb point expression two
1556 *
1557 * \return an object that encapsulate the expression
1558 *
1559 */
1560template<unsigned int dim, typename T>
1562operator*(const Point<dim,T> & va, double d)
1563{
1565
1566 return exp_sum;
1567}
1568
1569/* \brief Multiply two points expression
1570 *
1571 * \param va point expression one
1572 * \param vb point expression two
1573 *
1574 * \return an object that encapsulate the expression
1575 *
1576 */
1577template<unsigned int dim, typename T>
1578__device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,Point<dim,T>,POINT_MUL_POINT>
1579operator*(const Point<dim,T> & va, const Point<dim,T> & vb)
1580{
1581 point_expression_op<Point<dim,T>,Point<dim,T>,Point<dim,T>,POINT_MUL_POINT> exp_sum(va,vb);
1582
1583 return exp_sum;
1584}
1585
1586/* \brief Multiply two points expression
1587 *
1588 * \param va point expression one
1589 * \param vb point expression two
1590 *
1591 * \return an object that encapsulate the expression
1592 *
1593 */
1594template<typename orig,
1595 unsigned int dim,
1596 typename T,
1597 typename exp1,
1598 typename exp2,
1599 unsigned int op1,
1600 typename sfinae = typename std::enable_if<point_expression_op<orig,exp1,exp2,op1>::nvals != 1>::type >
1602operator*(const Point<dim,T> & va, const point_expression_op<orig,exp1,exp2,op1> & vb)
1603{
1605
1606 return exp_sum;
1607}
1608
1609/* \brief Multiply two points expression
1610 *
1611 * \param va point expression one
1612 * \param vb point expression two
1613 *
1614 * \return an object that encapsulate the expression
1615 *
1616 */
1617template<typename orig,
1618 unsigned int dim,
1619 typename T,
1620 typename exp1,
1621 typename exp2,
1622 unsigned int op1,
1623 typename sfinae = typename std::enable_if<point_expression_op<orig,exp1,exp2,op1>::nvals == 1>::type >
1625operator*(const Point<dim,T> & va, const point_expression_op<orig,exp1,exp2,op1> & vb)
1626{
1628
1629 return exp_sum;
1630}
1631
1632/* \brief Multiply two points expression
1633 *
1634 * \param va point expression one
1635 * \param vb point expression two
1636 *
1637 * \return an object that encapsulate the expression
1638 *
1639 */
1640template<typename orig,
1641 unsigned int dim,
1642 typename T,
1643 typename exp1,
1644 typename exp2,
1645 unsigned int op1,
1646 typename sfinae = typename std::enable_if<point_expression_op<orig,exp1,exp2,op1>::nvals != 1>::type >
1648operator*(const point_expression_op<orig,exp1,exp2,op1> & va, const Point<dim,T> & vb)
1649{
1651
1652 return exp_sum;
1653}
1654
1655/* \brief Multiply two points expression
1656 *
1657 * \param va point expression one
1658 * \param vb point expression two
1659 *
1660 * \return an object that encapsulate the expression
1661 *
1662 */
1663template<typename orig,
1664 unsigned int dim,
1665 typename T,
1666 typename exp1,
1667 typename exp2,
1668 unsigned int op1,
1669 typename check = typename std::enable_if<point_expression_op<orig,exp1,exp2,op1>::nvals == 1>::type >
1671operator*(const point_expression_op<orig,exp1,exp2,op1> & va, const Point<dim,T> & vb)
1672{
1674
1675 return exp_sum;
1676}
1677
1678/* \brief Multiply a point expression with a number
1679 *
1680 * \param d number
1681 * \param vb point expression
1682 *
1683 * \return an object that encapsulate the expression
1684 *
1685 */
1686template<typename orig, typename T, typename exp1, typename exp2, unsigned int op1>
1688operator*(T d, const point_expression_op<orig,exp1,exp2,op1> & vb)
1689{
1691
1692 return exp_sum;
1693}
1694
1695
1696/* \brief Multiply two points expression
1697 *
1698 * \param va point expression one
1699 * \param d constant value
1700 *
1701 * \return an object that encapsulate the expression
1702 *
1703 */
1704template<typename orig, typename exp1, typename exp2, unsigned int op1, typename T>
1706operator*(const point_expression_op<orig,exp1,exp2,op1> & va, T d)
1707{
1709
1710 return exp_sum;
1711}
1712
1713
1714/* \brief Multiply two points expression
1715 *
1716 * \param va point expression one
1717 * \param vb point expression two
1718 *
1719 * \return an object that encapsulate the expression
1720 *
1721 */
1722template<typename orig,
1723 typename exp1,
1724 typename exp2,
1725 unsigned int op1,
1726 typename exp3 ,
1727 typename exp4,
1728 unsigned int op2,
1729 typename check = typename std::enable_if<point_expression_op<orig,exp1,exp2,op1>::nvals != 1 && point_expression_op<orig,exp3,exp4,op2>::nvals != 1>::type >
1732{
1734
1735 return exp_sum;
1736}
1737
1738/* \brief Multiply two points expression
1739 *
1740 * \param va point expression one
1741 * \param vb point expression two
1742 *
1743 * \return an object that encapsulate the expression
1744 *
1745 */
1746template<typename orig,
1747 typename exp1,
1748 typename exp2,
1749 unsigned int op1,
1750 typename exp3 ,
1751 typename exp4,
1752 unsigned int op2,
1753 typename check = typename std::enable_if<point_expression_op<orig,exp1,exp2,op1>::nvals == 1 || point_expression_op<orig,exp3,exp4,op2>::nvals == 1 >::type >
1756{
1758
1759 return exp_sum;
1760}
1761
1763
1764/* \brief Multiply two points expression
1765 *
1766 * \param va point expression one
1767 * \param vb point expression two
1768 *
1769 * \return an object that encapsulate the expression
1770 *
1771 */
1772template<unsigned int dim, typename T>
1773__device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,Point<dim,T>,POINT_MUL>
1774pmul(const Point<dim,T> & va, const Point<dim,T> & vb)
1775{
1777
1778 return exp_sum;
1779}
1780
1781/* \brief Multiply two points expression
1782 *
1783 * \param va point expression one
1784 * \param vb point expression two
1785 *
1786 * \return an object that encapsulate the expression
1787 *
1788 */
1789template<typename orig, unsigned int dim, typename T, typename exp1, typename exp2, unsigned int op1>
1791pmul(const Point<dim,T> & va, const point_expression_op<orig,exp1,exp2,op1> & vb)
1792{
1794
1795 return exp_sum;
1796}
1797
1798/* \brief Multiply two points expression
1799 *
1800 * \param va point expression one
1801 * \param vb point expression two
1802 *
1803 * \return an object that encapsulate the expression
1804 *
1805 */
1806template<typename orig,unsigned int dim, typename T, typename exp1, typename exp2, unsigned int op1>
1808pmul(const point_expression_op<orig,exp1,exp2,op1> & va, const Point<dim,T> & vb)
1809{
1811
1812 return exp_sum;
1813}
1814
1815/* \brief Multiply two points expression
1816 *
1817 * \param va point expression one
1818 * \param vb point expression two
1819 *
1820 * \return an object that encapsulate the expression
1821 *
1822 */
1823template<typename orig, typename exp1, typename exp2, unsigned int op1, typename exp3 , typename exp4, unsigned int op2>
1826{
1828
1829 return exp_sum;
1830}
1831
1832
1839template<typename T, unsigned int dim>
1840class point_expression<T[dim]>
1841{
1843 T (& d)[dim];
1844
1845public:
1846
1848 typedef int has_init;
1849
1851 typedef int is_expression;
1852
1854 static const unsigned int nvals = dim;
1855
1857 typedef T coord_type;
1858
1864 inline point_expression(T (& d)[dim])
1865 :d(d)
1866 {
1867 }
1868
1881 template<typename orig, typename exp1, typename exp2, unsigned int op>
1883 {
1884 p_exp.init();
1885
1886 for (size_t i = 0; i < dim ; i++)
1887 {d[i] = p_exp.value(i);}
1888
1889 return *this;
1890 }
1891
1899 template<typename T_>
1900 __device__ __host__ point_expression<T[dim]> & operator=(const point_expression<T_> & p_exp)
1901 {
1902 p_exp.init();
1903
1904 for (size_t i = 0; i < dim ; i++)
1905 {d[i] = p_exp.value(i);}
1906
1907 return *this;
1908 }
1909
1913 __device__ __host__ T & operator[](int n)
1914 {
1915 return d[n];
1916 }
1917
1921 __device__ __host__ const T & operator[](int n) const
1922 {
1923 return d[n];
1924 }
1925
1931 __device__ __host__ inline void init() const
1932 {
1933 }
1934
1944 __device__ __host__ inline T value(const size_t k) const
1945 {
1946 return d[k];
1947 }
1948};
1949
1950
1957template<typename T, unsigned int dim>
1958class point_expression<const T[dim]>
1959{
1961 const T (& d)[dim];
1962
1963public:
1964
1966 typedef int has_init;
1967
1969 typedef int is_expression;
1970
1972 static const unsigned int nvals = dim;
1973
1975 typedef T coord_type;
1976
1982 __device__ __host__ inline point_expression(const T (& d)[dim])
1983 :d(d)
1984 {
1985 }
1986
1992 __device__ __host__ inline void init() const
1993 {
1994 }
1995
1999 T operator[](int n) const
2000 {
2001 return d[n];
2002 }
2003
2013 __device__ __host__ inline T value(const size_t k) const
2014 {
2015 return d[k];
2016 }
2017};
2018
2025template<typename T, typename vmpl>
2026class point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>
2027{
2030
2031public:
2032
2034 typedef int has_init;
2035
2037 typedef int is_expression;
2038
2040 static const unsigned int nvals = subar_dim<vmpl>::type::value;
2041
2043 typedef T coord_type;
2044
2057 template<typename orig, typename exp1, typename exp2, unsigned int op>
2060 {
2061 p_exp.init();
2062
2063 for (size_t i = 0; i < nvals ; i++)
2064 {d[i] = p_exp.value(i);}
2065
2066 return *this;
2067 }
2068
2075 :d(d.origin_mutable(),d.strides())
2076 {
2077 }
2078
2084 __device__ __host__ inline void init() const
2085 {
2086 }
2087
2093 __device__ __host__ inline T & operator[](int k)
2094 {
2095 return value(k);
2096 }
2097
2103 __device__ __host__ inline T & operator[](int k) const
2104 {
2105 return value(k);
2106 }
2107
2117 __device__ __host__ inline T & value(const int k)
2118 {
2119 return d[k];
2120 }
2121
2131 __device__ __host__ inline T & value(const int k) const
2132 {
2133 return d[k];
2134 }
2135};
2136
2137#include "Point_operators_functions.hpp"
2138
2139#endif /* OPENFPM_DATA_SRC_SPACE_SHAPE_POINT_OPERATORS_HPP_ */
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
__device__ __host__ const T & operator[](int n) const
Array operator.
__device__ __host__ point_expression< T[dim]> & operator=(const point_expression_op< orig, exp1, exp2, op > &p_exp)
Operator= for point expression.
__device__ __host__ T & operator[](int n)
Array operator.
point_expression(T(&d)[dim])
constructor from an array
T coord_type
The type of the internal vector.
int has_init
indicate that init must be called before value
__device__ __host__ point_expression< T[dim]> & operator=(const point_expression< T_ > &p_exp)
Operator= for point expression.
__device__ __host__ T value(const size_t k) const
Evaluate the expression at coordinate k.
__device__ __host__ void init() const
This function must be called before value.
int is_expression
indicate that this class encapsulate an expression
T operator[](int n) const
Array operator.
__device__ __host__ T value(const size_t k) const
Evaluate the expression at coordinate k.
int is_expression
indicate that this class encapsulate an expression
__device__ __host__ point_expression(const T(&d)[dim])
construct from an array of dimension dim
T coord_type
The type of the internal vector.
__device__ __host__ void init() const
This function must be called before value.
int has_init
indicate that init must be called before value
openfpm::detail::multi_array::sub_array_openfpm< T, 1, vmpl > d
array view of dimension dim
__device__ __host__ void init() const
This function must be called before value.
__device__ __host__ T & value(const int k)
Evaluate the expression at coordinate k.
__device__ __host__ point_expression< openfpm::detail::multi_array::sub_array_openfpm< T, 1, vmpl > > & operator=(const point_expression_op< orig, exp1, exp2, op > &p_exp)
Operator= for point expression.
__device__ __host__ point_expression(const openfpm::detail::multi_array::sub_array_openfpm< T, 1, vmpl > &d)
construct from an array of dimension dim
__device__ __host__ T & value(const int k) const
Evaluate the expression at coordinate k.
__device__ __host__ void init() const
This function must be called before value.
int is_expression
indicate that this class encapsulate an expression
__device__ __host__ r_type value(size_t k) const
Evaluate the expression.
__device__ __host__ point_expression_op(const exp1 &o1, const exp2 &o2)
constructor from expression 1 and expression 2
int has_init
indicate that init must be called before value
first_or_second_pt< has_coordtype< exp1 >::value, exp1, exp2 >::coord_type coord_type
The type of the internal vector.
__device__ __host__ r_type value(size_t k) const
Evaluate the expression.
__device__ __host__ void init() const
This function must be called before value.
int is_expression
indicate that this class encapsulate an expression
first_or_second_pt< has_coordtype< exp1 >::value, exp1, exp2 >::coord_type coord_type
The type of the internal vector.
int has_init
indicate that init must be called before value
__device__ __host__ point_expression_op(const exp1 &o1, const exp2 &o2)
constructor from 2 expression
__device__ __host__ point_expression_op(const exp1 &o1, const exp2 &o2)
constructor from 2 expressions
orig::coord_type return_type
return type of the expression
int is_expression
indicate that this class encapsulate an expression
__device__ __host__ void init() const
This function must be called before value.
__device__ __host__ r_type value(size_t k) const
Evaluate the expression.
first_or_second_pt< has_coordtype< exp1 >::value, exp1, exp2 >::coord_type coord_type
The type of the internal vector.
std::remove_const< typenameorig::coord_type >::type scal
the expression produce a scalar
int has_init
indicate that init must be called before value
int has_init
indicate that init must be called before value
__device__ __host__ r_type value(size_t k) const
Evaluate the expression at coordinate k.
int is_expression
indicate that this class encapsulate an expression
__device__ __host__ void init() const
This function must be called before value.
__device__ __host__ point_expression_op(const exp1 &o1, const exp2 &o2)
constructor from 2 expressions
first_or_second_pt< has_coordtype< exp1 >::value, exp1, exp2 >::coord_type coord_type
The type of the internal vector.
orig::coord_type scal
scalar value produced by the expression
int has_init
indicate that this class has an init function
__device__ __host__ void init() const
initialize the the expression
__device__ __host__ point_expression_op(const exp1 &o1)
first_or_second_pt< has_coordtype< exp1 >::value, exp1, exp2 >::coord_type coord_type
The type of the internal vector.
orig::coord_type return_type
return type of the expression evaluation
__device__ __host__ r_type value(size_t k) const
evaluate the expression
first_or_second_pt< has_coordtype< exp1 >::value, exp1, exp2 >::coord_type coord_type
The type of the internal vector.
r_type_p< r_type_dim< exp1::nvals, exp2::nvals, POINT_SUM >::value, orig >::type return_type
return type of the expression
orig orig_type
original type of the point expression
int has_init
indicate that init must be called before value
__device__ __host__ point_expression_op(const exp1 &o1, const exp2 &o2)
Constructor from 2 point expressions.
__device__ __host__ void init() const
This function must be called before value.
__device__ __host__ r_type value(size_t k) const
Evaluate the expression at coordinate k.
int is_expression
indicate that this class encapsulate an expression
Unknown operation specialization.
Main class that encapsulate a constant number used in a point expression.
__device__ __host__ T & value(const int k)
Evaluate the expression.
__device__ __host__ void init() const
This function must be called before value.
static const unsigned int nvals
this operation produce a vector as result of size dims
__device__ __host__ point_expression(T &d)
constructor from a value
__device__ __host__ const T & value(const int k) const
Evaluate the expression.
int is_expression
indicate that this class encapsulate an expression
int has_init
indicate that init must be called before value
convert a type into constant type
Void structure.
Definition common.hpp:74
It return the dimansionality of the operation given the dimensionality of the 2 operators.
orig::coord_type type
meta-function return a scalar or the expression produce a scalar
Return type of the expression.
orig type
meta-function return orig or the expression produce a vector
return the dimension of the sub_array