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>
97 template <
typename T,
typename MemorySpace>
98 class 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;
360 template<
typename RandomAccessIterator>
361 class array1d_view :
public thrust::iterator_adaptor<array1d_view<RandomAccessIterator>, RandomAccessIterator>
364 typedef thrust::iterator_adaptor<array1d_view<RandomAccessIterator>, RandomAccessIterator> Parent;
366 friend class thrust::iterator_core_access;
371 typedef RandomAccessIterator iterator;
372 typedef cusp::array1d_format format;
374 typedef typename thrust::iterator_value<RandomAccessIterator>::type value_type;
375 typedef typename thrust::iterator_system<RandomAccessIterator>::type memory_space;
376 typedef typename thrust::iterator_pointer<RandomAccessIterator>::type pointer;
377 typedef typename thrust::iterator_reference<RandomAccessIterator>::type reference;
378 typedef typename thrust::iterator_difference<RandomAccessIterator>::type difference_type;
380 typedef size_t size_type;
387 typedef RandomAccessIterator const_iterator;
400 template<
typename ArrayType>
408 template<
typename InputIterator>
422 reference
front(
void)
const;
428 reference
back(
void)
const;
444 iterator
begin(
void)
const;
450 iterator
end(
void)
const;
454 size_type
size(
void)
const;
476 void resize(size_type new_size);
509 view
subarray(size_type start_index, size_type num_entries);
562 template <
typename ValueType>
573 typedef typename Parent::iterator iterator;
574 typedef typename Parent::size_type size_type;
583 :
Parent(iterator(init), iterator(init) + size) {}
612 template <
typename ValueType>
623 typedef typename Parent::iterator iterator;
624 typedef typename Parent::size_type size_type;
633 :
Parent(iterator(value), iterator(value) + size) {}
660 template <
typename ValueType>
672 typedef typename Parent::size_type size_type;
693 template <
typename Iterator>
709 template <
typename T,
typename MemorySpace>
722 template <
typename Iterator>
735 template <
typename Iterator>
749 template <
typename T,
typename MemorySpace>
759 #include <cusp/detail/array1d.inl>
reference front(void) const
The array1d class is a 1D vector container that may contain elements stored in "host" or "device" mem...
view subarray(size_type start_index, size_type num_entries)
array1d & operator=(const thrust::device_vector< OtherT, OtherAlloc > &v)
array1d(const array1d &v)
array1d(size_type n, const value_type &value)
The array1d_view class is a 1D vector container that wraps data from various iterators in a array1d d...
array1d(const array1d_view< InputIterator > &v)
array1d_view & operator=(const array1d_view &v)
size_type size(void) const
array1d(const std::vector< OtherT, OtherAlloc > &v)
void swap(array1d_view &v)
reference operator[](size_type n) const
Subscript access to the data contained in this array1d_view.
array1d(const thrust::device_vector< OtherT, OtherAlloc > &v)
counting_array(size_type size, ValueType init=ValueType(0))
constant_array(size_type size, ValueType value)
array1d & operator=(const thrust::host_vector< OtherT, OtherAlloc > &v)
Iterator for generating random values.
array1d< T, MemorySpace >::const_view make_array1d_view(const array1d< T, MemorySpace > &v)
array1d(InputIterator first, InputIterator last)
size_type capacity(void) const
reference back(void) const
array1d(const thrust::host_vector< OtherT, OtherAlloc > &v)
array1d & operator=(const array1d &v)
iterator begin(void) const
An iterator which generates random entries.
void resize(size_type new_size)
Resizes this array1d_view to the specified number of elements.
Specialized array1d_view wrapping thrust::constant_iterator.
random_array(size_type size, size_type seed=0)
array1d(const array1d< OtherT, OtherMem > &v)
array1d & operator=(const array1d< OtherT, OtherMem > &v)
view subarray(size_type start_index, size_type num_entries)
array1d & operator=(const std::vector< OtherT, OtherAlloc > &v)
Specialized array1d_view wrapping thrust::counting_iterator.
Specialized array1d_view wrapping cusp::random_iterator.