void compute_raised_cosine_filter(double coeffs[], int len, int root, int sinc_compensate, double alpha, double beta) { double f; double x; double f1; double f2; double tau; complex_t vec[SEQ_LEN]; int i; int j; int h; f1 = (1.0 - beta)*alpha; f2 = (1.0 + beta)*alpha; tau = 0.5/alpha; /* (Root) raised cosine */ for (i = 0; i <= SEQ_LEN/2; i++) { f = (double) i/(double) SEQ_LEN; if (f <= f1) vec[i] = complex_set(1.0, 0.0); else if (f <= f2) vec[i] = complex_set(0.5*(1.0 + cos((3.1415926535*tau/beta)*(f - f1))), 0.0); else vec[i] = complex_set(0.0, 0.0); } if (root) { for (i = 0; i <= SEQ_LEN/2; i++) vec[i].re = sqrt(vec[i].re); } if (sinc_compensate) { for (i = 1; i <= SEQ_LEN/2; i++) { x = 3.1415926535*(double) i/(double) SEQ_LEN; vec[i].re *= (x/sin(x)); } } for (i = 0; i <= SEQ_LEN/2; i++) vec[i].re *= tau; for (i = 1; i < SEQ_LEN/2; i++) vec[SEQ_LEN - i] = vec[i]; ifft(vec, SEQ_LEN); h = (len - 1)/2; for (i = 0; i < len; i++) { j = (SEQ_LEN - h + i)%SEQ_LEN; coeffs[i] = vec[j].re/(double) SEQ_LEN; } }
static __inline__ complex_t expj(double theta) { return complex_set(cos(theta), sin(theta)); }