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

◆ polynomial_lags()

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

Polynomial in several lags at once.

coefs: [L, P, C...] with L lags and highest power P, then (P + 1) numbers per lag, lag-major and power-ascending. The result is the sum over lags k and powers j of C[k][j] * window[k]^j. Power zero is a constant, so a bias is C[0][0]. In a recursive Polynomial this is any nonlinear difference equation of the last L outputs: Henon is lags 0, 1, 2 with C[0][0] = 1, C[1][2] = -a, C[2][1] = b. Lags beyond the window are skipped; an array shorter than its header gives zero.

Definition at line 268 of file Kernels.cpp.

269{
270 if (coefs.size() < 2)
271 return 0.0;
272
273 const auto lags = static_cast<size_t>(std::max(coefs[0], 0.0));
274 const auto powers = static_cast<size_t>(std::max(coefs[1], 0.0)) + 1;
275 if (coefs.size() < 2 + lags * powers)
276 return 0.0;
277
278 double sum = 0.0;
279 const size_t reach = std::min(lags, window.size());
280 for (size_t k = 0; k < reach; ++k) {
281 const double w = window[k];
282 double power = 1.0;
283 for (size_t j = 0; j < powers; ++j) {
284 sum += coefs[2 + k * powers + j] * power;
285 power *= w;
286 }
287 }
288 return sum;
289}
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
std::vector< double > power(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Power (sum of squares) per window.
Definition Analysis.cpp:70

References power(), sum(), and window.

+ Here is the call graph for this function: