13 namespace alps {
namespace alea {
15 template <
typename T,
typename Str>
23 template <
typename T,
typename Str>
32 template <
typename T,
typename Str>
36 data2_ -= count_ * internal::outer<bind<Str, T> >(data_, data_);
41 const double nunbiased = count_ - count2_/count_;
43 data2_ = data2_.array().isNaN().select(data2_, INFINITY);
46 data2_ = data2_ / nunbiased;
49 template <
typename T,
typename Str>
59 const double nunbiased = count_ - count2_/count_;
61 data2_ = data2_.array().isNaN().select(data2_, 0);
63 data2_ = data2_ * nunbiased;
65 data2_ += count_ * internal::outer<bind<Str, T> >(data_, data_);
74 template <
typename T,
typename Str>
77 , current_(size, batch_size)
81 template <
typename T,
typename Str>
83 : store_(other.store_ ? new
cov_data<T,Str>(*other.store_) : nullptr)
84 , current_(other.current_)
87 template <
typename T,
typename Str>
90 store_.reset(other.store_ ?
new cov_data<T,Str>(*other.store_) :
nullptr);
91 current_ = other.current_;
95 template <
typename T,
typename Str>
105 template <
typename T,
typename Str>
113 template <
typename T,
typename Str>
121 template <
typename T,
typename Str>
132 template <
typename T,
typename Str>
143 store_->data() += other_store.
data();
144 store_->data2() += other_store.
data2();
145 store_->count() += other_store.
count();
146 store_->count2() += other_store.
count2();
151 template <
typename T,
typename Str>
160 template <
typename T,
typename Str>
168 template <
typename T,
typename Str>
174 if (current_.
count() != 0)
178 result.store_.reset();
179 result.store_.swap(store_);
182 result.store_->convert_to_mean();
185 template <
typename T,
typename Str>
189 store_->data().noalias() += current_.
sum();
190 store_->data2().noalias() +=
191 internal::outer<bind<Str, T> >(current_.
sum(), current_.
sum())
193 store_->count() += current_.
count();
194 store_->count2() += current_.
count() * current_.
count();
206 template <
typename T,
typename Str>
208 : store_(other.store_ ? new
cov_data<T,Str>(*other.store_) : nullptr)
211 template <
typename T,
typename Str>
214 store_.reset(other.store_ ?
new cov_data<T,Str>(*other.store_) :
nullptr);
218 template <
typename T,
typename Strategy>
232 const cov_result<std::complex<double>, circular_var> &r2);
234 const cov_result<std::complex<double>, elliptic_var> &r2);
236 template <
typename T,
typename Str>
240 return (store_->data2().diagonal().real() /
observations()).cwiseSqrt();
243 template <
typename T,
typename Str>
249 store_->convert_to_sum();
250 r.
reduce(
view<T>(store_->data().data(), store_->data().rows()));
255 if (pre_commit && post_commit) {
261 store_->convert_to_mean();
272 template <
typename T,
typename Str>
278 serialize(s,
"@size",
self.store_->data_.size());
279 serialize(s,
"count",
self.store_->count_);
280 serialize(s,
"count2",
self.store_->count2_);
282 serialize(s,
"value",
self.store_->data_);
285 serialize(s,
"cov",
self.store_->data2_);
288 template <
typename T,
typename Str>
297 if (!
self.
valid() ||
self.
size() != new_size)
319 template <
typename T,
typename Str>
320 std::ostream &operator<<(std::ostream &str, const cov_result<T,Str> &
self)
327 str <<
self.mean() <<
" +- " <<
self.stderror();
329 str <<
"\nSigma = " <<
self.cov();
333 template std::ostream &operator<<(std::ostream &, const cov_result<double, circular_var> &);
334 template std::ostream &operator<<(std::ostream &, const cov_result<std::complex<double>, circular_var> &);
335 template std::ostream &operator<<(std::ostream &, const cov_result<std::complex<double>, elliptic_var> &);
void set_size(size_t size)
size_t batch_size() const
const cov_matrix_type & data2() const
void check_valid(const Acc &acc)
cov_result< T, Strategy > finalize()
std::enable_if<!is_sequence< T >::value, std::size_t >::type size(T const &)
cov_acc(size_t size=1, size_t batch_size=1)
cov_result< T, Strategy > result() const
cov_acc & operator<<(const computed< T > &src)
cov_acc & operator=(const cov_acc &other)
virtual void commit() const =0
cov_result & operator=(const cov_result &other)
bind< Strategy, T >::var_type var_type
T & get_format(std::ios_base &stream, T initial_value=T())
column< var_type > stderror() const
double observations() const
friend void deserialize(deserializer &, const std::string &, cov_result &)
virtual void read(const std::string &key, ndview< double >)=0
virtual void add_to(view< T > out) const =0
const column< value_type > & data() const
void reduce(const reducer &r)
bool operator==(const autocorr_result< T > &r1, const autocorr_result< T > &r2)
void finalize_to(cov_result< T, Strategy > &result)
virtual reducer_setup get_setup() const =0
void set_batch_size(size_t batch_size)
friend void serialize(serializer &, const std::string &, const cov_result &)
virtual void enter(const std::string &group)=0
T r(T x, T y=T(), T z=T())
virtual void reduce(view< double > data) const =0
void add(const computed< T > &source, size_t count)
virtual void enter(const std::string &group)=0
const cov_data< T, Strategy > & store() const