     indices[3] = 7;
    
     // construct transform_iterator
-    thrust::permutation_iterator<Iterator, Iterator> iter(input.begin(), indices.begin());
+    thrust::permutation_iterator<Iterator, Iterator> iter(source.begin(), indices.begin());
 
     thrust::copy(thrust::make_permutation_iterator(source.begin(), indices.begin()),
                  thrust::make_permutation_iterator(source.begin(), indices.begin()) + 4,

#include <thrusttest/unittest.h>
#include <thrust/iterator/permutation_iterator.h>

#include <thrust/copy.h>
#include <thrust/reduce.h>
#include <thrust/sequence.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>

template <class Vector>
void TestPermutationIterator(void)

    indices[3] = 7;
   
    // construct transform_iterator
    thrust::permutation_iterator<Iterator, Iterator> p_source(source.begin(), indices.begin());

    // copy from source to output
    thrust::copy(p_source, p_source + 4, output.begin());

    ASSERT_EQUAL(output[0], 4);
    ASSERT_EQUAL(output[1], 1);
    ASSERT_EQUAL(output[2], 6);
    ASSERT_EQUAL(output[3], 8);
    
    // copy from output to source
    thrust::fill(output.begin(), output.end(), 10);
    thrust::copy(output.begin(), output.end(), p_source);

    ASSERT_EQUAL(source[0], 10);
    ASSERT_EQUAL(source[1],  2);
    ASSERT_EQUAL(source[2],  3);
    ASSERT_EQUAL(source[3], 10);
    ASSERT_EQUAL(source[4],  5);
    ASSERT_EQUAL(source[5], 10);
    ASSERT_EQUAL(source[6],  7);
    ASSERT_EQUAL(source[7], 10);
}
DECLARE_VECTOR_UNITTEST(TestPermutationIterator);

