◆ iota() [1/2]

template<typename T , typename T1 , typename T2 >
void boost::simd::iota ( T *  first,
T *  last,
T1  seed,
T2  step 
)

Fills the range [first, last) with sequentially increasing values, starting with seed and repetitively evaluating value += step.

Parameters
firstBeginning of the range of elements
lastEnd of the range of elements
seedinitial value to store
stepvalue to add (default to 1)
Requirement
Example:
#include <boost/simd/algorithm/iota.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
#include <vector>
namespace bs = boost::simd;
int main()
{
namespace bs = boost::simd;
std::vector<float> d(16);
d[15] = 42.0f;
bs::iota( d.data(),d.data()+15, 0.1f );
std::cout << "d = (" ;
for( auto e : d) std::cout << e << " ";
std::cout << ") " << std::endl;
bs::iota( d.data(),d.data()+15, 2.0f, 0.5f );
std::cout << "d = (" ;
for( auto e : d) std::cout << e << " ";
std::cout << ") " << std::endl;
return 0;
}
Possible output:
d = (0.1 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 11.1 12.1 13.1 14.1 42 )
d = (2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 42 )