Bolt  1.3
C++ template library with support for OpenCL
Functions
AMP-generate

Functions

template<typename ForwardIterator , typename Generator >
void bolt::amp::generate (bolt::amp::control &ctl, ForwardIterator first, ForwardIterator last, const Generator &gen)
 generate assigns to each element of a sequence [first,last] the value returned by gen.
 
template<typename ForwardIterator , typename Generator >
void bolt::amp::generate (ForwardIterator first, ForwardIterator last, const Generator &gen)
 
template<typename OutputIterator , typename Size , typename Generator >
OutputIterator bolt::amp::generate_n (bolt::amp::control &ctl, OutputIterator first, Size n, const Generator &gen)
 generate_n assigns to each element of a sequence [first,first+n] the value returned by gen.
 
template<typename OutputIterator , typename Size , typename Generator >
OutputIterator bolt::amp::generate_n (OutputIterator first, Size n, const Generator &gen)
 

Detailed Description

Function Documentation

template<typename ForwardIterator , typename Generator >
void bolt::amp::generate ( bolt::amp::control ctl,
ForwardIterator  first,
ForwardIterator  last,
const Generator &  gen 
)

generate assigns to each element of a sequence [first,last] the value returned by gen.

Parameters
ctlOptional Control structure to control accelerator, debug, tuning, etc.See bolt::amp::control.
firstThe first element of the sequence.
lastThe last element of the sequence.
genA generator, functor taking no parameters.
Template Parameters
ForwardIteratoris a model of Forward Iterator, and ForwardIterator is mutable.
Generatoris a model of Generator, and Generator's result_type is convertible to ForwardIterator's value_type.

The following code snippet demonstrates how to fill a vector with a generator.

#include <stdlib.h>
...
struct ConstFunctor
{
int val;
ConstFunctor(int a) : val(a) {};
int operator() () const restrict(amp,cpu)
{
return val;
};
};
...
ConstFunctor cf(1);
std::vector<int> vec(1024);
bolt::amp::generate( vec.begin(), vec.end(), cf);
// vec is now filled with 1
See Also
http://www.sgi.com/tech/stl/generate.html
template<typename OutputIterator , typename Size , typename Generator >
OutputIterator bolt::amp::generate_n ( bolt::amp::control ctl,
OutputIterator  first,
Size  n,
const Generator &  gen 
)

generate_n assigns to each element of a sequence [first,first+n] the value returned by gen.

Parameters
ctlOptional Control structure to control accelerator, debug, tuning, etc.See bolt::amp::control.
firstThe first element of the sequence.
nThe number of sequence elements to generate.
genA generator, functor taking no parameters.
Template Parameters
OutputIteratoris a model of Output Iterator.
Sizeis an integral type.
Generatoris a model of Generator, and Generator's result_type is convertible to OutputIterator's value_type.

The following code snippet demonstrates how to fill a vector with a generator.

#include <bolt/amp/bolt.h>
#include <stdlib.h>
...
struct ConstFunctor
{
int val;
ConstFunctor(int a) : val(a) {};
int operator() () const restrict(amp,cpu)
{
return val;
};
};
...
ConstFunctor cf(1);
std::vector<int> vec(1024);
int n = 1024;
bolt::amp::generate_n(vec.begin(), n, cf);
// vec is now filled with 1
See Also
http://www.sgi.com/tech/stl/generate_n.html