1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 12:40:35 +00:00

Add more extensive use of cstdint typenames

This commit is contained in:
Carles Fernandez 2018-08-14 01:32:06 +02:00
parent 200648be50
commit b64850d285
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
8 changed files with 73 additions and 70 deletions

View File

@ -39,7 +39,7 @@
using google::LogMessage;
notch_sptr make_notch_filter(float pfa, float p_c_factor,
int length_, int n_segments_est, int n_segments_reset)
int32_t length_, int32_t n_segments_est, int32_t n_segments_reset)
{
return notch_sptr(new Notch(pfa, p_c_factor, length_, n_segments_est, n_segments_reset));
}
@ -47,31 +47,31 @@ notch_sptr make_notch_filter(float pfa, float p_c_factor,
Notch::Notch(float pfa,
float p_c_factor,
int length_,
int n_segments_est,
int n_segments_reset) : gr::block("Notch",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
int32_t length_,
int32_t n_segments_est,
int32_t n_segments_reset) : gr::block("Notch",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
{
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple));
set_history(2);
this->pfa = pfa;
noise_pow_est = 0.0;
this->p_c_factor = gr_complex(p_c_factor, 0);
this->length_ = length_; //Set the number of samples per segment
filter_state_ = false; //Initial state of the filter
n_deg_fred = 2 * length_; //Number of dregrees of freedom
this->p_c_factor = gr_complex(p_c_factor, 0.0);
this->length_ = length_; // Set the number of samples per segment
filter_state_ = false; // Initial state of the filter
n_deg_fred = 2 * length_; // Number of dregrees of freedom
n_segments = 0;
this->n_segments_est = n_segments_est; // Set the number of segments for noise power estimation
this->n_segments_reset = n_segments_reset; // Set the period (in segments) when the noise power is estimated
z_0 = gr_complex(0, 0);
z_0 = gr_complex(0.0, 0.0);
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
c_samples = static_cast<gr_complex *>(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment()));
angle_ = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
last_out = gr_complex(0, 0);
last_out = gr_complex(0.0, 0.0);
d_fft = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(length_, true));
}
@ -86,7 +86,7 @@ Notch::~Notch()
void Notch::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required)
{
for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++)
for (uint32_t aux = 0; aux < ninput_items_required.size(); aux++)
{
ninput_items_required[aux] = length_;
}
@ -96,7 +96,7 @@ void Notch::forecast(int noutput_items __attribute__((unused)), gr_vector_int &n
int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
int index_out = 0;
int32_t index_out = 0;
float sig2dB = 0.0;
float sig2lin = 0.0;
lv_32fc_t dot_prod_;
@ -127,7 +127,7 @@ int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribu
}
volk_32fc_x2_multiply_conjugate_32fc(c_samples, in, (in - 1), length_);
volk_32fc_s32f_atan2_32f(angle_, c_samples, static_cast<float>(1.0), length_);
for (int aux = 0; aux < length_; aux++)
for (int32_t aux = 0; aux < length_; aux++)
{
z_0 = std::exp(gr_complex(0, 1) * (*(angle_ + aux)));
*(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out;

View File

@ -34,6 +34,7 @@
#include <boost/shared_ptr.hpp>
#include <gnuradio/block.h>
#include <gnuradio/fft/fft.h>
#include <cstdint>
#include <memory>
class Notch;
@ -41,7 +42,7 @@ class Notch;
typedef boost::shared_ptr<Notch> notch_sptr;
notch_sptr make_notch_filter(float pfa, float p_c_factor,
int length_, int n_segments_est, int n_segments_reset);
int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
/*!
* \brief This class implements a real-time software-defined multi state notch filter
@ -53,11 +54,11 @@ private:
float pfa;
float noise_pow_est;
float thres_;
int length_;
int n_deg_fred;
unsigned int n_segments;
unsigned int n_segments_est;
unsigned int n_segments_reset;
int32_t length_;
int32_t n_deg_fred;
uint32_t n_segments;
uint32_t n_segments_est;
uint32_t n_segments_reset;
bool filter_state_;
gr_complex last_out;
gr_complex z_0;
@ -68,7 +69,7 @@ private:
std::unique_ptr<gr::fft::fft_complex> d_fft;
public:
Notch(float pfa, float p_c_factor, int length_, int n_segments_est, int n_segments_reset);
Notch(float pfa, float p_c_factor, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
~Notch();

View File

@ -38,7 +38,7 @@
using google::LogMessage;
notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff)
notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff)
{
return notch_lite_sptr(new NotchLite(p_c_factor, pfa, length_, n_segments_est, n_segments_reset, n_segments_coeff));
}
@ -46,17 +46,17 @@ notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_,
NotchLite::NotchLite(float p_c_factor,
float pfa,
int length_,
int n_segments_est,
int n_segments_reset,
int n_segments_coeff) : gr::block("NotchLite",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
int32_t length_,
int32_t n_segments_est,
int32_t n_segments_reset,
int32_t n_segments_coeff) : gr::block("NotchLite",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
{
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple));
set_history(2);
this->p_c_factor = gr_complex(p_c_factor, 0);
this->p_c_factor = gr_complex(p_c_factor, 0.0);
this->n_segments_est = n_segments_est;
this->n_segments_reset = n_segments_reset;
this->n_segments_coeff_reset = n_segments_coeff;
@ -68,12 +68,12 @@ NotchLite::NotchLite(float p_c_factor,
n_deg_fred = 2 * length_;
noise_pow_est = 0.0;
filter_state_ = false;
z_0 = gr_complex(0, 0);
last_out = gr_complex(0, 0);
z_0 = gr_complex(0.0, 0.0);
last_out = gr_complex(0.0, 0.0);
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
c_samples1 = gr_complex(0, 0);
c_samples2 = gr_complex(0, 0);
c_samples1 = gr_complex(0.0, 0.0);
c_samples2 = gr_complex(0.0, 0.0);
angle1 = 0.0;
angle2 = 0.0;
power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
@ -89,7 +89,7 @@ NotchLite::~NotchLite()
void NotchLite::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required)
{
for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++)
for (uint32_t aux = 0; aux < ninput_items_required.size(); aux++)
{
ninput_items_required[aux] = length_;
}
@ -99,7 +99,7 @@ void NotchLite::forecast(int noutput_items __attribute__((unused)), gr_vector_in
int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
int index_out = 0;
int32_t index_out = 0;
float sig2dB = 0.0;
float sig2lin = 0.0;
lv_32fc_t dot_prod_;
@ -138,7 +138,7 @@ int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __att
float angle_ = (angle1 + angle2) / 2.0;
z_0 = std::exp(gr_complex(0, 1) * angle_);
}
for (int aux = 0; aux < length_; aux++)
for (int32_t aux = 0; aux < length_; aux++)
{
*(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out;
last_out = *(out + aux);

View File

@ -34,13 +34,14 @@
#include <boost/shared_ptr.hpp>
#include <gnuradio/block.h>
#include <gnuradio/fft/fft.h>
#include <cstdint>
#include <memory>
class NotchLite;
typedef boost::shared_ptr<NotchLite> notch_lite_sptr;
notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff);
notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff);
/*!
* \brief This class implements a real-time software-defined multi state notch filter light version
@ -49,13 +50,13 @@ notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_,
class NotchLite : public gr::block
{
private:
int length_;
int n_segments;
int n_segments_est;
int n_segments_reset;
int n_segments_coeff_reset;
int n_segments_coeff;
int n_deg_fred;
int32_t length_;
int32_t n_segments;
int32_t n_segments_est;
int32_t n_segments_reset;
int32_t n_segments_coeff_reset;
int32_t n_segments_coeff;
int32_t n_deg_fred;
float pfa;
float thres_;
float noise_pow_est;
@ -71,7 +72,7 @@ private:
std::unique_ptr<gr::fft::fft_complex> d_fft;
public:
NotchLite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff);
NotchLite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff);
~NotchLite();

View File

@ -37,21 +37,21 @@
using google::LogMessage;
pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int length_,
int n_segments_est, int n_segments_reset)
pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length_,
int32_t n_segments_est, int32_t n_segments_reset)
{
return pulse_blanking_cc_sptr(new pulse_blanking_cc(pfa, length_, n_segments_est, n_segments_reset));
}
pulse_blanking_cc::pulse_blanking_cc(float pfa,
int length_,
int n_segments_est,
int n_segments_reset) : gr::block("pulse_blanking_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
int32_t length_,
int32_t n_segments_est,
int32_t n_segments_reset) : gr::block("pulse_blanking_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
{
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple));
this->pfa = pfa;
this->length_ = length_;
@ -64,9 +64,9 @@ pulse_blanking_cc::pulse_blanking_cc(float pfa,
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
zeros_ = static_cast<gr_complex *>(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment()));
for (int aux = 0; aux < length_; aux++)
for (int32_t aux = 0; aux < length_; aux++)
{
zeros_[aux] = gr_complex(0, 0);
zeros_[aux] = gr_complex(0.0, 0.0);
}
}
@ -79,7 +79,7 @@ pulse_blanking_cc::~pulse_blanking_cc()
void pulse_blanking_cc::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required)
{
for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++)
for (uint32_t aux = 0; aux < ninput_items_required.size(); aux++)
{
ninput_items_required[aux] = length_;
}
@ -93,7 +93,7 @@ int pulse_blanking_cc::general_work(int noutput_items, gr_vector_int &ninput_ite
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
float *magnitude = static_cast<float *>(volk_malloc(noutput_items * sizeof(float), volk_get_alignment()));
volk_32fc_magnitude_squared_32f(magnitude, in, noutput_items);
int sample_index = 0;
int32_t sample_index = 0;
float segment_energy;
while ((sample_index + length_) < noutput_items)
{

View File

@ -33,22 +33,23 @@
#include <boost/shared_ptr.hpp>
#include <gnuradio/block.h>
#include <cstdint>
class pulse_blanking_cc;
typedef boost::shared_ptr<pulse_blanking_cc> pulse_blanking_cc_sptr;
pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int length_, int n_segments_est, int n_segments_reset);
pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
class pulse_blanking_cc : public gr::block
{
private:
int length_;
int n_segments;
int n_segments_est;
int n_segments_reset;
int n_deg_fred;
int32_t length_;
int32_t n_segments;
int32_t n_segments_est;
int32_t n_segments_reset;
int32_t n_deg_fred;
bool last_filtered;
float noise_power_estimation;
float thres_;
@ -56,7 +57,7 @@ private:
gr_complex *zeros_;
public:
pulse_blanking_cc(float pfa, int length_, int n_segments_est, int n_segments_reset);
pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
~pulse_blanking_cc();

View File

@ -268,7 +268,7 @@ uint64_t Galileo_Navigation_Message::read_navigation_unsigned(std::bitset<GALILE
{
for (int32_t j = 0; j < parameter[i].second; j++)
{
value <<= 1; //shift left
value <<= 1; // shift left
if (bits[GALILEO_DATA_JK_BITS - parameter[i].first - j] == 1)
{
value += 1; // insert the bit
@ -287,7 +287,7 @@ uint64_t Galileo_Navigation_Message::read_page_type_unsigned(std::bitset<GALILEO
{
for (int32_t j = 0; j < parameter[i].second; j++)
{
value <<= 1; //shift left
value <<= 1; // shift left
if (bits[GALILEO_PAGE_TYPE_BITS - parameter[i].first - j] == 1)
{
value += 1; // insert the bit

View File

@ -632,7 +632,7 @@ Gps_Iono Gps_Navigation_Message::get_iono()
iono.d_beta2 = d_beta2;
iono.d_beta3 = d_beta3;
iono.valid = flag_iono_valid;
//WARNING: We clear flag_utc_model_valid in order to not re-send the same information to the ionospheric parameters queue
// WARNING: We clear flag_utc_model_valid in order to not re-send the same information to the ionospheric parameters queue
flag_iono_valid = false;
return iono;
}