From 7a8d4a6509e4a154c2e42937f1dbe509b1731b6c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 4 Aug 2012 11:39:01 +0000 Subject: [PATCH] Added some const git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@227 64b25241-fba3-4117-9849-534c7e92360d --- src/algorithms/libs/gnss_signal_processing.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/algorithms/libs/gnss_signal_processing.cc b/src/algorithms/libs/gnss_signal_processing.cc index 8c566460f..cb278af5e 100644 --- a/src/algorithms/libs/gnss_signal_processing.cc +++ b/src/algorithms/libs/gnss_signal_processing.cc @@ -38,10 +38,10 @@ void complex_exp_gen(std::complex* _dest, double _f, double _fs, unsigned int _samps) { double phase = 0; - double phase_step = (GPS_TWO_PI*_f)/_fs; + const double phase_step = (GPS_TWO_PI * _f) / _fs; for(unsigned int i = 0; i < _samps; i++) { - _dest[i] = std::complex(cos(phase),sin(phase)); + _dest[i] = std::complex(cos(phase), sin(phase)); phase += phase_step; } } @@ -150,28 +150,23 @@ void hex_to_binary_converter(int * _dest, char _from) } } + void resampler(std::complex* _from, std::complex* _dest, float _fs_in, float _fs_out, unsigned int _length_in, unsigned int _length_out) { - unsigned int _codeValueIndex; //--- Find time constants -------------------------------------------------- - float _t_in = 1/_fs_in; // Incoming sampling period in sec - float _t_out = 1/_fs_out; // Out sampling period in sec - + const float _t_in = 1/_fs_in; // Incoming sampling period in sec + const float _t_out = 1/_fs_out; // Out sampling period in sec for (unsigned int i=0; i<_length_out; i++) { //=== Digitizing ======================================================= - - //--- Make index array to read sampled values ------------------------- - + //--- compute index array to read sampled values ------------------------- _codeValueIndex = ceil((_t_out * ((float)i + 1)) / _t_in) - 1; - if (i == _length_out - 1) { //--- Correct the last index (due to number rounding issues) ----------- _dest[i] = _from[_length_in - 1]; - } else { @@ -179,5 +174,4 @@ void resampler(std::complex* _from, std::complex* _dest, float _fs _dest[i] = _from[_codeValueIndex]; } } - }