◆ nbtrue()

std::size_t boost::simd::nbtrue ( Value const &  x)

This function object returns the number of non Zero elements of the argument.

Header <boost/simd/function/nbtrue.hpp>
Note

This function is peculiarly useful in horizontal branching idioms.

Example:
#include <boost/simd/pack.hpp>
#include <boost/simd/reduction.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack<float, 4>;
int main() {
pack_ft pf = {1.0f, 0.0f, -1.0f, 0.5f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::nbtrue(pf) = " << bs::nbtrue(pf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 0, -1, 0.5)
-> bs::nbtrue(pf) = 3