bucket_size *= 2;
}
+void
+HistStor::add(HistStor *hs)
+{
+ int b_size = hs->size();
+ assert(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()
{
}
/**
* 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()
void grow_up();
void grow_out();
void grow_convert();
+ void add(HistStor *);
/**
* Add a value to the distribution for the given number of times.
{
data()->reset(this->info());
}
+
+ /**
+ * Add the argument distribution to the this distibution.
+ */
+ void add(DistBase &d) { data()->add(d.data()); }
+
};
template <class Stat>
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;
if (!desc.empty())
ccprintf(stream, " # %s", desc);
}
-
stream << endl;
}
}
print.value = total;
print(stream);
}
-
- if (flags.isSet(oneline) && ((!flags.isSet(nozero)) || (total != 0))) {
- stream << endl;
- }
}
struct DistPrint
void
DistPrint::operator()(ostream &stream) const
{
+ if (flags.isSet(nozero) && data.samples == 0) return;
string base = name + separatorString;
ScalarPrint print;
print.pdf = NAN;
print.cdf = NAN;
+ if (flags.isSet(oneline)) {
+ 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);
print(stream);
}
+ if (flags.isSet(oneline)) {
+ ccprintf(stream, "%-40s", name);
+ }
+
for (off_type i = 0; i < size; ++i) {
stringstream namestr;
namestr << base;
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) {