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

◆ input_truth_table()

MAYAFLUX_API bool MayaFlux::Kinesis::Discrete::input_truth_table ( const std::vector< double > &  inputs,
std::span< const double >  coefs 
)
noexcept

Any boolean function of the input slots, as a table.

coefs: [threshold, arity, outputs...]. The signal counterpart of truth_table: AND, XOR, majority or any other gate of the slots, missing slots read as zero.

Definition at line 323 of file Boolean.cpp.

324{
325 if (coefs.size() < 2)
326 return false;
327
328 const size_t arity = index_of(coefs[1]);
329 if (arity > MAX_TABLE_ARITY || coefs.size() < 2 + (size_t { 1 } << arity))
330 return false;
331
332 size_t pattern = 0;
333 for (size_t i = 0; i < arity && i < inputs.size(); ++i) {
334 if (inputs[i] > coefs[0])
335 pattern |= size_t { 1 } << i;
336 }
337 return coefs[2 + pattern] > 0.5;
338}