QMCPACK
MinTest Class Reference
+ Collaboration diagram for MinTest:

Public Member Functions

 MinTest (double value=0.0)
 
RealType one_cycle (RealType x)
 
void find_bracket (RealType x0)
 
void find_bracket_bound (RealType x0, RealType bound)
 
void find_min (RealType x0)
 

Public Attributes

RealType min_value
 

Detailed Description

Definition at line 24 of file test_min_oned.cpp.

Constructor & Destructor Documentation

◆ MinTest()

MinTest ( double  value = 0.0)
inline

Definition at line 27 of file test_min_oned.cpp.

27 : min_value(value) {}

Member Function Documentation

◆ find_bracket()

void find_bracket ( RealType  x0)
inline

Definition at line 31 of file test_min_oned.cpp.

References bracket_minimum(), MinTest::one_cycle(), and qmcplusplus::REQUIRE().

Referenced by qmcplusplus::TEST_CASE().

32  {
33  auto bracket = bracket_minimum([this](RealType x) -> RealType { return one_cycle(x); }, x0);
34  REQUIRE(bracket.success == true);
35  RealType xa = bracket.a;
36  RealType xb = bracket.b;
37  RealType xc = bracket.c;
38  //std::cout << " xa = " << xa;
39  //std::cout << " xb = " << xb;
40  //std::cout << " xc = " << xc;
41  //std::cout << std::endl;
42 
43  REQUIRE(xa < xb);
44  REQUIRE(xb < xc);
45 
46  // For a starting point of 1.3
47  //CHECK(xa == Approx(-0.0041));
48  //CHECK(xb == Approx( 0.03615));
49  //CHECK(xc == Approx(-0.04435));
50 
51 
52  RealType fa = one_cycle(xa);
53  RealType fb = one_cycle(xb);
54  RealType fc = one_cycle(xc);
55 
56  REQUIRE(fa > fb);
57  REQUIRE(fc > fb);
58  }
Bracket_min_t< T > bracket_minimum(const F &f, T initial_value, T bound_max=-1.0)
RealType one_cycle(RealType x)
REQUIRE(std::filesystem::exists(filename))
QMCTraits::RealType RealType

◆ find_bracket_bound()

void find_bracket_bound ( RealType  x0,
RealType  bound 
)
inline

Definition at line 61 of file test_min_oned.cpp.

References bracket_minimum(), MinTest::one_cycle(), and qmcplusplus::REQUIRE().

Referenced by qmcplusplus::TEST_CASE().

62  {
63  auto bracket = bracket_minimum([this](RealType x) -> RealType { return one_cycle(x); }, x0, bound);
64  REQUIRE(bracket.success == false);
65  }
Bracket_min_t< T > bracket_minimum(const F &f, T initial_value, T bound_max=-1.0)
RealType one_cycle(RealType x)
REQUIRE(std::filesystem::exists(filename))
QMCTraits::RealType RealType

◆ find_min()

void find_min ( RealType  x0)
inline

Definition at line 67 of file test_min_oned.cpp.

References bracket_minimum(), qmcplusplus::CHECK(), find_minimum(), qmcplusplus::Units::distance::m, MinTest::min_value, and MinTest::one_cycle().

Referenced by qmcplusplus::TEST_CASE().

68  {
69  auto bracket = bracket_minimum([this](RealType x) -> RealType { return one_cycle(x); }, x0);
70  auto m = find_minimum([this](RealType x) -> RealType { return one_cycle(x); }, bracket);
71 
72  CHECK(m.first == Approx(min_value));
73  CHECK(m.second == Approx(0.0));
74  }
Bracket_min_t< T > bracket_minimum(const F &f, T initial_value, T bound_max=-1.0)
RealType one_cycle(RealType x)
std::pair< T, T > find_minimum(const F &f, Bracket_min_t< T > &bracket)
QMCTraits::RealType RealType
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))

◆ one_cycle()

RealType one_cycle ( RealType  x)
inline

Definition at line 29 of file test_min_oned.cpp.

References MinTest::min_value.

Referenced by MinTest::find_bracket(), MinTest::find_bracket_bound(), and MinTest::find_min().

29 { return (x - min_value) * (x - min_value); }

Member Data Documentation

◆ min_value

RealType min_value

Definition at line 28 of file test_min_oned.cpp.

Referenced by MinTest::find_min(), and MinTest::one_cycle().


The documentation for this class was generated from the following file: