[Positioner] Measurement: use floats, not doubles

Use floats variables for the average and variance.
This commit is contained in:
Matteo Cypriani 2012-02-09 14:49:36 +01:00
parent e687aac741
commit dcd902c9f0
3 changed files with 11 additions and 11 deletions

View File

@ -123,10 +123,10 @@ void Measurement::recalculate_average()
void Measurement::update_average(ss_t ss_dbm) void Measurement::update_average(ss_t ss_dbm)
{ {
// Convert the new SS in mW: // Convert the new SS in mW:
double ss_mw = pow(10, static_cast<double>(ss_dbm) / 10.0) ; float ss_mw = pow(10, static_cast<float>(ss_dbm) / 10.0) ;
// Update the average: // Update the average:
double delta = ss_mw - average_mw ; float delta = ss_mw - average_mw ;
average_mw += delta / ss_list.size() ; average_mw += delta / ss_list.size() ;
average_dbm = 10.0 * log10(average_mw) ; average_dbm = 10.0 * log10(average_mw) ;

View File

@ -26,15 +26,15 @@ protected:
/// List of signal strengths captured (in dBm) /// List of signal strengths captured (in dBm)
std::map<pkt_id_t, ss_t> ss_list ; std::map<pkt_id_t, ss_t> ss_list ;
/// Average of all the captured signal strengths (dBm) /// Average of all the captured signal strengths (dBm)
double average_dbm ; float average_dbm ;
/// Average of all the captured signal strengths (mW) /// Average of all the captured signal strengths (mW)
double average_mw ; float average_mw ;
/// Variance of all the captured signal strengths /// Variance of all the captured signal strengths
double variance ; float variance ;
private: private:
/// Intermediate variable used to compute the variance /// Intermediate variable used to compute the variance
double variance_m2 ; float variance_m2 ;
protected: protected:
@ -62,8 +62,8 @@ public:
/** @name Read accessors */ /** @name Read accessors */
//@{ //@{
AccessPoint* get_ap() const ; AccessPoint* get_ap() const ;
double get_average_dbm() const ; float get_average_dbm() const ;
double get_variance() const ; float get_variance() const ;
int get_nb_ss() const ; int get_nb_ss() const ;
//@} //@}
@ -116,13 +116,13 @@ inline AccessPoint* Measurement::get_ap() const
} }
inline double Measurement::get_average_dbm() const inline float Measurement::get_average_dbm() const
{ {
return average_dbm ; return average_dbm ;
} }
inline double Measurement::get_variance() const inline float Measurement::get_variance() const
{ {
return variance ; return variance ;
} }

View File

@ -257,7 +257,7 @@ float ReferencePoint::friis_indexes_for_ap(
measurements.find(ap_mac) ; measurements.find(ap_mac) ;
if (measurement != measurements.end()) if (measurement != measurements.end())
{ {
double ss = measurement->second.get_average_dbm() ; float ss = measurement->second.get_average_dbm() ;
assert((*request)->get_mobile()) ; assert((*request)->get_mobile()) ;
float mobile_gain = float mobile_gain =
(*request)->get_mobile()->get_antenna_gain() ; (*request)->get_mobile()->get_antenna_gain() ;