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

◆ rotor_bank()

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

Sum of N sinusoids advanced by complex rotation instead of a sine call.

Each call rotates every unit phasor by its increment and returns the sum of scale * imaginary part, which is sin(phase) after the advance. A first order correction keeps the phasors on the unit circle, so the amplitude does not drift over long runs. Cheaper than phasor_bank per sinusoid, with no slow amplitude swell: scale the array's scales column for that.

Definition at line 219 of file Kernels.cpp.

220{
221 if (coefs.empty())
222 return 0.0;
223
224 const auto n = static_cast<size_t>(std::max(coefs.front(), 0.0));
225 if (n == 0 || coefs.size() < 1 + 5 * n)
226 return 0.0;
227
228 const auto cos_step = coefs.subspan(1, n);
229 const auto sin_step = coefs.subspan(1 + n, n);
230 const auto scales = coefs.subspan(1 + 2 * n, n);
231 const auto re = coefs.subspan(1 + 3 * n, n);
232 const auto im = coefs.subspan(1 + 4 * n, n);
233
234 rotate_rotors(cos_step.data(), sin_step.data(), re.data(), im.data(), n);
235 return weighted_sum(scales, im);
236}
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

References weighted_sum().

+ Here is the call graph for this function: