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

◆ lagrange_weights()

MAYAFLUX_API void MayaFlux::Kinesis::Discrete::lagrange_weights ( double  delay,
std::span< double >  weights 
)
noexcept

Lagrange interpolation weights written to an array, without allocating.

Parameters
delayPosition between the taps, clamped to [0, taps - 1]
weightsOutput; its size is the number of taps, so order = size - 1

The same weights as lagrange_delay for order = weights.size() - 1, for use per sample.

Definition at line 367 of file Coefficients.cpp.

368{
369 const size_t taps = weights.size();
370 if (taps == 0)
371 return;
372
373 const double d = std::clamp(delay, 0.0, static_cast<double>(taps - 1));
374
375 if (taps > reciprocal_factorial.size()) {
376 for (size_t k = 0; k < taps; ++k) {
377 weights[k] = 1.0;
378 for (size_t j = 0; j < taps; ++j) {
379 if (j == k)
380 continue;
381 weights[k] *= (d - static_cast<double>(j))
382 / (static_cast<double>(k) - static_cast<double>(j));
383 }
384 }
385 return;
386 }
387
388 double before = 1.0;
389 for (size_t k = 0; k < taps; ++k) {
390 weights[k] = before;
391 before *= d - static_cast<double>(k);
392 }
393
394 double after = 1.0;
395 for (size_t k = taps; k-- > 0;) {
396 const size_t rest = taps - 1 - k;
397 const double scale = reciprocal_factorial[k] * reciprocal_factorial[rest];
398 weights[k] *= after * (rest % 2 == 0 ? scale : -scale);
399 after *= d - static_cast<double>(k);
400 }
401}
Tendency< D, float > scale(const Tendency< D, float > &t, float factor)
Uniform scaling of a scalar-output tendency.
Definition Tendency.hpp:98

References delay(), and MayaFlux::Kinesis::scale().

Referenced by lagrange_delay(), and MayaFlux::Buffers::FeedbackProcessor::read_at().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: