Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: LFS, Container Registry, Job Artifacs, Uploads (Wiki, Bilder, Projekt-Exporte). Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/59-object-storage-pilot

Commit 07ab802f authored by sw440870's avatar sw440870
Browse files

can now add a valarray

parent 5e271ed5
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include <valarray>
namespace loadl { namespace loadl {
...@@ -20,6 +21,9 @@ public: ...@@ -20,6 +21,9 @@ public:
template<class T> template<class T>
void add(const std::vector<T> &); void add(const std::vector<T> &);
template<class T>
void add(const std::valarray<T> &);
void checkpoint_write(const iodump::group &dump_file) const; void checkpoint_write(const iodump::group &dump_file) const;
// This will empty the cache of already completed bins // This will empty the cache of already completed bins
...@@ -73,4 +77,29 @@ void observable::add(const std::vector<T> &val) { ...@@ -73,4 +77,29 @@ void observable::add(const std::vector<T> &val) {
current_bin_filling_ = 0; current_bin_filling_ = 0;
} }
} }
template<class T>
void observable::add(const std::valarray<T> &val) {
if(vector_length_ != val.size()) {
throw std::runtime_error{
fmt::format("observable::add: added vector has unexpected size ({}). Observable was "
"initialized with vector length ({})",
val.size(), vector_length_)};
}
for(size_t j = 0; j < vector_length_; ++j)
samples_[j + current_bin_ * vector_length_] += static_cast<double>(val[j]);
current_bin_filling_++;
if(current_bin_filling_ == bin_length_) { // need to start a new bin next time
if(bin_length_ > 1) {
for(size_t j = 0; j < vector_length_; ++j) {
samples_[current_bin_ * vector_length_ + j] /= bin_length_;
}
}
current_bin_++;
samples_.resize((current_bin_ + 1) * vector_length_);
current_bin_filling_ = 0;
}
}
} }
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