12 namespace alps {
namespace alea {
17 , batch_size_(batch_size)
19 , nextlevel_(batch_size)
20 , granularity_(granularity)
23 level_.push_back(
var_acc<T>(size, batch_size));
30 nextlevel_ = batch_size_;
32 level_.push_back(
var_acc<T>(size_, batch_size_));
46 batch_size_ = batch_size;
54 granularity_ = granularity;
62 nextlevel_ *= granularity_;
69 assert(count_ < nextlevel_);
74 if(count_ >= nextlevel_)
78 level_[0].add(source, count, level_.data() + 1);
88 level_.push_back(
var_acc<T>(size_, batch_size_));
92 for (
size_t i = 0; i != other.
nlevel(); ++i)
93 level_[i] << other.
level(i);
107 template <
typename T>
115 template <
typename T>
119 result.level_.resize(level_.size());
125 for (
size_t i = 0; i != level_.size() - 1; ++i)
126 level_[i].
finalize_to(result.level_[i], level_.data() + i + 1);
128 level_[
nlevel() - 1].finalize_to(result.level_[
nlevel() - 1],
nullptr);
135 template <
typename T>
139 for(
size_t i = 0; i < r1.
nlevel(); ++i) {
151 template <
typename T>
154 return level_[i].batch_size();
157 template <
typename T>
161 for (
unsigned i =
nlevel(); i != 0; --i) {
168 template <
typename T>
171 size_t lvl = find_level(DEFAULT_MIN_SAMPLES);
175 return level_[lvl].count2();
178 template <
typename T>
181 size_t lvl = find_level(DEFAULT_MIN_SAMPLES);
185 return level_[lvl].var();
188 template <
typename T>
191 size_t lvl = find_level(DEFAULT_MIN_SAMPLES);
196 return level_[lvl].stderror();
199 template <
typename T>
202 size_t lvl = find_level(DEFAULT_MIN_SAMPLES);
206 return (0.5 * varn.array() / var0.array() - 0.5).matrix();
209 template <
typename T>
217 for (
size_t i =
nlevel(); i != needs_levels; ++i)
221 for (
size_t i = 0; i !=
nlevel(); ++i)
222 level_[i].reduce(r,
true,
false);
224 if (pre_commit && post_commit) {
231 for (
size_t i = 0; i !=
nlevel(); ++i)
232 level_[i].reduce(r,
false,
true);
242 template <
typename T>
251 for (
size_t i = 0; i !=
self.nlevel(); ++i)
252 serialize(s, std::to_string(i),
self.level_[i]);
261 template <
typename T>
272 self.level_.resize(new_nlevel);
275 for (
size_t i = 0; i !=
self.nlevel(); ++i)
280 new_size =
self.size();
292 template <
typename T>
293 std::ostream &operator<<(std::ostream &str, const autocorr_result<T> &
self)
301 str <<
self.mean() <<
" +- " <<
self.stderror();
306 str <<
"\n " << curr;
311 template std::ostream &operator<<(std::ostream &, const autocorr_result<double> &);
312 template std::ostream &operator<<(std::ostream &, const autocorr_result<std::complex<double>> &);
const level_acc_type & level(size_t i) const
autocorr_acc(size_t size=1, size_t batch_size=1, size_t granularity=2)
void set_batch_size(size_t batch_size)
typename bind< circular_var, T >::var_type var_type
void check_valid(const Acc &acc)
const level_result_type & level(size_t i) const
void set_size(size_t size)
std::enable_if<!is_sequence< T >::value, std::size_t >::type size(T const &)
size_t find_level(size_t min_samples) const
void reduce(const reducer &r)
void add(const computed< T > &source, size_t count)
void deserialize(deserializer &, const std::string &, autocorr_result< T > &)
virtual long get_max(long value) const =0
column< var_type > tau() const
mean_type< T >::type mean(T const &arg)
virtual void commit() const =0
void finalize_to(autocorr_result< T > &result)
void serialize(serializer &, const std::string &, const autocorr_result< T > &)
autocorr_acc & operator<<(const computed< T > &src)
T & get_format(std::ios_base &stream, T initial_value=T())
void set_granularity(size_t granularity)
column< var_type > var() const
virtual void read(const std::string &key, ndview< double >)=0
bind< circular_var, T >::var_type var_type
bool operator==(const autocorr_result< T > &r1, const autocorr_result< T > &r2)
virtual reducer_setup get_setup() const =0
virtual void enter(const std::string &group)=0
T r(T x, T y=T(), T z=T())
autocorr_result< T > result() const
virtual void enter(const std::string &group)=0
column< var_type > stderror() const
size_t batch_size(size_t level) const
autocorr_result< T > finalize()