8#ifndef MULTI_ARRAY_REF_OPENFPM_BASE_HPP_
9#define MULTI_ARRAY_REF_OPENFPM_BASE_HPP_
12#include <boost/mpl/size_t.hpp>
13#include "boost/iterator/reverse_iterator.hpp"
14#include "storage_order.hpp"
15#include <boost/mpl/at.hpp>
16#include <boost/mpl/size.hpp>
17#include <boost/mpl/pop_front.hpp>
18#include <boost/type.hpp>
30template <
typename T,
int NumDims,
typename vector>
31class multi_array_ref_openfpm;
34namespace multi_array_types
36 typedef openfpm::detail::multi_array::size_type size_type;
37 typedef std::ptrdiff_t difference_type;
38 typedef openfpm::detail::multi_array::index index;
45template <
typename T, std::
size_t NumDims,
typename vector>
46class sub_array_openfpm;
48template <
typename T, std::
size_t NumDims,
typename vector,
typename TPtr = const T*>
49class const_sub_array_openfpm;
51 template <
typename T,
typename TPtr,
typename NumDims,
typename vector,
typename Reference,
52 typename IteratorCategory>
53class array_iterator_openfpm;
55template <
typename T, std::
size_t NumDims,
typename TPtr = const T*>
56class const_multi_array_view_openfpm;
58template <
typename T, std::
size_t NumDims>
59class multi_array_view_openfpm;
69 typedef multi_array_types::size_type size_type;
70 typedef multi_array_types::difference_type difference_type;
71 typedef multi_array_types::index index;
79template<
typename T, std::
size_t NumDims,
typename vector>
84 typedef typename super_type::index index;
97 template <
typename Reference,
typename TPtr>
98 __device__ __host__
inline Reference access(boost::type<Reference>,
100 const index* strides,
103 TPtr newbase = base + idx * strides[0];
104 return Reference(newbase,strides+1);
111template <
class T>
inline __device__ __host__
void ignore_unused_variable_warning_ofp(T
const&) {}
118template<
typename T,
typename vector>
123 typedef typename super_type::index index;
128 typedef T value_type;
129 typedef T& reference;
130 typedef T
const& const_reference;
135 template <
typename Reference,
typename TPtr>
136 inline __device__ __host__ Reference access(boost::type<Reference>,index idx,
137 const index* strides,
140 return *(base + idx * strides[0]);
144 template <
typename Reference,
typename TPtr>
145 inline __device__ __host__ Reference access(boost::type<Reference>,index idx,TPtr base,
const index* strides)
const
147 BOOST_ASSERT(size_type(idx < boost::mpl::at<
vector,boost::mpl::int_<0>>::type::value));
148 return *(base + idx * strides[0]);
160template <
typename T, std::
size_t NumDims,
typename vector>
166template <
typename T,
typename vector>
172template <
typename T,
typename NumDims,
typename vector>
175 BOOST_STATIC_CONSTANT(std::size_t, dimensionality = NumDims::value);
178 boost::mpl::eval_if_c<(dimensionality == 1),
185template <
class T,
class NumDims,
typename vector>
197#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
198struct mutable_iterator_tag
199 : boost::random_access_traversal_tag, std::input_iterator_tag
201 operator std::output_iterator_tag()
const {
202 return std::output_iterator_tag();
211template <
typename T, std::
size_t NumDims,
typename vector>
217 typedef typename types::index index;
218 typedef typename types::size_type size_type;
219 typedef typename types::element element;
220 typedef typename types::value_type value_type;
221 typedef typename types::reference reference;
222 typedef typename types::const_reference const_reference;
224 template <std::
size_t NDims>
230 template <std::
size_t NDims>
236 template <std::
size_t NDims>
242 template <std::
size_t NDims>
249#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
255 boost::random_access_traversal_tag>
iterator;
260 typedef ::boost::reverse_iterator<iterator> reverse_iterator;
261 typedef ::boost::reverse_iterator<const_iterator> const_reverse_iterator;
263 BOOST_STATIC_CONSTANT(std::size_t, dimensionality = NumDims);
271 template <
typename Str
ide_list,
typename Extent_type>
272 void compute_strides(Stride_list& stride_list, Extent_type& extent,
277 for (size_type n = 0; n != NumDims; ++n)
281 stride_list[storage.ordering(n)] = stride;
283 if (storage.ordering(n) == 0)
287 switch(storage.ordering(n))
340 template <
typename Reference,
typename IndexList,
typename TPtr>
341 Reference access_element(boost::type<Reference>,
342 const IndexList& indices,
344 const size_type* extents,
345 const index* strides,
346 const index* index_bases)
const
348 boost::function_requires<
349 boost::CollectionConcept<IndexList> >();
350 ignore_unused_variable_warning(index_bases);
351 ignore_unused_variable_warning(extents);
353 for (size_type i = 0; i != NumDims; ++i)
355 BOOST_ASSERT(indices[i] - index_bases[i] >= 0);
356 BOOST_ASSERT(size_type(indices[i] - index_bases[i]) < extents[i]);
362 typename IndexList::const_iterator i = indices.begin();
366 offset += (*i) * strides[n];
This class is a trick to indicate the compiler a specific specialization pattern.
Implementation of 1-D std::vector like structure.
convert a type into constant type