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

◆ weighted_sum()

MAYAFLUX_API double MayaFlux::Kinesis::Discrete::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.

The linear case: FIR taps in a feedforward window, feedback weights in a recursive one, or the output of any generator in Coefficients.

Definition at line 98 of file Kernels.cpp.

99{
100 const size_t count = std::min(window.size(), coefs.size());
101 const double* a = window.data();
102 const double* b = coefs.data();
103
104 double s0 = 0.0;
105 double s1 = 0.0;
106 double s2 = 0.0;
107 double s3 = 0.0;
108 size_t k = 0;
109 for (; k + 4 <= count; k += 4) {
110 s0 += a[k] * b[k];
111 s1 += a[k + 1] * b[k + 1];
112 s2 += a[k + 2] * b[k + 2];
113 s3 += a[k + 3] * b[k + 3];
114 }
115
116 double tail = 0.0;
117 for (; k < count; ++k)
118 tail += a[k] * b[k];
119 return ((s0 + s1) + (s2 + s3)) + tail;
120}
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
size_t a
size_t b
size_t count

References a, b, count, and window.

Referenced by lotka_volterra_step(), modular_recurrence(), and rotor_bank().

+ Here is the caller graph for this function: