34 #include <cugar/basic/types.h> 35 #include <cugar/basic/iterator.h> 67 template <
typename Iterator, u
int32 SIZE>
70 typedef iterator_traits<Iterator>::reference reference_type;
71 static const uint32 DIM = SIZE;
83 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference_type
operator[](
const uint32 i)
const {
select( r, i ); }
87 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
88 static reference
select(
const Iterator& it,
const uint32 i) {
return it[i]; }
92 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
operator Iterator()
const {
return r; }
102 template <
typename Iterator>
105 typedef iterator_traits<Iterator>::reference reference_type;
106 static const uint32 DIM = 4;
114 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
register_array(
const Iterator& it) : r(it) {}
118 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference_type
operator[](
const uint32 i)
const {
select( r, i ); }
122 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
operator Iterator()
const {
return r; }
126 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
127 static reference
select(
const Iterator& it,
const uint32 i)
129 return i < 2 ? (i == 0 ? it[0] : it[1]) :
130 (i == 2 ? it[2] : it[3]);
141 template <
typename Iterator>
144 typedef iterator_traits<Iterator>::reference reference_type;
145 static const uint32 DIM = 5;
153 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
register_array(
const Iterator& it) : r(it) {}
157 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference_type
operator[](
const uint32 i)
const {
select( r, i ); }
161 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
operator Iterator()
const {
return r; }
165 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
166 static reference
select(
const Iterator& it,
const uint32 i)
168 return i == 4 ? it[4] :
169 i < 2 ? (i == 0 ? it[0] : it[1]) :
170 (i == 2 ? it[2] : it[3]);
181 template <
typename Iterator>
184 typedef iterator_traits<Iterator>::reference reference_type;
185 static const uint32 DIM = 8;
193 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
register_array(
const Iterator& it) : r(it) {}
197 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference_type
operator[](
const uint32 i)
const {
select( r, i ); }
201 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
operator Iterator()
const {
return r; }
205 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
206 static reference
select(
const Iterator& it,
const uint32 i)
209 (i < 2 ? (i == 0 ? it[0] : it[1]) :
210 (i == 2 ? it[2] : it[3])) :
211 (i < 6 ? (i == 4 ? it[4] : it[5]) :
212 (i == 6 ? it[6] : it[7]));
223 template <
typename Iterator>
226 typedef iterator_traits<Iterator>::reference reference_type;
227 static const uint32 DIM = 16;
235 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
register_array(
const Iterator& it) : r(it) {}
239 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference_type
operator[](
const uint32 i)
const {
select( r, i ); }
243 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
operator Iterator()
const {
return r; }
247 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
248 static reference
select(
const Iterator& it,
const uint32 i)
252 (i < 2 ? (i == 0 ? it[0] : it[1]) :
253 (i == 2 ? it[2] : it[3])) :
254 (i < 6 ? (i == 4 ? it[4] : it[5]) :
255 (i == 6 ? it[6] : it[7]))) :
257 (i < 10 ? (i == 8 ? it[8] : it[9]) :
258 (i == 10 ? it[10] : it[11])) :
259 (i < 14 ? (i == 12 ? it[12] : it[13]) :
260 (i == 14 ? it[14] : it[15])));
267 template <u
int32 SIZE,
typename iterator_type>
268 iterator_traits<iterator_type>::reference
dynamic_index(
const iterator_type& T,
const uint32 i)
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE register_array(const Iterator &it)
Definition: register_array.h:193
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE register_array()
Definition: register_array.h:110
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE register_array(const Iterator &it)
Definition: register_array.h:114
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE register_array()
Definition: register_array.h:149
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference_type operator[](const uint32 i) const
Definition: register_array.h:83
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE register_array(Iterator it)
Definition: register_array.h:79
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE register_array()
Definition: register_array.h:75
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference_type operator[](const uint32 i) const
Definition: register_array.h:118
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE register_array(const Iterator &it)
Definition: register_array.h:153
CUGAR_FORCEINLINE static CUGAR_HOST_DEVICE reference select(const Iterator &it, const uint32 i)
Definition: register_array.h:166
CUGAR_FORCEINLINE static CUGAR_HOST_DEVICE reference select(const Iterator &it, const uint32 i)
Definition: register_array.h:88
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE register_array(const Iterator &it)
Definition: register_array.h:235
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference_type operator[](const uint32 i) const
Definition: register_array.h:239
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
Definition: register_array.h:68
CUGAR_FORCEINLINE static CUGAR_HOST_DEVICE reference select(const Iterator &it, const uint32 i)
Definition: register_array.h:248
CUGAR_FORCEINLINE static CUGAR_HOST_DEVICE reference select(const Iterator &it, const uint32 i)
Definition: register_array.h:127
CUGAR_FORCEINLINE static CUGAR_HOST_DEVICE reference select(const Iterator &it, const uint32 i)
Definition: register_array.h:206
iterator_traits< iterator_type >::reference dynamic_index(const iterator_type &T, const uint32 i)
Definition: register_array.h:268
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference_type operator[](const uint32 i) const
Definition: register_array.h:157
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE reference_type operator[](const uint32 i) const
Definition: register_array.h:197
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE register_array()
Definition: register_array.h:231
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE register_array()
Definition: register_array.h:189