OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
create_vmpl_sequence.hpp
1/*
2 * mpl_sequence.hpp
3 *
4 * Set of classes to create an mpl::vector with a filled sequence
5 *
6 * Created on: Aug 27, 2014
7 * Author: Pietro Incardona
8 */
9
10#ifndef MPL_SEQUENCE_HPP
11#define MPL_SEQUENCE_HPP
12
13#include <boost/mpl/int.hpp>
14#include <boost/mpl/reverse.hpp>
15
16template<int ...> struct index_tuple_sq{};
17
27template<int c,int end>
28struct exit_impl_sq : boost::mpl::equal_to<boost::mpl::int_<c>,boost::mpl::int_<end>>
29{};
30
39template<int c , int end, bool exit,int ... vars>
41{
42 typedef typename exit_impl_sq<c,end>::type exit_;
43 typedef typename to_variadic_impl<c+1,end,exit_::value,vars ..., c>::type type;
44};
45
46
48template<int c, int end, int ... vars>
49struct to_variadic_impl<c,end,true, vars ...>
50{
51 typedef index_tuple_sq<vars ...> type;
52};
53
68template<unsigned int N, unsigned int M>
70{
73
75 typedef typename to_variadic_impl<N+1,M,exit_::value,N>::type type;
76};
77
78
80
89template<int c , int end, int ele, bool exit,int ... vars>
91{
92 typedef typename exit_impl_sq<c,end-1>::type exit_;
93 typedef typename to_variadic_const_impl<c+1,end,ele,exit_::value,vars ..., ele>::type type;
94};
95
96
98template<int c, int end, int ele, int ... vars>
99struct to_variadic_const_impl<c,end,ele,true, vars ...>
100{
101 typedef boost::mpl::vector<boost::mpl::int_<vars> ...> type;
102};
103
117template<unsigned int N, unsigned int M>
119{
122
124 typedef typename to_variadic_const_impl<1,N,M,exit_::value,M>::type type;
125};
126
128
129template<typename bint, unsigned int ele>
131{
132};
133
134template<int op1, unsigned int ele>
135struct sum_ele<boost::mpl::int_<op1>,ele>
136{
137 typedef boost::mpl::int_<op1+ele> type;
138};
139
140template<unsigned int ele>
141struct sum_ele<boost::mpl::na,ele>
142{
143 typedef boost::mpl::na type;
144};
145
146
147template <unsigned int ele, typename ... vmpl>
149{
151 typedef boost::mpl::vector<typename sum_ele<vmpl,ele>::type ...> type;
152};
153
154template <unsigned int ele, typename vmpl>
156{
157 typedef int type;
158};
170template <unsigned int ele, typename ... vars>
171struct vmpl_sum_constant<ele, boost::mpl::vector<vars ... > >
172{
174 typedef boost::mpl::vector<typename sum_ele<vars,ele>::type ...> type;
175};
176
177
178
180
181template<int c, int accu, int stop, typename vmpl, bool exit>
183{
184 typedef typename exit_impl_sq<c,stop>::type exit_;
185 typedef typename boost::mpl::at<vmpl,boost::mpl::int_<c>>::type ele;
186 typedef typename vmpl_reduce_prod_impl<c+1,accu*ele::value,stop,vmpl,exit_::value>::type type;
187};
188
189
191template<int c, int accu, int stop, typename vmpl>
192struct vmpl_reduce_prod_impl<c,accu,stop,vmpl,true>
193{
194 typedef boost::mpl::int_<accu> type;
195};
196
197
198template<typename vmpl>
200{
201 typedef typename vmpl_reduce_prod_impl<0,1,(int)vmpl::size::value-1,vmpl,false>::type type;
202};
203
204template<typename vmpl, int stop>
206{
207 typedef typename vmpl_reduce_prod_impl<0,1,stop,vmpl,false>::type type;
208};
209
210template<typename vmpl>
212{
213 typedef typename boost::mpl::int_<1> type;
214};
215
217template<typename vmpl, typename a> __device__ __host__ inline unsigned int Lin_vmpl(a v)
218{
219 return v*vmpl_reduce_prod_stop<vmpl,((int)vmpl::size::value) - 2>::type::value;
220}
221
227template<typename vmpl, typename a, typename ...lT>
228__device__ __host__ inline unsigned int Lin_vmpl(a v,lT...t)
229{
230 return v*vmpl_reduce_prod_stop<vmpl,(int)vmpl::size::value - (int)sizeof...(t) - 2>::type::value + Lin_vmpl<vmpl>(t...);
231}
232
234template<typename vmpl, typename vmpl_off, typename a> __device__ __host__ inline unsigned int Lin_vmpl_off(a v)
235{
236 return (v + boost::mpl::at<vmpl_off,boost::mpl::int_< ((int)vmpl::size::value) - 1 > >::type::value )*vmpl_reduce_prod_stop<vmpl,(int)vmpl::size::value - 2>::type::value;
237}
238
244template<typename vmpl, typename vmpl_off, typename a, typename ...lT>
245__device__ __host__ inline unsigned int Lin_vmpl_off(a v,lT...t)
246{
247 return (v + boost::mpl::at<vmpl_off,boost::mpl::int_<((int)vmpl::size::value) - (int)sizeof...(t) - 1> >::type::value)*vmpl_reduce_prod_stop<vmpl,(int)((int)vmpl::size::value - sizeof...(t) - 2)>::type::value + Lin_vmpl_off<vmpl,vmpl_off>(t...);
248}
249
250#endif
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data
Exit condition.
exit_impl_sq< N, M >::type exit_
end condition
to_variadic_impl< N+1, M, exit_::value, N >::type type
generate the boost::fusion::vector apply H on each term
Recursive specialization of to_variadic.
Recursive specialization of to_variadic.
to_variadic_const_impl< 1, N, M, exit_::value, M >::type type
generate the boost::fusion::vector apply H on each term
exit_impl_sq< N, M >::type exit_
end condition
boost::mpl::vector< typename sum_ele< vars, ele >::type ... > type
construct an mpl vector from the variadic
boost::mpl::vector< typename sum_ele< vmpl, ele >::type ... > type
construct an mpl vector from the variadic