Changeset 9384
- Timestamp:
- 08/23/08 15:26:19
- Files:
-
- gnuradio/trunk/gnuradio-core/src/lib/filter/Makefile.am (modified) (2 diffs)
- gnuradio/trunk/gnuradio-core/src/lib/filter/gr_rotator.h (modified) (2 diffs)
- gnuradio/trunk/gnuradio-core/src/lib/filter/qa_filter.cc (modified) (2 diffs)
- gnuradio/trunk/gnuradio-core/src/lib/filter/qa_gr_rotator.cc (copied) (copied from gnuradio/trunk/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.cc) (1 diff)
- gnuradio/trunk/gnuradio-core/src/lib/filter/qa_gr_rotator.h (copied) (copied from gnuradio/trunk/gnuradio-core/src/lib/filter/qa_gri_mmse_fir_interpolator.h) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gnuradio/trunk/gnuradio-core/src/lib/filter/Makefile.am
r9336 r9384 231 231 qa_gr_fir_ccc.cc \ 232 232 qa_gr_fir_scc.cc \ 233 qa_gr_rotator.cc \ 233 234 qa_gri_mmse_fir_interpolator.cc \ 234 235 qa_gri_mmse_fir_interpolator_cc.cc … … 318 319 qa_gr_fir_ccc.h \ 319 320 qa_gr_fir_scc.h \ 321 qa_gr_rotator.h \ 320 322 qa_gri_mmse_fir_interpolator.h \ 321 323 qa_gri_mmse_fir_interpolator_cc.h gnuradio/trunk/gnuradio-core/src/lib/filter/gr_rotator.h
r6044 r9384 1 1 /* -*- c++ -*- */ 2 2 /* 3 * Copyright 2003 Free Software Foundation, Inc.3 * Copyright 2003,2008 Free Software Foundation, Inc. 4 4 * 5 5 * This file is part of GNU Radio … … 29 29 gr_complex d_phase; 30 30 gr_complex d_phase_incr; 31 unsigned int d_counter; 31 32 32 33 public: 33 gr_rotator () : d_phase (1), d_phase_incr ( 0) { }34 gr_rotator () : d_phase (1), d_phase_incr (1), d_counter(0) { } 34 35 35 void set_phase (gr_complex phase) { d_phase = phase ; }36 void set_phase_incr (gr_complex incr) { d_phase_incr = incr ; }36 void set_phase (gr_complex phase) { d_phase = phase / abs(phase); } 37 void set_phase_incr (gr_complex incr) { d_phase_incr = incr / abs(incr); } 37 38 38 39 gr_complex rotate (gr_complex in){ 39 d_ phase *= d_phase_incr; // incr our phase (complex mult == add phases)40 d_counter++; 40 41 41 d_phase /= abs(d_phase); // ensure multiplication is rotation 42 // FIXME. This is expensive. Maybe workaround using 43 // double precision complex??? 42 gr_complex z = in * d_phase; // rotate in by phase 43 d_phase *= d_phase_incr; // incr our phase (complex mult == add phases) 44 44 45 return in * d_phase; // rotate in by phase 45 if ((d_counter % 512) == 0) 46 d_phase /= abs(d_phase); // Normalize to ensure multiplication is rotation 47 48 return z; 46 49 } 47 50 gnuradio/trunk/gnuradio-core/src/lib/filter/qa_filter.cc
r9336 r9384 36 36 #include <qa_gri_mmse_fir_interpolator.h> 37 37 #include <qa_gri_mmse_fir_interpolator_cc.h> 38 #include <qa_gr_rotator.h> 38 39 39 40 CppUnit::TestSuite * … … 50 51 s->addTest (qa_gri_mmse_fir_interpolator::suite ()); 51 52 s->addTest (qa_gri_mmse_fir_interpolator_cc::suite ()); 53 s->addTest (qa_gr_rotator::suite ()); 52 54 53 55 return s; gnuradio/trunk/gnuradio-core/src/lib/filter/qa_gr_rotator.cc
r9378 r9384 22 22 23 23 #include <cppunit/TestAssert.h> 24 #include <qa_gr i_mmse_fir_interpolator.h>25 #include <gr i_mmse_fir_interpolator.h>24 #include <qa_gr_rotator.h> 25 #include <gr_rotator.h> 26 26 #include <stdio.h> 27 27 #include <cmath> 28 29 #define NELEM(x) (sizeof (x) / sizeof (x[0])) 28 #include <gr_expj.h> 30 29 31 30 32 static float 33 test_fcn (double index) 31 // error vector magnitude 32 __attribute__((unused)) static float 33 error_vector_mag(gr_complex a, gr_complex b) 34 34 { 35 return (2 * sin (index * 0.25 * 2 * M_PI + 0.125 * M_PI) 36 + 3 * sin (index * 0.077 * 2 * M_PI + 0.3 * M_PI)); 35 return abs(a-b); 37 36 } 38 37 38 void 39 qa_gr_rotator::t1 () 40 { 41 static const unsigned int N = 100000; 39 42 40 void 41 qa_gri_mmse_fir_interpolator::t1 () 42 { 43 static const unsigned N = 100; 44 float input[N + 10]; 43 gr_rotator r; 45 44 46 for (unsigned i = 0; i < NELEM(input); i++)47 input[i] = test_fcn ((double) i);45 double phase_incr = 2*M_PI / 1003; 46 double phase = 0; 48 47 49 gri_mmse_fir_interpolator intr; 50 float inv_nsteps = 1.0 / intr.nsteps (); 48 // Old code: We increment then return the rotated value, thus we need to start one tick back 49 // r.set_phase(gr_complex(1,0) * conj(gr_expj(phase_incr))); 50 51 r.set_phase(gr_complex(1,0)); 52 r.set_phase_incr(gr_expj(phase_incr)); 51 53 52 54 for (unsigned i = 0; i < N; i++){ 53 for (unsigned imu = 0; imu <= intr.nsteps (); imu += 1){ 54 float expected = test_fcn ((i + 3) + imu * inv_nsteps); 55 float actual = intr.interpolate (&input[i], imu * inv_nsteps); 55 gr_complex expected = gr_expj(phase); 56 gr_complex actual = r.rotate(gr_complex(1, 0)); 56 57 57 CPPUNIT_ASSERT_DOUBLES_EQUAL (expected, actual, 0.004); 58 // printf ("%9.6f %9.6f %9.6f\n", expected, actual, expected - actual); 59 } 58 #if 0 59 float evm = error_vector_mag(expected, actual); 60 printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n", 61 i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm); 62 #endif 63 64 CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); 65 66 phase += phase_incr; 67 if (phase >= 2*M_PI) 68 phase -= 2*M_PI; 60 69 } 61 70 } 62 gnuradio/trunk/gnuradio-core/src/lib/filter/qa_gr_rotator.h
r9378 r9384 1 1 /* -*- c++ -*- */ 2 2 /* 3 * Copyright 200 2Free Software Foundation, Inc.3 * Copyright 2008 Free Software Foundation, Inc. 4 4 * 5 5 * This file is part of GNU Radio … … 20 20 * Boston, MA 02110-1301, USA. 21 21 */ 22 #ifndef _QA_GR I_MMSE_FIR_INTERPOLATOR_H_23 #define _QA_GR I_MMSE_FIR_INTERPOLATOR_H_22 #ifndef _QA_GR_ROTATOR_H_ 23 #define _QA_GR_ROTATOR_H_ 24 24 25 25 #include <cppunit/extensions/HelperMacros.h> 26 26 #include <cppunit/TestCase.h> 27 27 28 class qa_gr i_mmse_fir_interpolator : public CppUnit::TestCase {28 class qa_gr_rotator : public CppUnit::TestCase { 29 29 30 CPPUNIT_TEST_SUITE (qa_gr i_mmse_fir_interpolator);30 CPPUNIT_TEST_SUITE (qa_gr_rotator); 31 31 CPPUNIT_TEST (t1); 32 32 CPPUNIT_TEST_SUITE_END (); … … 37 37 }; 38 38 39 40 #endif /* _QA_GRI_MMSE_FIR_INTERPOLATOR_H_ */ 39 #endif /* _QA_GR_ROTATOR_H_ */
