|
template<typename InputIterator , typename OutputType > |
OutputType | bolt::amp::inner_product (bolt::amp::control &ctl, InputIterator first1, InputIterator last1, InputIterator first2, OutputType init) |
| Inner Product returns the inner product of two iterators. This is similar to calculating binary transform and then reducing the result. The inner_product operation is similar the std::inner_product function. This function can take optional control structure to control command-queue.
|
|
template<typename InputIterator , typename OutputType > |
OutputType | bolt::amp::inner_product (InputIterator first1, InputIterator last1, InputIterator first2, OutputType init) |
|
template<typename InputIterator , typename OutputType , typename BinaryFunction1 , typename BinaryFunction2 > |
OutputType | bolt::amp::inner_product (bolt::amp::control &ctl, InputIterator first1, InputIterator last1, InputIterator first2, OutputType init, BinaryFunction1 f1, BinaryFunction2 f2) |
| Inner Product returns the inner product of two iterators using user specified binary functors f1 and f2. This is similar to calculating transform and then reducing the result. The functor f1 should be commutative. This function can take optional control structure to control command-queue. The inner_product operation is similar the std::inner_product function.
|
|
template<typename InputIterator , typename OutputType , typename BinaryFunction1 , typename BinaryFunction2 > |
OutputType | bolt::amp::inner_product (InputIterator first1, InputIterator last1, InputIterator first2, OutputType init, BinaryFunction1 f1, BinaryFunction2 f2) |
|
template<typename InputIterator , typename OutputType >
OutputType bolt::amp::inner_product |
( |
bolt::amp::control & |
ctl, |
|
|
InputIterator |
first1, |
|
|
InputIterator |
last1, |
|
|
InputIterator |
first2, |
|
|
OutputType |
init |
|
) |
| |
Inner Product returns the inner product of two iterators. This is similar to calculating binary transform and then reducing the result. The inner_product
operation is similar the std::inner_product function. This function can take optional control
structure to control command-queue.
- Parameters
-
ctl | Optional Control structure to control accelerator, debug, tuning, etc.See bolt::amp::control. |
first1 | The beginning of input sequence. |
last1 | The end of input sequence. |
first2 | The beginning of the second input sequence. |
init | The initial value for the accumulator. |
- Template Parameters
-
InputIterator | An iterator that can be dereferenced for an object, and can be incremented to get to the next element in a sequence. |
OutputType | The type of the result. |
- Returns
- The result of the inner product.
The following code example shows the use of inner_product
to perform dot product on two vectors of size 10 , using the default multiplies and plus operator.
int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int b[10] = {1, 1, 2, 3, 5, 8, 13, 21, 34, 55};
- See Also
- http://www.sgi.com/tech/stl/inner_product.html
template<typename InputIterator , typename OutputType , typename BinaryFunction1 , typename BinaryFunction2 >
OutputType bolt::amp::inner_product |
( |
bolt::amp::control & |
ctl, |
|
|
InputIterator |
first1, |
|
|
InputIterator |
last1, |
|
|
InputIterator |
first2, |
|
|
OutputType |
init, |
|
|
BinaryFunction1 |
f1, |
|
|
BinaryFunction2 |
f2 |
|
) |
| |
Inner Product returns the inner product of two iterators using user specified binary functors f1 and f2. This is similar to calculating transform and then reducing the result. The functor f1 should be commutative. This function can take optional control
structure to control command-queue. The inner_product
operation is similar the std::inner_product function.
- Parameters
-
ctl | Control structure to control accelerator, debug, tuning, etc.See bolt::amp::control. |
first1 | The first position in the input sequence. |
last1 | The last position in the input sequence. |
first2 | The beginning of second input sequence. |
init | The initial value for the accumulator. |
f1 | Binary functor for reduction. |
f2 | Binary functor for transformation. |
- Template Parameters
-
InputIterator | An iterator that can be dereferenced for an object, and can be incremented to get to the next element in a sequence. |
OutputType | The type of the result. |
- Returns
- The result of the inner product.
The following code example shows the use of inner_product
on two vectors of size 10, using the user defined functors.
int a[10] = {-5, 0, 2, 3, 2, 4, -2, 1, 2, 3};
int b[10] = {-5, 0, 2, 3, 2, 4, -2, 1, 2, 3};
- See Also
- http://www.sgi.com/tech/stl/inner_product.html