QMCPACK
test_grid_functor.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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
8 //
9 // File created by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
17 
18 
19 #include <stdio.h>
20 #include <string>
21 #include <sstream>
22 
23 using std::string;
24 using std::stringstream;
25 
26 namespace qmcplusplus
27 {
28 TEST_CASE("double_1d_grid_functor", "[numerics]")
29 {
30  LinearGrid<double> grid;
32 
33  grid.set(0.0, 1.0, 3);
34 
35  REQUIRE(grid.size() == 3);
36  REQUIRE(grid.rmin() == 0.0);
37  REQUIRE(grid.rmax() == 1.0);
38  CHECK(grid.dh() == Approx(0.5));
39  CHECK(grid.dr(1) == Approx(0.5));
40 }
41 
42 TEST_CASE("double_1d_grid_functor_vs_n", "[numerics]")
43 {
44  for (int n = 2; n < 5; n++)
45  {
46  stringstream sec_name;
47  sec_name << "grid size " << n;
48  SECTION(sec_name.str())
49  {
50  LinearGrid<double> grid;
51  grid.set(0.0, 1.0, n);
52  REQUIRE(grid.size() == n);
53  REQUIRE(grid.rmin() == 0.0);
54  REQUIRE(grid.rmax() == 1.0);
55  CHECK(grid.dh() == Approx(1.0 / (n - 1)));
56  CHECK(grid.dr(0) == Approx(1.0 / (n - 1)));
57  }
58  }
59 }
60 
61 } // namespace qmcplusplus
T rmin() const
return the first grid point
One-Dimensional linear-grid.
void set(T ri, T rf, int n) override
Set the grid given the parameters.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Implement One-Dimensional function on a radial grid.
std::unique_ptr< OneDimGridBase< T, CT > > makeClone() const override
TEST_CASE("complex_helper", "[type_traits]")
T dh() const
return the differential spacing of the grid
Decalaration of One-Dimesional grids.
REQUIRE(std::filesystem::exists(filename))
int size() const
returns the size of the grid
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
T rmax() const
return the last grid point
T dr(int i) const
returns