@@ -13,37 +13,31 @@ inline std::complex<float_type> expj(float_type x) { return (std::complex<float_
1313inline float_type coshin (float_type x) { return (log (x + sqrt (x * x - 1 .))); }
1414
1515void real_dft (std::vector<float_type>& y, int n) {
16- int j, l;
17- /* n inverse dft length */
1816 std::vector<float_type> x (n);
1917
2018 /* calculate the w values recursively */
21- for (j = 0 ; j < n; j++) { x[j] = y[j]; }
19+ for (int j = 0 ; j < n; j++) { x[j] = y[j]; }
2220
2321 /* start inverse fft */
24- for (l = 0 ; l < n; l++) {
22+ for (int l = 0 ; l < n; l++) {
2523 y[l] = 0 ;
26- for (j = 0 ; j < n; j++) {
24+ for (int j = 0 ; j < n; j++) {
2725 y[l] += x[j] * cos (TWOPI * l * j / (n));
2826 }
2927 }
3028}
3129
3230void real_dft (std::vector<std::complex <float_type>>& y, int n) {
33- int j, l;
34- /* n inverse dft length */
35- std::vector<std::complex <float_type> > x (n + 1 );
31+ std::vector<std::complex <float_type> > x (n);
3632 std::complex <float_type> mult;
3733
3834 /* calculate the w values recursively */
39- for (j = 0 ; j < n; j++) {
40- x[j] = y[j];
41- }
35+ for (int j = 0 ; j < n; j++) { x[j] = y[j];}
4236
4337 /* start inverse fft */
44- for (l = 0 ; l < n; l++) {
38+ for (int l = 0 ; l < n; l++) {
4539 y[l] = 0 ;
46- for (j = 0 ; j < n; j++) {
40+ for (int j = 0 ; j < n; j++) {
4741 mult = x[j] * std::complex <float_type>(cos (TWOPI*l*j/n),sin (TWOPI*l*j/n));
4842 y[l] += mult;
4943 }
@@ -141,22 +135,22 @@ float_type kaiser_beta(float_type ripple) {
141135 float_type A = -20.0 *log10 (ripple);
142136 float_type beta = (A>50 ) ? (0.1102 *(A-8.7 )) :
143137 ((A<=21 ) ? 0.0 : (0.5842 *pow (A-21.0 ,0.4 ) + 0.07886 *(A-21.0 )));
144- return beta;
138+ return beta;
145139}
146140// ! \ingroup fir
147141// ! \brief kaiser window
148142std::vector<float_type> kaiser (long nf, float_type beta) {
149- // nf = filter length in samples
150- // beta = parameter of kaiser window
151- std::vector<float_type> w (nf);
152- float_type bes = 1.0 / io (beta);
153- for (int i = 0 ; i < nf; i++) {
154- float xi = i - nf/2.0 + 0.5 ;
143+ // nf = filter length in samples
144+ // beta = parameter of kaiser window
145+ std::vector<float_type> w (nf);
146+ float_type bes = 1.0 / io (beta);
147+ for (int i = 0 ; i < nf; i++) {
148+ float_type xi = i - nf/2.0 + 0.5 ;
155149 float_type bm = (2.0 *xi/(nf - 1 ));
156- float_type val = io (beta * sqrt (1 . - bm*bm)) * bes;
157- w[i] = val;
158- }
159- return (w);
150+ float_type val = io (beta * sqrt (1 . - bm*bm)) * bes;
151+ w[i] = val;
152+ }
153+ return (w);
160154}
161155float_type cheby_poly (int m, float_type a) {
162156 float_type x;
0 commit comments