8 #ifndef OPENFPM_DATA_SRC_SPACE_SHAPE_POINT_OPERATORS_HPP_
9 #define OPENFPM_DATA_SRC_SPACE_SHAPE_POINT_OPERATORS_HPP_
11 #include "util/multi_array_openfpm/array_openfpm.hpp"
13 template<
unsigned int dim ,
typename T>
class Point;
19 #define POINT_MUL_POINT 5
28 #define POINT_EXPM1 11
30 #define POINT_LOG10 13
32 #define POINT_LOG1P 15
44 #define POINT_ASINH 28
45 #define POINT_ACOSH 29
46 #define POINT_ATANH 30
49 #define POINT_TGAMMA 33
50 #define POINT_LGAMMA 34
52 #define POINT_FLOOR 36
53 #define POINT_TRUNC 37
54 #define POINT_ROUND 38
55 #define POINT_NEARBYINT 39
57 #define POINT_SUB_UNI 41
58 #define POINT_NORM_INF 42
63 template<
bool cond,
typename exp1,
typename exp2>
66 typedef typename exp2::coord_type coord_type;
69 template<
typename exp1,
typename exp2>
72 typedef typename exp1::coord_type coord_type;
75 template<
typename T,
typename Sfinae =
void>
91 template<
typename source1,
typename source2>
97 template<
typename source2>
100 typedef source2 type;
103 template<
typename source2>
106 typedef source2 type;
109 template<
typename source2>
112 typedef source2 type;
115 template<
typename source2>
118 typedef source2 type;
121 template<
typename source1>
124 typedef source1 type;
127 template<
typename source1>
130 typedef source1 type;
133 template<
typename source1>
136 typedef source1 type;
139 template<
typename source1>
142 typedef source1 type;
145 template<
typename source1,
typename source2>
153 constexpr
unsigned int max_expr(
unsigned int dim1,
unsigned int dim2)
155 return (dim1 > dim2)?dim1:dim2;
167 template <
unsigned int op1_dim,
unsigned int op2_dim,
unsigned int op>
173 value = max_expr(op1_dim,op2_dim),
200 template <
unsigned int op1_dim,
unsigned int op2_dim>
238 template <
unsigned int r,
typename orig>
250 template <
typename orig>
254 typedef typename orig::coord_type
type;
277 static const unsigned int nvals = 1;
279 typedef T coord_type;
295 __device__ __host__
inline void init()
const
306 __device__ __host__
inline const T &
value(
const int k)
const
318 __device__ __host__
inline T &
value(
const int k)
334 template <
typename orig,
typename exp1,
typename exp2,
unsigned int op>
347 template <
typename orig,
typename exp1,
typename exp2>
390 __device__ __host__
inline void init()
const
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
407 return o1.value(k) + o2.value(k);
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
418 return o1.value(0) + o2.value(0);
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 >
432 return o1.value(i) + o2.value(i);
442 template <
typename orig,
typename exp1,
typename exp2>
485 __device__ __host__
inline void init()
const
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
502 return o1.value(k) - o2.value(k);
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
513 return o1.value(0) - o2.value(0);
526 template <
typename orig,
typename exp1,
typename exp2>
533 mutable typename orig::coord_type
scal;
550 static const unsigned int nvals = exp1::nvals;
565 __device__ __host__
inline void init()
const
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
580 return -(o1.value(k));
584 template <typename T, typename check = typename std::enable_if<!std::is_same<T,orig>::value >::type >
585 __device__ __host__
operator T()
const
588 return -(o1.value(0));
601 template <
typename orig,
typename exp1,
typename exp2>
610 mutable typename std::remove_const<typename orig::coord_type>::type
scal;
630 static const unsigned int nvals = 1;
639 :o1(o1),o2(o2),scal(0.0)
647 __device__ __host__
inline void init()
const
652 for (
size_t i = 0 ; i < orig::dims ; i++)
653 scal += o1.value(i) * o2.value(i);
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
671 template<typename T, typename test=typename boost::disable_if_c< std::is_same<T,orig>::value >::type >
672 __device__ __host__
operator T()
const
687 template <
typename orig,
typename exp1,
typename exp2>
730 __device__ __host__
inline void init()
const
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
745 return o1.value(k) * o2.value(k);
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
756 return o1.value(0) * o2.value(0);
767 template <
typename orig,
typename exp1,
typename exp2>
811 __device__ __host__
inline void init()
const
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
828 return o1.value(k) / o2.value(k);
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
839 return o1.value(0) / o2.value(0);
867 template<
unsigned int dim,
typename T>
870 template<
typename vmpl> __device__ __host__
878 getExprR(T (& a)[dim])
883 template<
typename vmpl> __device__ __host__
891 getExprL(T (& a)[dim])
903 #define CREATE_POINT_OPERATOR(operator_name,OP_ID) \
906 template<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>\
908 operator_name(const Point<dim,T> & va, const point_expression<const T[(unsigned int)dim]> & vb)\
910 point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<const T[dim]>,OP_ID> exp_sum(va,vb);\
915 template<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>\
917 operator_name(const Point<dim,T> & va, const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & vb)\
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);\
924 template<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>\
926 operator_name(const point_expression<const T[(unsigned int)dim]> & va, const Point<dim,T> & vb)\
928 point_expression_op<Point<dim,T>,point_expression<const T[dim]>,Point<dim,T>,OP_ID> exp_sum(va,vb);\
933 template<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>\
935 operator_name(const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & va,\
936 const Point<dim,T> & vb)\
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);\
943 template<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>\
945 operator_name(const point_expression<const T[dim]> & va, double d)\
947 point_expression_op<Point<dim,T>,point_expression<const T[dim]>,point_expression<double>,OP_ID> exp_sum(va,point_expression<double>(d));\
952 template<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>,\
957 operator_name(const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & va, double d)\
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>,\
963 exp_sum(va,point_expression<double>(d));\
968 template<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>\
970 operator_name(double d, const point_expression<const T[dim]> & va)\
972 point_expression_op<Point<dim,T>,point_expression<double>,point_expression<const T[dim]>,OP_ID> exp_sum(point_expression<double>(d),va);\
977 template<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>>,\
982 operator_name(double d, const point_expression<openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>> & va)\
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>>,\
988 exp_sum(point_expression<double>(d),va);\
993 template<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>\
995 operator_name(const point_expression<const T[dim]> & va, const point_expression<const T[dim]> & vb)\
997 point_expression_op<Point<dim,T>,point_expression<const T[dim]>,point_expression<const T[dim]>,OP_ID> exp_sum(va,vb);\
1002 template<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>>,\
1007 operator_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)\
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);\
1018 template<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>\
1020 operator_name(const point_expression<const T[dim]> & va, const point_expression<T[dim]> & vb)\
1022 point_expression_op<Point<dim,T>,point_expression<const T[dim]>,point_expression<T[dim]>,OP_ID> exp_sum(va,vb);\
1027 template<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>\
1029 operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, const point_expression<T[dim]> & vb)\
1031 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<T[dim]>,OP_ID> exp_sum(va,vb);\
1036 template<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>>,\
1041 operator_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)\
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);\
1052 template<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>\
1054 operator_name(const point_expression<T[dim]> & va, const point_expression_op<orig,exp1,exp2,op1> & vb)\
1056 point_expression_op<orig,point_expression<T[dim]>,point_expression_op<orig,exp1,exp2,op1>,OP_ID> exp_sum(va,vb);\
1061 template<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>,\
1066 operator_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)\
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);\
1078 template<unsigned int dim, typename T>\
1079 __device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,Point<dim,T>,OP_ID>\
1080 operator_name(const Point<dim,T> & va, const Point<dim,T> & vb)\
1082 point_expression_op<Point<dim,T>,Point<dim,T>,Point<dim,T>,OP_ID> exp_sum(va,vb);\
1087 template<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>\
1089 operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, const Point<dim,T> & vb)\
1091 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,Point<dim,T>,OP_ID> exp_sum(va,vb);\
1096 template<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>\
1098 operator_name(const Point<dim,T> & va, const point_expression_op<orig,exp1,exp2,op1> & vb)\
1100 point_expression_op<Point<dim,T>,Point<dim,T>,point_expression_op<orig,exp1,exp2,op1>,OP_ID> exp_sum(va,vb);\
1105 template<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>\
1107 operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, T d)\
1109 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<T>,OP_ID> exp_sum(va,d);\
1114 template<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>\
1116 operator_name(T d, const point_expression_op<orig,exp1,exp2,op1> & vb)\
1118 point_expression_op<orig,point_expression<T>,point_expression_op<orig,exp1,exp2,op1>,OP_ID> exp_sum(d,vb);\
1123 template<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>\
1125 operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, const point_expression_op<orig,exp3,exp4,op2> & vb)\
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);\
1132 template<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>\
1134 operator_name(const Point<dim,T> & va, T d)\
1136 point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<T>,OP_ID> exp_sum(va,point_expression<T>(d));\
1141 template<unsigned int dim , typename T>\
1142 __device__ __host__ inline point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<double>,OP_ID>\
1143 operator_name(const Point<dim,T> & va, double d)\
1145 point_expression_op<Point<dim,T>,Point<dim,T>,point_expression<double>,OP_ID> exp_sum(va,point_expression<double>(d));\
1150 template<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>\
1152 operator_name(T d, const Point<dim,T> & vb)\
1154 point_expression_op<Point<dim,T>,point_expression<T>,Point<dim,T>,OP_ID> exp_sum(point_expression<T>(d),vb);\
1159 template<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>\
1161 operator_name(T (& d)[dim], const Point<dim,T> & vb)\
1163 point_expression_op<Point<dim,T>,point_expression<T[dim]>,Point<dim,T>,OP_ID> exp_sum(point_expression<T[dim]>(d),vb);\
1168 template<unsigned int dim , typename T>\
1169 __device__ __host__ inline point_expression_op<Point<dim,T>,point_expression<double>,Point<dim,T>,OP_ID>\
1170 operator_name(double d, const Point<dim,T> & vb)\
1172 point_expression_op<Point<dim,T>,point_expression<double>,Point<dim,T>,OP_ID> exp_sum(point_expression<double>(d),vb);\
1177 template<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>\
1179 operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, T d)\
1181 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<T>,OP_ID> exp_sum(va,point_expression<T>(d));\
1186 template<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>\
1188 operator_name(const point_expression_op<orig,exp1,exp2,op1> & va, double d)\
1190 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,point_expression<double>,OP_ID> exp_sum(va,point_expression<double>(d));\
1196 CREATE_POINT_OPERATOR(
operator+,POINT_SUM)
1197 CREATE_POINT_OPERATOR(
operator-,POINT_SUB)
1198 CREATE_POINT_OPERATOR(
operator/,POINT_DIV)
1208 template<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 &
1228 template<
typename orig,
typename exp1 ,
typename exp2,
unsigned int op1,
typename T>
1229 __device__ __host__
inline T &
1246 template<
typename orig,
typename exp1,
typename exp2,
unsigned int op1>
1262 template<
unsigned int dim,
typename T>
1277 template<
unsigned int dim,
typename T>
1286 template<
typename T,
typename vmpl>
1302 template<
unsigned int dim,
typename T>
1312 template<
typename T,
typename vmpl>
1328 template<
unsigned int dim,
typename T>
1337 template<
typename T,
typename vmpl>
1348 POINT_MUL_POINT> exp_sum(va,vb);
1353 template<unsigned int dim, typename T, typename check=typename std::enable_if< !std::is_same<T,double>::value >::type>
1364 template<
typename orig,
1370 typename sfinae =
typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == dim >::type >
1380 POINT_MUL_POINT> exp_sum(va,vb);
1385 template<
typename orig,
1401 POINT_MUL_POINT> exp_sum(va,vb);
1406 template<
typename orig,
1412 typename sfinae =
typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == 1 >::type >
1421 template<
typename orig,
1427 typename sfinae =
typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == 1 >::type >
1437 POINT_MUL> exp_sum(va,vb);
1444 template<
typename orig,
1450 typename sfinae =
typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == dim >::type >
1459 template<
typename orig,
1475 POINT_MUL_POINT> exp_sum(va,vb);
1480 template<
typename orig,
1486 typename sfinae =
typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == 1 >::type >
1495 template<
typename orig,
1501 typename sfinae =
typename std::enable_if< point_expression_op<orig,exp1,exp2,op1>::nvals == 1 >::type >
1511 POINT_MUL> exp_sum(va,vb);
1526 template<
unsigned int dim,
typename T>
1543 template<unsigned int dim, typename T, typename check=typename std::enable_if< !std::is_same<T,double>::value >::type >
1560 template<
unsigned int dim,
typename T>
1577 template<
unsigned int dim,
typename T>
1594 template<
typename orig,
1600 typename sfinae =
typename std::enable_if<point_expression_op<orig,exp1,exp2,op1>::nvals != 1>::type >
1617 template<
typename orig,
1623 typename sfinae =
typename std::enable_if<point_expression_op<orig,exp1,exp2,op1>::nvals == 1>::type >
1640 template<
typename orig,
1646 typename sfinae =
typename std::enable_if<point_expression_op<orig,exp1,exp2,op1>::nvals != 1>::type >
1663 template<
typename orig,
1669 typename check =
typename std::enable_if<point_expression_op<orig,exp1,exp2,op1>::nvals == 1>::type >
1686 template<
typename orig,
typename T,
typename exp1,
typename exp2,
unsigned int op1>
1704 template<
typename orig,
typename exp1,
typename exp2,
unsigned int op1,
typename T>
1722 template<
typename orig,
1733 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,
point_expression_op<orig,exp3,exp4,op2>,POINT_MUL_POINT> exp_sum(va,vb);
1746 template<
typename orig,
1757 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,
point_expression_op<orig,exp3,exp4,op2>,POINT_MUL> exp_sum(va,vb);
1772 template<
unsigned int dim,
typename T>
1789 template<
typename orig,
unsigned int dim,
typename T,
typename exp1,
typename exp2,
unsigned int op1>
1806 template<
typename orig,
unsigned int dim,
typename T,
typename exp1,
typename exp2,
unsigned int op1>
1823 template<
typename orig,
typename exp1,
typename exp2,
unsigned int op1,
typename exp3 ,
typename exp4,
unsigned int op2>
1827 point_expression_op<orig,point_expression_op<orig,exp1,exp2,op1>,
point_expression_op<orig,exp3,exp4,op2>,POINT_MUL> exp_sum(va,vb);
1839 template<
typename T,
unsigned int dim>
1881 template<
typename orig,
typename exp1,
typename exp2,
unsigned int op>
1886 for (
size_t i = 0; i < dim ; i++)
1887 {
d[i] = p_exp.value(i);}
1899 template<
typename T_>
1904 for (
size_t i = 0; i < dim ; i++)
1931 __device__ __host__
inline void init()
const
1944 __device__ __host__
inline T
value(
const size_t k)
const
1957 template<
typename T,
unsigned int dim>
1992 __device__ __host__
inline void init()
const
2013 __device__ __host__
inline T
value(
const size_t k)
const
2025 template<
typename T,
typename vmpl>
2057 template<
typename orig,
typename exp1,
typename exp2,
unsigned int op>
2063 for (
size_t i = 0; i <
nvals ; i++)
2064 {
d[i] = p_exp.value(i);}
2078 template<
unsigned int dim>
2082 for (
size_t i = 0; i <
nvals ; i++)
2083 {
d[i] = point.
get(i);}
2098 template<
typename T2,
unsigned int dim>
2102 for (
size_t i = 0; i <
nvals ; i++)
2103 {
d[i] = point.
get(i);}
2114 :
d(
d.origin_mutable(),
d.strides())
2123 __device__ __host__
inline void init()
const
2156 __device__ __host__
inline T &
value(
const int k)
2170 __device__ __host__
inline T &
value(
const int k)
const
2176 #include "Point_operators_functions.hpp"
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Specialization for an array of dimension dim as expression.
__device__ __host__ point_expression< T[dim]> & operator=(const point_expression_op< orig, exp1, exp2, op > &p_exp)
Operator= for point expression.
__device__ __host__ const T & operator[](int n) const
Array operator.
__device__ __host__ point_expression< T[dim]> & operator=(const point_expression< T_ > &p_exp)
Operator= for point expression.
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__ T & operator[](int n)
Array operator.
__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
Specialization for a const array of dimension dim.
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__ point_expression< openfpm::detail::multi_array::sub_array_openfpm< T, 1, vmpl > > & operator=(const Point< dim, T2 > &point)
operator= for Point object
__device__ __host__ void init() const
This function must be called before value.
__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__ T & value(const int k) const
Evaluate the expression at coordinate k.
int is_expression
indicate that this class encapsulate an expression
__device__ __host__ T & operator[](int k)
Same as value()
__device__ __host__ point_expression< openfpm::detail::multi_array::sub_array_openfpm< T, 1, vmpl > > & operator=(const Point< dim, T > &point)
operator= for Point object
int has_init
indicate that init must be called before value
T coord_type
The type of the internal vector.
__device__ __host__ T & operator[](int k) const
Same as value()
__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)
Evaluate the expression at coordinate k.
__device__ __host__ void init() const
This function must be called before value.
const exp1 o1
expression 1
int is_expression
indicate that this class encapsulate an expression
__device__ __host__ r_type value(size_t k) const
Evaluate the expression.
const exp2 o2
expression 2
__device__ __host__ point_expression_op(const exp1 &o1, const exp2 &o2)
constructor from expression 1 and expression 2
orig orig_type
original type
orig return_type
return type of the expression
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.
const exp1 o1
expression 1
__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
orig return_type
return type of the 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
orig orig_type
origin type
__device__ __host__ point_expression_op(const exp1 &o1, const exp2 &o2)
constructor from 2 expression
const exp2 o2
expression 2
const exp2 o2
second expression
__device__ __host__ point_expression_op(const exp1 &o1, const exp2 &o2)
constructor from 2 expressions
const exp1 o1
first expression
orig::coord_type return_type
return type of the expression
int is_expression
indicate that this class encapsulate an expression
orig orig_type
base type of the 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.
std::remove_const< typename orig::coord_type >::type scal
the expression produce a scalar
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
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
orig return_type
return type of the expression
orig orig_type
Original type.
__device__ __host__ void init() const
This function must be called before value.
const exp2 o2
expression 2
__device__ __host__ point_expression_op(const exp1 &o1, const exp2 &o2)
constructor from 2 expressions
const exp1 o1
expression 1
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
orig orig_type
original type
int has_init
indicate that this class has an init function
__device__ __host__ void init() const
initialize the the expression
int is_expression
indicate that is an 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
const exp1 o1
first 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__ r_type operator[](size_t i)
Get the component i.
__device__ __host__ void init() const
This function must be called before value.
const exp2 o2
second expression
__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__ 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
int is_expression
indicate that this class encapsulate an expression
int has_init
indicate that init must be called before value
__device__ __host__ T & value(const int k)
Evaluate the expression.
__device__ __host__ const T & value(const int k) const
Evaluate the expression.
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data
OutputIteratorT OffsetT ReductionOpT OuputT init
< [in] The initial value of the reduction
convert a type into constant type
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