3 * Copyright 2002 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
23 #include <qa_gr_firdes.h>
24 #include <gr_firdes.h>
25 #include <cppunit/TestAssert.h>
26 #include <gr_complex.h>
32 #define NELEM(x) (sizeof (x) / sizeof (x[0]))
37 print_taps (std::ostream &s, vector<float> &v)
40 for (unsigned int i = 0; i < v.size (); i++){
41 printf ("tap[%2d] = %16.7e\n", i, v[i]);
46 check_symmetry (vector<float> &v)
51 for (int i = 0; i < m; i++)
52 CPPUNIT_ASSERT_DOUBLES_EQUAL (v[i], v[n - i - 1], 1e-9);
55 const static float t1_exp[53] = {
111 const static float t2_exp[53] = {
167 const static float t3_exp[107] = {
282 gr_firdes::low_pass ( 1.0,
286 gr_firdes::WIN_HAMMING);
288 // cout << "ntaps: " << taps.size () << endl;
289 // print_taps (cout, taps);
291 CPPUNIT_ASSERT_EQUAL (NELEM (t1_exp), taps.size ());
292 for (unsigned int i = 0; i < taps.size (); i++)
293 CPPUNIT_ASSERT_DOUBLES_EQUAL (t1_exp[i], taps[i], 1e-9);
295 check_symmetry (taps);
302 gr_firdes::high_pass ( 1.0,
306 gr_firdes::WIN_HAMMING);
308 // cout << "ntaps: " << taps.size () << endl;
309 // print_taps (cout, taps);
311 CPPUNIT_ASSERT_EQUAL (NELEM (t2_exp), taps.size ());
313 for (unsigned int i = 0; i < taps.size (); i++)
314 CPPUNIT_ASSERT_DOUBLES_EQUAL (t2_exp[i], taps[i], 1e-9);
316 check_symmetry (taps);
323 gr_firdes::band_pass ( 1.0,
328 gr_firdes::WIN_HAMMING);
330 // cout << "ntaps: " << taps.size () << endl;
331 // print_taps (cout, taps);
333 CPPUNIT_ASSERT_EQUAL (NELEM (t3_exp), taps.size ());
335 for (unsigned int i = 0; i < taps.size (); i++)
336 CPPUNIT_ASSERT_DOUBLES_EQUAL (t3_exp[i], taps[i], 1e-7);
338 check_symmetry (taps);