#include "leveltrack.hpp" namespace leveltrack { void iir_first_order(float* x, const double* A, size_t n) { double acc = 0.0; for (size_t i = 0; i < n; i++) { double y = static_cast(x[i]) * A[i] + acc; acc = y; x[i] = static_cast(y); } } void iir_bidirectional(float* x, const double* A, size_t n) { iir_first_order(x, A, n); // reverse pass over reversed indices back into x (keep array order). double acc = 0.0; for (size_t k = n; k-- > 0;) { double y = static_cast(x[k]) * A[k] + acc; acc = y; x[k] = static_cast(y); } } void iir_first_order_unrolled4(float* x, const double* A, size_t n) { double acc = 0.0; size_t i = 0; for (; i + 4 <= n;) { for (int u = 0; u < 4; u++, i++) { double y = static_cast(x[i]) * A[i] + acc; acc = y; x[i] = static_cast(y); } } for (; i < n; i++) { double y = static_cast(x[i]) * A[i] + acc; acc = y; x[i] = static_cast(y); } } } // namespace leveltrack