MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ count_at_least()

MAYAFLUX_API bool MayaFlux::Kinesis::Discrete::count_at_least ( std::span< const bool >  history,
std::span< const double >  coefs 
)
noexcept

True when at least k of the last n bits are set.

coefs: [n, k]. Majority, burst detection and k-of-n voting.

Definition at line 62 of file Boolean.cpp.

63{
64 if (coefs.size() < 2)
65 return false;
66
67 const size_t n = std::min(index_of(coefs[0]), history.size());
68 const auto set = static_cast<size_t>(std::count(history.begin(), history.begin() + static_cast<std::ptrdiff_t>(n), true));
69 return set >= index_of(coefs[1]);
70}