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

◆ galois_lfsr()

MAYAFLUX_API bool MayaFlux::Kinesis::Discrete::galois_lfsr ( double  input,
std::span< double >  coefs 
)
noexcept

Linear feedback shift register clocked by the rises of the input.

coefs: [threshold, latched, taps, register]. Each rise shifts the register right and, when a bit fell out, folds the taps in. The output is the low bit, a pseudo-random bit stream with a period set by the taps.

Definition at line 151 of file Boolean.cpp.

152{
153 if (coefs.size() < 4)
154 return false;
155
156 uint32_t reg = word_of(coefs[3]);
157 if (rises(input > coefs[0], coefs[1])) {
158 if (reg == 0)
159 reg = 1;
160 const bool fell_out = (reg & 1U) != 0U;
161 reg >>= 1U;
162 if (fell_out)
163 reg ^= word_of(coefs[2]);
164 coefs[3] = static_cast<double>(reg);
165 }
166 return (reg & 1U) != 0U;
167}
Core::GlobalInputConfig input
Definition Config.cpp:42

References input.