◆ reduce() [1/2]

template<typename T >
T boost::simd::reduce ( T const *  first,
T const *  last,

Computes the sum over elements in the given Contiguous Range [first, last[ and the initial value init.

The summation order can be different from the order of a sequential summation , thus leading to different results.
#include <boost/simd/algorithm/reduce.hpp>
#include <iostream>
#include <numeric>
int main()
float values[] = {1.f,2.f,3.f,4.f,5.f,6.f,7.f,8.f,9.f,};
std::cout << "SIMD reduce :" << boost::simd::reduce(&values[0],&values[0]+9, 0.f) << std::endl;
std::cout << "STD accumulate:" << std::accumulate(&values[0],&values[0]+9, 0.f) << std::endl;
return 0;
Possible output:
SIMD reduce : 45
STD accumulate : 45
firstBeginning of the range of elements to sum
lastEnd of the range of elements to sum
initInitial value of the sum
The sum of the given value and elements in the given range.