feat: add iir high-pass design routine

This commit is contained in:
2026-05-10 13:04:23 +02:00
parent e8f3021879
commit 555c976df2
2 changed files with 114 additions and 0 deletions

View File

@@ -7,8 +7,11 @@
#include <vector>
#include <deque>
#include <complex>
namespace pd_signal {
using cplx = std::complex<double>;
/** `num` evenly spaced numbers over interval [start,stop] */
void linspace(std::vector<double>& data, double start, double stop, int num);
/** `num` evenly spaced numbers over interval [start,stop] with endpoint=true or [start,stop) with endpoint=false */
@@ -37,6 +40,34 @@ namespace pd_signal {
/** two-dimensional mean of a collection of signals */
void mean(std::vector<double> &out, std::deque<std::vector<double> >& m);
/**
* Convolution of two polynomials given in ASCENDING power order.
* If <c>p = p_0 + p_1 x + ... + p_{P-1} x^{P-1}</c> and likewise for q,
* then <c>out = p * q</c> in ascending power order, of length P+Q-1.
*/
void polymul(std::vector<cplx>& out,
const std::vector<cplx>& p, const std::vector<cplx>& q);
/**
* Build a monic polynomial from its roots:
* <c>(x - r_0) (x - r_1) ... (x - r_{N-1})</c>.
* Returned in DESCENDING power order, i.e. <c>out[0]=1, ..., out[N]</c>
* is the constant term. Length is <c>roots.size() + 1</c>.
*/
void poly(std::vector<cplx>& out, const std::vector<cplx>& roots);
/**
* Design an N-th order Butterworth IIR high-pass digital filter via the
* bilinear transform. The passband is normalized to unit gain at Nyquist.
*
* @param b numerator coefficients in DESCENDING powers of z (length N+1)
* @param a denominator coefficients in DESCENDING powers of z (length N+1)
* @param N filter order (>= 1)
* @param fc cutoff frequency of the digital filter in Hz (0 < fc < fs/2)
* @param fs sampling frequency in Hz
*/
void iirHighpass(std::vector<double>& b, std::vector<double>& a,
int N, double fc, double fs);
}
#endif //PASADASUPERPROJECT_SIGNAL_H