23 #include <cusp/detail/config.h>
25 #include <thrust/functional.h>
27 #include <thrust/iterator/counting_iterator.h>
28 #include <thrust/iterator/permutation_iterator.h>
29 #include <thrust/iterator/transform_iterator.h>
38 template<
typename>
struct random_functor_type;
39 template<
typename,
typename>
struct random_integer_functor;
89 typedef size_t difference_type;
90 typedef size_t size_type;
91 typedef thrust::random_access_traversal_tag iterator_category;
93 typedef std::ptrdiff_t IndexType;
94 typedef detail::random_integer_functor<IndexType,T> IndexFunctor;
95 typedef typename thrust::counting_iterator<IndexType> CountingIterator;
96 typedef typename thrust::transform_iterator<IndexFunctor, CountingIterator, IndexType> RandomCountingIterator;
99 typedef typename detail::random_functor_type<T>::type Functor;
100 typedef typename thrust::transform_iterator<Functor, RandomCountingIterator, T> RandomTransformIterator;
101 typedef RandomTransformIterator iterator;
108 : random_counting_iterator(CountingIterator(0), IndexFunctor(seed)) {}
116 return RandomTransformIterator(random_counting_iterator, Functor());
127 return *(
begin() + n);
133 RandomCountingIterator random_counting_iterator;
143 #include <cusp/iterator/detail/random_iterator.inl>
random_iterator(const size_t seed=0)
This constructor builds a random_iterator using a specified seed.
Iterator for generating random values.
iterator begin(void) const
This method returns an iterator pointing to the beginning of this random sequence of entries...
value_type operator[](size_type n) const
Subscript access to the data contained in this iterator.