QMCPACK
test_transform.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) 2018 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Mark Dewing, mewing@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 #include <stdio.h>
16 #include <string>
17 #include <iostream>
18 
19 #include "Numerics/Transform2GridFunctor.h"
21 
22 using std::string;
23 
24 namespace qmcplusplus
25 {
26 class Input
27 {
28 public:
29  using real_type = double;
30 
31  double f(double r) { return r * r; }
32 
33  double df(double r) { return 2 * r; }
34 };
35 
36 TEST_CASE("transform2gridfunctor", "[numerics]")
37 {
39  using OutputType = OneDimQuinticSpline<double>;
40 
41  auto agrid = std::make_unique<LogGrid<double>>();
42  agrid->set(0.1, 10, 10);
43  OutputType output(std::move(agrid));
44  Input input;
45  Transform2GridFunctor<Input, OutputType> transform(input, output);
46  double rmin = 0.1;
47  double rmax = 10;
48  int npts = 10;
49  transform.generate(rmin, rmax, npts);
50  CHECK(output.splint(0.1) == Approx(0.01));
51  CHECK(output.splint(0.15) == Approx(0.0225));
52  CHECK(output.splint(7.0) == Approx(49.0));
53  CHECK(output.splint(10) == Approx(100.0));
54 }
55 } // namespace qmcplusplus
double f(double r)
One-Dimensional linear-grid.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
An abstract base class to implement a One-Dimensional grid.
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
testing::ValidSpinDensityInput input
double df(double r)