CASM  1.1.0
A Clusters Approach to Statistical Mechanics
MCData.hh
Go to the documentation of this file.
1 #ifndef MCData_HH
2 #define MCData_HH
3 
5 #include "casm/global/eigen.hh"
7 
8 namespace CASM {
9 namespace Monte {
10 
12 class MCData {
13  public:
15 
17  MCData() : MCData(1) {}
18 
21  : m_observation(Eigen::VectorXd::Zero(count)), m_size(0) {}
22 
24  void clear() { m_size = 0; }
25 
27  void push_back(double value) {
28  m_observation(m_size) = value;
29  ++m_size;
30 
31  // re-size as necessary by doubling reserved space
32  if (m_size == m_observation.size()) {
33  Eigen::VectorXd tmp = Eigen::VectorXd::Zero(m_observation.size() * 2);
34  tmp.head(m_observation.size()) = m_observation;
35  m_observation = tmp;
36  }
37  }
38 
40  Eigen::VectorBlock<const Eigen::VectorXd> observations() const {
41  return m_observation.head(m_size);
42  }
43 
45  size_type size() const { return m_size; }
46 
47  private:
51 
54 };
55 
59  public:
61 
64 
66  MCDataEquilibration(const Eigen::VectorXd &observations, double prec);
67 
68  bool is_equilibrated() const { return m_is_equilibrated; }
69 
71 
72  private:
75 };
76 
80  public:
82 
85 
87  MCDataConvergence(const Eigen::VectorXd &observations, double conf);
88 
98  bool is_converged(double prec) const { return m_calculated_prec <= prec; }
99 
101  double mean() const { return m_mean; }
102 
104  double squared_norm() const { return m_squared_norm; }
105 
114  double calculated_precision() const { return m_calculated_prec; }
115 
116  private:
119  std::tuple<bool, double, double> _calc_rho(
120  const Eigen::VectorXd &observations);
121 
123  double m_mean;
126 };
127 
128 } // namespace Monte
129 } // namespace CASM
130 
131 #endif
Index count
Checks if a range of observations have converged.
Definition: MCData.hh:79
bool is_converged(double prec) const
Returns true if converged to the requested level.
Definition: MCData.hh:98
std::tuple< bool, double, double > _calc_rho(const Eigen::VectorXd &observations)
Try to find rho = pow(2.0, -1.0/i), using min i such that CoVar[i]/CoVar[0] <= 0.5.
Definition: MCData.cc:170
double calculated_precision() const
Calculated precision of <X>
Definition: MCData.hh:114
MCData::size_type size_type
Definition: MCData.hh:81
MCDataConvergence()
Default constructor.
Definition: MCData.hh:84
double squared_norm() const
<X*X>
Definition: MCData.hh:104
double mean() const
<X>
Definition: MCData.hh:101
Checks if a range of observations have equilibrated.
Definition: MCData.hh:58
MCDataEquilibration()
Default constructor.
Definition: MCData.hh:63
size_type equilibration_samples() const
Definition: MCData.hh:70
MCData::size_type size_type
Definition: MCData.hh:60
MCData stores observations of properties.
Definition: MCData.hh:12
MCData(size_type count)
Constructor with initial buffer size 'count'.
Definition: MCData.hh:20
size_type m_size
The number of observations.
Definition: MCData.hh:53
MCData()
Default constructor.
Definition: MCData.hh:17
Eigen::VectorXd m_observation
vector of all observations (includes m_size observations, and the rest is reserved space)
Definition: MCData.hh:50
void clear()
Forget all the observed values (does not resize reserved space)
Definition: MCData.hh:24
Eigen::VectorBlock< const Eigen::VectorXd > observations() const
Return all observations.
Definition: MCData.hh:40
Monte::size_type size_type
Definition: MCData.hh:14
size_type size() const
Number of observations.
Definition: MCData.hh:45
void push_back(double value)
Add an observation.
Definition: MCData.hh:27
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::VectorXd VectorXd