discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] bug in gr_rotate and patch


From: Joshua Lackey
Subject: [Discuss-gnuradio] bug in gr_rotate and patch
Date: Sun, 11 Jan 2004 16:35:11 -0800
User-agent: Mutt/1.2.5.1i

I've found a trivial but fairly annoying bug in the gr_rotator class.
The bug affects anything using a frequency translating filter and that
includes almost all the programs in src/gnu/examples.

It is caused by rounding error and manifests as slowly decreasing signal
amplitude.  Essentially, the output from the filter is rotated through a
certain phase which is incremented each time.  The initial phase and
phase increment both have magnitude 1 yet, because of rounding error,
their product does not.  My fix is to normalize the phase after each
increment.

The following patch is against the latest version of gr_rotator.h in cvs.


Index: src/gnu/lib/gr/gr_rotator.h
===================================================================
RCS file: /cvsroot/gnuradio/gnuradio/src/gnu/lib/gr/gr_rotator.h,v
retrieving revision 1.1
diff -u -5 -r1.1 gr_rotator.h
--- src/gnu/lib/gr/gr_rotator.h 22 Feb 2003 00:41:42 -0000      1.1
+++ src/gnu/lib/gr/gr_rotator.h 12 Jan 2004 00:09:37 -0000
@@ -35,10 +35,11 @@
   void set_phase (VrComplex phase)     { d_phase = phase; }
   void set_phase_incr (VrComplex incr) { d_phase_incr = incr; }
 
   VrComplex rotate (VrComplex in){
     d_phase *= d_phase_incr;   // incr our phase (complex mult == add phases)
+    d_phase /= abs(d_phase);   // ensure multiplication is rotation
     return in * d_phase;       // rotate in by phase
   }
 
 };
 

-- 
Joshua Lackey, PhD. -- address@hidden

Attachment: gr_rotator.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]