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

◆ modular_recurrence()

MAYAFLUX_API double MayaFlux::Kinesis::Discrete::modular_recurrence ( std::span< const double >  window,
std::span< const double >  coefs 
)
noexcept

Weighted sum wrapped into [0, modulus).

coefs: [modulus, weights...]. In a recursive Polynomial the weights act on the last outputs, which is a lagged-Fibonacci style recurrence with the structure the weights and modulus give it. A modulus of zero or less leaves the sum unwrapped.

Definition at line 474 of file Kernels.cpp.

475{
476 if (coefs.empty())
477 return 0.0;
478
479 const double sum = weighted_sum(window, coefs.subspan(1));
480 const double modulus = coefs.front();
481 if (modulus <= 0.0)
482 return sum;
483 return wrap(sum, 0.0, modulus);
484}
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
std::vector< double > sum(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Sum per window.
Definition Analysis.cpp:469
double weighted_sum(std::span< const double > window, std::span< const double > coefs) noexcept
Sum of window[k] * coefs[k] over the shorter of the two.
Definition Kernels.cpp:98
T wrap(T x, T lo, T hi) noexcept
Wrap x into [lo, hi) with modulo semantics.
Definition Scalar.hpp:218

References sum(), weighted_sum(), window, and MayaFlux::Kinesis::wrap().

+ Here is the call graph for this function: