diff -r bdd606534bdc -r 29b6d80dc915 src/base/statistics.hh --- a/src/base/statistics.hh Tue Dec 03 10:51:40 2013 -0600 +++ b/src/base/statistics.hh Thu Dec 05 16:21:43 2013 -0600 @@ -228,12 +228,12 @@ /** * Copy constructor, copies are not allowed. */ - DataWrap(const DataWrap &stat); + DataWrap(const DataWrap &stat) {} /** * Can't copy stats. */ - void operator=(const DataWrap &); + void operator=(const DataWrap &) {} public: DataWrap() @@ -1502,6 +1502,7 @@ void grow_up(); void grow_out(); void grow_convert(); + void add(HistStor *); /** * Add a value to the distribution for the given number of times. @@ -1840,6 +1841,12 @@ { data()->reset(this->info()); } + + /** + * Add the argument distribution to the this distibution. + */ + void add(DistBase &d) { data()->add(d.data()); } + }; template diff -r bdd606534bdc -r 29b6d80dc915 src/base/statistics.cc --- a/src/base/statistics.cc Tue Dec 03 10:51:40 2013 -0600 +++ b/src/base/statistics.cc Thu Dec 05 16:21:43 2013 -0600 @@ -352,6 +352,28 @@ bucket_size *= 2; } +void +HistStor::add(HistStor *hs) +{ + int a_size = size(); + int b_size = hs->size(); + assert(a_size == b_size); + assert(min_bucket == hs->min_bucket); + + sum += hs->sum; + logs += hs->logs; + squares += hs->squares; + samples += hs->samples; + + while(bucket_size > hs->bucket_size) + hs->grow_up(); + while(bucket_size < hs->bucket_size) + grow_up(); + + for (uint32_t i = 0; i < b_size; i++) + cvec[i] += hs->cvec[i]; +} + Formula::Formula() { } diff -r bdd606534bdc -r 29b6d80dc915 src/base/stats/text.cc --- a/src/base/stats/text.cc Tue Dec 03 10:51:40 2013 -0600 +++ b/src/base/stats/text.cc Thu Dec 05 16:21:43 2013 -0600 @@ -210,7 +210,7 @@ void ScalarPrint::operator()(ostream &stream, bool oneLine) const { - if ((flags.isSet(nozero) && value == 0.0) || + if ((flags.isSet(nozero) && (!oneLine) && value == 0.0) || (flags.isSet(nonan) && std::isnan(value))) return; @@ -312,7 +312,6 @@ if (!desc.empty()) ccprintf(stream, " # %s", desc); } - stream << endl; } } @@ -325,10 +324,6 @@ print.value = total; print(stream); } - - if (flags.isSet(oneline) && ((!flags.isSet(nozero)) || (total != 0))) { - stream << endl; - } } struct DistPrint @@ -380,6 +375,7 @@ void DistPrint::operator()(ostream &stream) const { + if (flags.isSet(nozero) && data.samples == 0) return; string base = name + separatorString; ScalarPrint print; @@ -390,6 +386,18 @@ print.pdf = NAN; print.cdf = NAN; + print.name = base + "bucket_size"; + print.value = data.bucket_size; + print(stream); + + print.name = base + "min_bucket"; + print.value = data.min; + print(stream); + + print.name = base + "max_bucket"; + print.value = data.max; + print(stream); + print.name = base + "samples"; print.value = data.samples; print(stream); @@ -436,6 +444,10 @@ print(stream); } + if (flags.isSet(oneline)) { + ccprintf(stream, "%-40s", name); + } + for (off_type i = 0; i < size; ++i) { stringstream namestr; namestr << base; @@ -448,7 +460,15 @@ print.name = namestr.str(); print.update(data.cvec[i], total); - print(stream); + print(stream, flags.isSet(oneline)); + } + + if (flags.isSet(oneline)) { + if (descriptions) { + if (!desc.empty()) + ccprintf(stream, " # %s", desc); + } + stream << endl; } if (data.type == Dist && data.overflow != NAN) {