John wrote:> On Sep 12, 2:42 am, ste...@coppice.org wrote: >> On Sep 12, 4:59 am, Jerry Avins <j...@ieee.org> wrote: >> >> >> >>> John wrote: >>>> On Sep 3, 4:18 pm, Vladimir Vassilevsky <antispam_bo...@hotmail.com> >>>> wrote: >>>>> Thomas Magma wrote: >>>>>> Hello, >>>>>> I'm trying to write a very efficient and fast detection algorithm for a >>>>>> dsPIC. >>>>> To detect what? >>>>>> I've already been down the path of the Goertzel and have dismissed it >>>>>> because of it's use of floating point numbers. >>>>> Goertzel can be done in the integer math. >>>>>> I am now using a modified DFT >>>>> There is no point. With dsPIC, Goertzel is more efficient then I/Q >>>>> accumulation. >>>>>> and would like to get rid of the square root algorithm that calculates the >>>>>> magnitude of I & Q. >>>>> sqrt(I^2 + Q^2) ~ max(|I|,|Q|) + (min(|I|,|Q|) >> 2) >>>>> The error is less then 10% >>>> I think you mean either >>1 or /2, no? >>> Either way. 3/8 is a bit better. Seehttp://www.dspguru.com/comp.dsp/tricks/alg/mag_est.htm >> That's considerably better than 1/2 or 1/4, but requires an extra add. >> I remember when that involved numerous extra chips, and we deeply >> debated whether we could live with the reduced precision. One guy >> treated "greater plus three eighths of the lesser" as a mantra. Times >> change. :-) >> >> For most purposes using 1/2 or 1/4 gives comparable results. The >> errors nudge in different directions, so one or other sometimes works >> out better in specific applications. >> >> Regards, >> Steve > > Suppose I want the time-average magnitude of a vector. Is it better to > average |I| and |Q| and then apply the approximation, or average the > approximation?Whether the magnitudes are calculated exactly or approximated, average the magnitudes. Average magnitude and the magnitude of average I and Q can be very different. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������