Commit b82c36c5 authored by maximilianlohoefer's avatar maximilianlohoefer
Browse files

measurement::add(...) methods now pass by reference.

rebinning is now repeated as long as possible (if -> while)


git-svn-id: https://svn.rwth-aachen.de/repos/sw440870_load_leveller/trunk@32 36cca2a8-63f0-4188-8a56-663e3b0d1cf3
parent 26bf5c84
......@@ -129,16 +129,16 @@ class measurements
//! Add measurment to observable
/*! Here we can "feed" values into the observables and perform measurements. */
template <class T> void add(std::string name, T value) {obs_v[eo[name]]->add(value);}
template <class T> void add(std::string name, const T& value) {obs_v[eo[name]]->add(value);}
//! Add measurment to observable
/*! Here we can "feed" values into the observables and perform measurements. */
template <class T> void add(std::string name, T* value) {obs_v[eo[name]]->add(value);}
//! Add measurment to vector observable
/*! Here we can "feed" values into the observables and perform measurements. */
template <class T> void add(std::string name, vector<T> value) {obs_v[eo[name]]->add(value);}
template <class T> void add(std::string name, const vector<T>& value) {obs_v[eo[name]]->add(value);}
//! Add measurment to evalable
/*! Here we can "feed" values into the observables and perform measurements. */
void add(std::string name, std::valarray<double> value) {obs_v[eo[name]]->add(value);}
void add(std::string name, const std::valarray<double>& value) {obs_v[eo[name]]->add(value);}
void mean(std::string name,std::valarray<double>& v)
{(tag[name]) ? obs_v[eo[name]]->mean(v) : eva_v[eo[name]]->mean(v);}
......
......@@ -56,7 +56,7 @@ void observable :: extract(int j, observable& obs)
}
void observable :: add(valarray<double>& val)
void observable :: add(const valarray<double>& val)
{
if ((current_bin==0) && (val.size()>vector_length_)) {
vector_length_=val.size();
......@@ -268,7 +268,7 @@ void observable :: binning(){
valarray<double> binneddata(0.,vector_length_*bins()/binning_base());
valarray<double> ali(0.,vector_length_);
int is_first_rebinning=1;
if (n>=min_number_of_bins()*binning_base()) {
while (n>=min_number_of_bins()*binning_base()) {
length*=binning_base();
n/=binning_base();
luint index=0;
......
......@@ -41,8 +41,8 @@ class observable
void extract(int, observable&);
void mean(valarray<double>&);
void error(valarray<double>&);
void mean(valarray<double>&);
void error(valarray<double>&);
void naiveerror(valarray<double>&);
void variance(valarray<double>&);
void autocorrelationtime(valarray<double>&);
......@@ -57,8 +57,8 @@ class observable
template <class T> void add(T);
template <class T> void add(T*);
template <class T> void add(vector<T>&);
void add(valarray<double>&);
template <class T> void add(const vector<T>&);
void add(const valarray<double>&);
void rebin(int);
......@@ -86,13 +86,13 @@ class observable
vector<valarray<double> > error_v;
private:
string name_;
luint bin_length_;
string name_;
luint bin_length_;
luint vector_length_;
luint length;
luint initial_length;
luint current_bin;
luint current_bin_filling;
luint current_bin;
luint current_bin_filling;
luint chunks;
void init(string,luint,luint,luint);
......@@ -148,12 +148,12 @@ void observable :: add(T* val)
}
template <class T>
void observable :: add(vector<T>& val)
void observable :: add(const vector<T>& val)
{
if (!current_bin && val.size()>vector_length_) {
vector_length_=val.size();
samples.resize(length*vector_length_,0.);
}
if (!current_bin && val.size()>vector_length_) {
vector_length_=val.size();
samples.resize(length*vector_length_,0.);
}
for (uint j=0;j<vector_length_;++j)
samples[j+current_bin*vector_length_]+=static_cast<double>(val[j]);
++current_bin_filling;
......@@ -173,7 +173,5 @@ void observable :: add(vector<T>& val)
}
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment