◆ min_val() [2/2]

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

Returns the value of the element with the smallest value in the range [first,last), The largest possible value for the order if the range is empty.

Parameters
firstBeginning of the range of elements to min_val
lastEnd of the range of elements to min_val
Requirement
Example

The following code uses simd::min_val to find the greatest and smallest element std::vector.

#include <boost/simd/algorithm/min_val.hpp>
#include <boost/simd/function/is_greater.hpp>
#include <iostream>
#include <vector>
int main()
{
namespace bs = boost::simd;
std::vector<float> d{ 0.0f, 2.0f, 0.0f, 0.0f, -1.0f, 2.0f, 0.0f};
auto r1 = bs::min_val( d.data(), d.data()+7);
std::cout << "r1 " << r1<< "\n";
auto r2 = bs::min_val( d.data(), d.data()+7, bs::is_greater);
std::cout << "r2 " << r2 << "\n";
return 0;
}
r1 -1
r2 2
Returns
the minimum value of the range elements.