QMCPACK
test_SplineBound.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, mdewing@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 #include "Numerics/SplineBound.hpp"
15 
16 namespace qmcplusplus
17 {
18 template<typename T>
20 {
21  T x = 2.2;
22  T dx;
23  int ind;
24  int ng = 10;
25  getSplineBound(x, ng, ind, dx);
26  CHECK(dx == Approx(0.2));
27  REQUIRE(ind == 2);
28 
29  // check clamping to a maximum index value
30  x = 10.5;
31  getSplineBound(x, ng, ind, dx);
32  CHECK(dx == Approx(0.5));
33  REQUIRE(ind == 10);
34 
35  x = 11.5;
36  getSplineBound(x, ng, ind, dx);
37  CHECK(dx == Approx(1.0));
38  REQUIRE(ind == 10);
39 
40  // check clamping to a zero index value
41  x = -1.3;
42  getSplineBound(x, ng, ind, dx);
43  CHECK(dx == Approx(0.0));
44  REQUIRE(ind == 0);
45 }
46 
47 TEST_CASE("getSplineBound double", "[numerics]") { test_spline_bounds<double>(); }
48 TEST_CASE("getSplineBound float", "[numerics]") { test_spline_bounds<float>(); }
49 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
REQUIRE(std::filesystem::exists(filename))
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
void getSplineBound(const T x, const int nmax, int &ind, TRESIDUAL &dx)
break x into the integer part and residual part and apply bounds
Definition: SplineBound.hpp:37
void test_spline_bounds()