24#include <cusp/detail/config.h>
26#include <cusp/memory.h>
27#include <cusp/detail/format.h>
28#include <cusp/exception.h>
32#include <thrust/copy.h>
33#include <thrust/host_vector.h>
34#include <thrust/device_vector.h>
35#include <thrust/detail/vector_base.h>
36#include <thrust/iterator/constant_iterator.h>
37#include <thrust/iterator/counting_iterator.h>
43template <
typename RandomAccessIterator>
class array1d_view;
97template <
typename T,
typename MemorySpace>
98class array1d :
public thrust::detail::vector_base<T, typename cusp::default_memory_allocator<T, MemorySpace>::type>
101 typedef typename cusp::default_memory_allocator<T, MemorySpace>::type Alloc;
102 typedef typename thrust::detail::vector_base<T,Alloc> Parent;
106 typedef MemorySpace memory_space;
107 typedef cusp::array1d_format format;
109 typedef typename Parent::iterator iterator;
110 typedef typename Parent::const_iterator const_iterator;
111 typedef typename Parent::value_type value_type;
112 typedef typename Parent::size_type size_type;
118 template<
typename MemorySpace2>
141 explicit array1d(size_type n,
const value_type &value)
142 : Parent(n, value) {}
154 { Parent::operator=(v);
return *
this; }
161 template<
typename OtherT,
typename OtherMem>
170 template<
typename OtherT,
typename OtherMem>
172 { Parent::operator=(v);
return *
this; }
179 template<
typename OtherT,
typename OtherAlloc>
180 array1d(
const std::vector<OtherT, OtherAlloc> &v)
188 template<
typename OtherT,
typename OtherAlloc>
190 { Parent::operator=(v);
return *
this; }
197 template<
typename OtherT,
typename OtherAlloc>
198 array1d(
const thrust::host_vector<OtherT, OtherAlloc> &v)
206 template<
typename OtherT,
typename OtherAlloc>
208 { Parent::operator=(v);
return *
this; }
215 template<
typename OtherT,
typename OtherAlloc>
216 array1d(
const thrust::device_vector<OtherT, OtherAlloc> &v)
224 template<
typename OtherT,
typename OtherAlloc>
226 { Parent::operator=(v);
return *
this; }
233 template<
typename InputIterator>
234 array1d(InputIterator first, InputIterator last)
235 : Parent(first, last) {}
241 template<
typename InputIterator>
243 : Parent(v.begin(), v.end()) {}
275 view
subarray(size_type start_index, size_type num_entries);
307 const_view
subarray(size_type start_index, size_type num_entries)
const;
360template<
typename RandomAccessIterator>
361class array1d_view :
public thrust::iterator_adaptor<array1d_view<RandomAccessIterator>, RandomAccessIterator>
364 typedef thrust::iterator_adaptor<array1d_view<RandomAccessIterator>, RandomAccessIterator> Parent;
365 typedef typename thrust::iterator_system<RandomAccessIterator>::type space;
367 friend class thrust::iterator_core_access;
372 typedef RandomAccessIterator iterator;
373 typedef cusp::array1d_format format;
375 typedef typename cusp::iterator_system<space>::type memory_space;
376 typedef typename ::cuda::std::iterator_traits<RandomAccessIterator>::value_type value_type;
377 typedef typename ::cuda::std::iterator_traits<RandomAccessIterator>::pointer pointer;
378 typedef typename ::cuda::std::iterator_traits<RandomAccessIterator>::reference reference;
379 typedef typename ::cuda::std::iterator_traits<RandomAccessIterator>::difference_type difference_type;
381 typedef size_t size_type;
388 typedef RandomAccessIterator const_iterator;
401 template<
typename ArrayType>
409 template<
typename InputIterator>
510 view
subarray(size_type start_index, size_type num_entries);
563template <
typename ValueType>
574 typedef typename Parent::iterator iterator;
575 typedef typename Parent::size_type size_type;
584 :
Parent(iterator(init), iterator(init) +
size) {}
613template <
typename ValueType>
624 typedef typename Parent::iterator iterator;
625 typedef typename Parent::size_type size_type;
634 :
Parent(iterator(value), iterator(value) +
size) {}
661template <
typename ValueType>
673 typedef typename Parent::size_type size_type;
694template <
typename Iterator>
710template <
typename T,
typename MemorySpace>
723template <
typename Iterator>
736template <
typename Iterator>
750template <
typename T,
typename MemorySpace>
760#include <cusp/detail/array1d.inl>
The array1d_view class is a 1D vector container that wraps data from various iterators in a array1d d...
void swap(array1d_view &v)
view subarray(size_type start_index, size_type num_entries)
array1d_view & operator=(const array1d_view &v)
size_type size(void) const
reference back(void) const
size_type capacity(void) const
array1d_view(InputIterator begin, InputIterator end)
array1d_view(ArrayType &v)
reference front(void) const
reference operator[](size_type n) const
Subscript access to the data contained in this array1d_view.
iterator begin(void) const
void resize(size_type new_size)
Resizes this array1d_view to the specified number of elements.
The array1d class is a 1D vector container that may contain elements stored in "host" or "device" mem...
array1d(const thrust::device_vector< OtherT, OtherAlloc > &v)
array1d(const array1d &v)
array1d(const std::vector< OtherT, OtherAlloc > &v)
array1d & operator=(const array1d &v)
array1d(InputIterator first, InputIterator last)
array1d(const array1d_view< InputIterator > &v)
view subarray(size_type start_index, size_type num_entries)
array1d & operator=(const thrust::device_vector< OtherT, OtherAlloc > &v)
const_view subarray(size_type start_index, size_type num_entries) const
array1d(size_type n, const value_type &value)
array1d(const array1d< OtherT, OtherMem > &v)
array1d(const thrust::host_vector< OtherT, OtherAlloc > &v)
array1d & operator=(const thrust::host_vector< OtherT, OtherAlloc > &v)
array1d & operator=(const array1d< OtherT, OtherMem > &v)
array1d & operator=(const std::vector< OtherT, OtherAlloc > &v)
Specialized array1d_view wrapping thrust::constant_iterator.
constant_array(size_type size, ValueType value)
Specialized array1d_view wrapping thrust::counting_iterator.
counting_array(size_type size, ValueType init=ValueType(0))
Specialized array1d_view wrapping cusp::random_iterator.
random_array(size_type size, size_type seed=0)
Iterator for generating random values.
array1d_view< Iterator > make_array1d_view(Iterator first, Iterator last)
An iterator which generates random entries.