ALPSCore reference
bundle.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1998-2018 ALPS Collaboration. See COPYRIGHT.TXT
3  * All rights reserved. Use is subject to license terms. See LICENSE.TXT
4  * For use in publications, see ACKNOWLEDGE.TXT
5  */
6 #pragma once
7 
8 #include <alps/alea/core.hpp>
9 #include <alps/alea/util.hpp>
10 
11 namespace alps { namespace alea {
12 
19 template <typename T>
20 class bundle
21 {
22 public:
23  bundle(size_t size, size_t target) : sum_(size), target_(target) { reset(); }
24 
26  void reset() { sum_.fill(0); count_ = 0; }
27 
28  bool is_full() { return count_ >= target_; }
29 
31  size_t size() const { return sum_.rows(); }
32 
33  size_t &target() { return target_; }
34 
35  const size_t &target() const { return target_; }
36 
37  size_t &count() { return count_; }
38 
39  size_t count() const { return count_; }
40 
41  column<T> &sum() { return sum_; }
42 
43  const column<T> &sum() const { return sum_; }
44 
45 private:
46  column<T> sum_;
47  size_t target_, count_;
48 };
49 
50 }}
size_t size() const
Definition: bundle.hpp:31
column< T > & sum()
Definition: bundle.hpp:41
const column< T > & sum() const
Definition: bundle.hpp:43
size_t & target()
Definition: bundle.hpp:33
size_t count() const
Definition: bundle.hpp:39
const size_t & target() const
Definition: bundle.hpp:35
bundle(size_t size, size_t target)
Definition: bundle.hpp:23
size_t & count()
Definition: bundle.hpp:37