diff options
author | n4hy | 2006-12-14 05:20:15 +0000 |
---|---|---|
committer | n4hy | 2006-12-14 05:20:15 +0000 |
commit | 0bcd3eef3ddd18fd190a459923920a59287b7485 (patch) | |
tree | 7b23c1cf39fdddf9c4af1171bd36aad63dcf6147 /gnuradio-core/src/lib/general | |
parent | 732324bb5569286f035eec8ad0d6923b3ad843ce (diff) | |
download | gnuradio-0bcd3eef3ddd18fd190a459923920a59287b7485.tar.gz gnuradio-0bcd3eef3ddd18fd190a459923920a59287b7485.tar.bz2 gnuradio-0bcd3eef3ddd18fd190a459923920a59287b7485.zip |
Two loop gr_costas_loop removing one if statement per sample
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@4080 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r-- | gnuradio-core/src/lib/general/gr_costas_loop_cc.cc | 77 |
1 files changed, 51 insertions, 26 deletions
diff --git a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc b/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc index f06be47eb..61d58ebe5 100644 --- a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc +++ b/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc @@ -98,33 +98,58 @@ gr_costas_loop_cc::work (int noutput_items, float error; gr_complex nco_out; - - for (int i = 0; i < noutput_items; i++){ - nco_out = gr_expj(-d_phase); - optr[i] = iptr[i] * nco_out; - - error = (*this.*d_phase_detector)(optr[i]); - if (error > 1) - error = 1; - else if (error < -1) - error = -1; - - d_freq = d_freq + d_beta * error; - d_phase = d_phase + d_freq + d_alpha * error; - - while(d_phase>M_TWOPI) - d_phase -= M_TWOPI; - while(d_phase<-M_TWOPI) - d_phase += M_TWOPI; - - if (d_freq > d_max_freq) - d_freq = d_max_freq; - else if (d_freq < d_min_freq) - d_freq = d_min_freq; - - if (write_foptr){ + + if (write_foptr) { + + for (int i = 0; i < noutput_items; i++){ + nco_out = gr_expj(-d_phase); + optr[i] = iptr[i] * nco_out; + + error = (*this.*d_phase_detector)(optr[i]); + if (error > 1) + error = 1; + else if (error < -1) + error = -1; + + d_freq = d_freq + d_beta * error; + d_phase = d_phase + d_freq + d_alpha * error; + + while(d_phase>M_TWOPI) + d_phase -= M_TWOPI; + while(d_phase<-M_TWOPI) + d_phase += M_TWOPI; + + if (d_freq > d_max_freq) + d_freq = d_max_freq; + else if (d_freq < d_min_freq) + d_freq = d_min_freq; + foptr[i] = gr_complex(d_freq,0); - //foptr[i] = gr_complex(error, 0); + } + } else { + for (int i = 0; i < noutput_items; i++){ + nco_out = gr_expj(-d_phase); + optr[i] = iptr[i] * nco_out; + + error = (*this.*d_phase_detector)(optr[i]); + if (error > 1) + error = 1; + else if (error < -1) + error = -1; + + d_freq = d_freq + d_beta * error; + d_phase = d_phase + d_freq + d_alpha * error; + + while(d_phase>M_TWOPI) + d_phase -= M_TWOPI; + while(d_phase<-M_TWOPI) + d_phase += M_TWOPI; + + if (d_freq > d_max_freq) + d_freq = d_max_freq; + else if (d_freq < d_min_freq) + d_freq = d_min_freq; + } } return noutput_items; |