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

Functions

template<typename InputIterator , typename T >
void bolt::amp::replace (InputIterator first, InputIterator last, const T &old_value, const T &new_value)
 
template<typename InputIterator , typename T >
void bolt::amp::replace (control &ctl, InputIterator first, InputIterator last, const T &old_value, const T &new_value)
 
template<typename InputIterator , typename Predicate , typename T >
void bolt::amp::replace_if (control &ctl, InputIterator first, InputIterator last, Predicate pred, const T &new_value)
 
template<typename InputIterator , typename Predicate , typename T >
void bolt::amp::replace_if (InputIterator first, InputIterator last, Predicate pred, const T &new_value)
 
template<typename InputIterator1 , typename InputIterator2 , typename Predicate , typename T >
void bolt::amp::replace_if (InputIterator1 first, InputIterator1 last, InputIterator2 stencil, Predicate pred, const T &new_value)
 
template<typename InputIterator1 , typename InputIterator2 , typename Predicate , typename T >
void bolt::amp::replace_if (control &ctl, InputIterator1 first, InputIterator1 last, InputIterator2 stencil, Predicate pred, const T &new_value)
 
template<typename InputIterator , typename OutputIterator , typename Predicate , typename T >
OutputIterator bolt::amp::replace_copy_if (control &ctl, InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T &new_value)
 
template<typename InputIterator , typename OutputIterator , typename Predicate , typename T >
OutputIterator bolt::amp::replace_copy_if (InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T &new_value)
 
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator , typename Predicate , typename T >
OutputIterator bolt::amp::replace_copy_if (control &ctl, InputIterator1 first, InputIterator1 last, InputIterator2 stencil, OutputIterator result, Predicate pred, const T &new_value)
 
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator , typename Predicate , typename T >
OutputIterator bolt::amp::replace_copy_if (InputIterator1 first, InputIterator1 last, InputIterator2 stencil, OutputIterator result, Predicate pred, const T &new_value)
 
template<typename InputIterator , typename OutputIterator , typename T >
OutputIterator bolt::amp::replace_copy (control &ctl, InputIterator first, InputIterator last, OutputIterator result, const T &old_value, const T &new_value)
 
template<typename InputIterator , typename OutputIterator , typename T >
OutputIterator bolt::amp::replace_copy (InputIterator first, InputIterator last, OutputIterator result, const T &old_value, const T &new_value)
 

Detailed Description

Function Documentation

template<typename InputIterator , typename T >
void bolt::amp::replace ( InputIterator  first,
InputIterator  last,
const T &  old_value,
const T &  new_value 
)

This version of replace / replace_if replaces every element in input sequence that is equal to old_value or that which satisfies the predicate with new_value and stores the result in the corresponding position in input sequence itself.

Parameters
ctlOptional Control structure to control accelerator, debug, tuning, etc.See bolt::amp::control.
firstThe beginning of the first input sequence.
lastThe end of the first input sequence.
old_valueThe value present in input sequence that needs to be replaced.
new_valueThe new value to replace.
stencilThe beginning of the stencil sequence.
predThe predicate to test on every value of the range [first,last).
Returns
Nothing. Input itself is modified.
Template Parameters
InputIteratoris a model of InputIterator and InputIterator's value_type is convertible to UnaryFunction's
Tis a model of Assignable.
       The following code snippet demonstrates how to use \p replace and \p replace_if.
int input[10] = {-5, 0, 2, 3, 2, 4, -2, 1, 2, 3};
int stencil[10] = {0, 0, 1, 1, 0, 1, 1, 1, 0, 1};
//Create an AMP Control object using the default accelerator
::Concurrency::accelerator accel(::Concurrency::accelerator::default_accelerator);
bolt::amp::control ctl(accel);
template <typename T>
struct is_even
{
bool operator()(T x) const restrict(amp, cpu)
{
if (((int)x) % 2)
return true;
else
return false;
}
};
bolt::amp::replace(ctl, input, input + 10, 3, 300);
// input is now {-5, 0, 2, 300, 2, 4, -2, 1, 2, 300};
bolt::amp::replace_if(ctl, input, input + 10, is_even<int>(), -7);
// input is now {-5, -7, -7, -7, -7, -7, -7, 1, -7, -7};
bolt::amp::replace_if(ctl, input, input + 10, stencil, bolt::amp::identity<int>(), 10);
// input is now {-5, -7, 10, 10, -7, 10, 10, 10, -7, 10};
See Also
http://www.sgi.com/tech/stl/replace.html
template<typename InputIterator , typename OutputIterator , typename Predicate , typename T >
OutputIterator bolt::amp::replace_copy_if ( control &  ctl,
InputIterator  first,
InputIterator  last,
OutputIterator  result,
Predicate  pred,
const T &  new_value 
)

This version of replace_copy / replace_copy_if copies elements from the range [first, last) to the range [result, result + (last-first)), except that any element equal to old_value or that which satisfies the predicate is not copied; new_value is copied instead.

Parameters
ctlOptional Control structure to control accelerator, debug, tuning, etc.See bolt::amp::control.
firstThe beginning of the first input sequence.
lastThe end of the first input sequence.
OutputIteratoris a model of OutputIterator
old_valueThe value present in input sequence that needs to be replaced.
new_valueThe new value to replace.
predThe predicate to test on every value of the range [first,last).
Returns
Nothing. Input itself is modified.
Template Parameters
InputIteratoris a model of InputIterator and InputIterator's value_type is convertible to UnaryFunction's
Tis a model of Assignable.
       The following code snippet demonstrates how to use \p replace_copy and \p replace_copy_if.
int input[10] = {-5, 0, 2, 3, 2, 4, -2, 1, 2, 3};
int output[10];
//Create an AMP Control object using the default accelerator
::Concurrency::accelerator accel(::Concurrency::accelerator::default_accelerator);
bolt::amp::control ctl(accel);
template <typename T>
struct is_even
{
bool operator()(T x) const restrict(amp, cpu)
{
if (((int)x) % 2)
return true;
else
return false;
}
};
bolt::amp::replace_copy(ctl, input, input + 10, output, 3, 300);
// output is now {-5, 0, 2, 300, 2, 4, -2, 1, 2, 300};
bolt::amp::replace_copy_if(ctl, input, input + 10, output, is_even<int>(), -7);
// output is now {-5, -7, -7, -7, -7, -7, -7, 1, -7, -7};
See Also
http://www.sgi.com/tech/stl/replace.html