QMCPACK
test_SizeLimitedDataQueue.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2023 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #include "catch.hpp"
13 #include "SizeLimitedDataQueue.hpp"
14 
15 namespace qmcplusplus
16 {
17 
18 TEST_CASE("SizeLimitedDataQueue", "[estimators]")
19 {
20  SizeLimitedDataQueue<double, 1> weight_and_energy(3);
21  CHECK(weight_and_energy.size() == 0);
22  {
23  weight_and_energy.push({1.0, {2.0}});
24  CHECK(weight_and_energy.size() == 1);
25  auto avg = weight_and_energy.weighted_avg();
26  CHECK(Approx(avg[0]) == 2.0);
27  }
28  {
29  weight_and_energy.push({3.0, {1.0}});
30  CHECK(weight_and_energy.size() == 2);
31  auto avg = weight_and_energy.weighted_avg();
32  CHECK(Approx(avg[0]) == 1.25);
33  }
34  {
36  weight_and_energy.push(std::move(temp));
37  CHECK(weight_and_energy.size() == 3);
38  auto avg = weight_and_energy.weighted_avg();
39  CHECK(Approx(avg[0]) == 1.444444444);
40  }
41  {
42  weight_and_energy.push({0.5, {3.0}});
43  CHECK(weight_and_energy.size() == 3);
44  auto avg = weight_and_energy.weighted_avg();
45  CHECK(Approx(avg[0]) == 1.5);
46  }
47 }
48 
49 } // namespace qmcplusplus
collect data with a history limit.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
auto size() const
return the number of records
void push(const value_type &val)
add a new record
auto weighted_avg() const
return weighted average