Skip to content

Commit cd19e97

Browse files
author
Aaron Roller
authored
Merge pull request #4 from AutoModality/devel
Fixes for compile warnings
2 parents c1a2753 + 6d57f2f commit cd19e97

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

include/am_utils/am_onlinestatistics.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace am {
1313
class OnlineStatistics {
1414
public:
1515
OnlineStatistics() : OnlineStatistics(0) {};
16-
OnlineStatistics(size_t N) : ary_(0), cb(N) {};
16+
OnlineStatistics(size_t N) : ary_(0), cb_(N) {};
1717
void addData( double val );
1818
void setSize( size_t N );
1919
void insertion_sort(std::vector<double>& ary);
@@ -29,11 +29,11 @@ class OnlineStatistics {
2929

3030
private:
3131
size_t N;
32-
boost::circular_buffer<double> cb;
32+
std::vector<double> ary_;
33+
boost::circular_buffer<double> cb_;
3334
double mean_; // mean, median
3435
double m2n_; // sum of squares of differences from current mean
3536
double var_, skew_, kurt_; // variance, skewness, and kurtosis
36-
std::vector<double> ary_;
3737
};
3838

3939

src/am_onlinestatistics.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,34 @@ namespace am {
1616
*
1717
*/
1818
void OnlineStatistics::addData( double val ) {
19-
if ( cb.size() == 0 ) {
19+
if ( cb_.size() == 0 ) {
2020
mean_ = val;
2121
var_ = NAN;
2222
m2n_ = 0.0;
23-
} else if ( 1 + cb.size() > cb.capacity() ) {
24-
double tmp = cb.back();
23+
} else if ( 1 + cb_.size() > cb_.capacity() ) {
24+
double tmp = cb_.back();
2525
// std::cout << *this << std::endl;
2626
double oldmean = mean_;
27-
mean_ = mean_ + (val - tmp)/cb.size();
27+
mean_ = mean_ + (val - tmp)/cb_.size();
2828
double delta = mean_ - oldmean;
2929
double alpha = val - tmp;
3030
/* Fix this part here */
31-
m2n_ = m2n_ + (delta*delta*cb.size()) + alpha*(alpha+2*tmp-2*mean_ );
32-
var_ = m2n_ / cb.size();
31+
m2n_ = m2n_ + (delta*delta*cb_.size()) + alpha*(alpha+2*tmp-2*mean_ );
32+
var_ = m2n_ / cb_.size();
3333
auto const ip = std::find( ary_.begin(), ary_.end(), tmp );
3434
if ( ip != ary_.end() ) {
3535
ary_.erase(ip);
3636
}
3737

3838
} else {
3939
double oldmean_ = mean_;
40-
mean_ = (val - mean_)/(cb.size()+1) + mean_;
40+
mean_ = (val - mean_)/(cb_.size()+1) + mean_;
4141
m2n_ = m2n_ + ( val - oldmean_)*(val - mean_ );
42-
var_ = m2n_ / (cb.size()+1);
42+
var_ = m2n_ / (cb_.size()+1);
4343
}
4444
ary_.insert(ary_.begin(),val );
4545
insertion_sort(ary_);
46-
cb.push_front(val);
46+
cb_.push_front(val);
4747
// std::cout << *this << std::endl;
4848
}
4949

@@ -59,14 +59,14 @@ void OnlineStatistics::insertion_sort(std::vector<double>& ary) {
5959

6060
void OnlineStatistics::setSize( size_t N )
6161
{
62-
cb.set_capacity(N);
63-
cb.erase(cb.begin(),cb.end());
62+
cb_.set_capacity(N);
63+
cb_.erase(cb_.begin(),cb_.end());
6464
ary_.clear();
6565
}
6666

6767
void OnlineStatistics::setDelayStats( am_utils::DelayStats &msg )
6868
{
69-
msg.count = cb.size();
69+
msg.count = cb_.size();
7070
msg.mean_delay = getMean();
7171
msg.stddev_delay = sqrt(getVariance());
7272
msg.min_delay = getMin();
@@ -77,8 +77,8 @@ void OnlineStatistics::setDelayStats( am_utils::DelayStats &msg )
7777
std::ostream& operator<<(std::ostream& os, OnlineStatistics &stats) {
7878
// os << stats.cb;
7979
os << "[ ";
80-
for ( auto it = stats.cb.begin() ; it != stats.cb.end(); ++it ) {
81-
os << *it << ( it + 1 == stats.cb.end() ? "" : ", " );
80+
for ( auto it = stats.cb_.begin() ; it != stats.cb_.end(); ++it ) {
81+
os << *it << ( it + 1 == stats.cb_.end() ? "" : ", " );
8282
}
8383
os << "]";
8484
return os;

0 commit comments

Comments
 (0)