QMCPACK
RungeKutta< IntegrandClass, T > Class Template Reference
+ Collaboration diagram for RungeKutta< IntegrandClass, T >:

Public Member Functions

void Integrate (const Grid &grid, int startPoint, int endPoint, Array< T, 1 > &result, bool scale=true)
 
 RungeKutta (IntegrandClass &integrand)
 

Private Member Functions

void IntegrateForw (const Grid &grid, int startPoint, int endPoint, Array< T, 1 > &result, bool scale=true)
 
void IntegrateRev (const Grid &grid, int startPoint, int endPoint, Array< T, 1 > &result, bool scale=true)
 

Private Attributes

IntegrandClass & Integrand
 

Detailed Description

template<class IntegrandClass, class T>
class RungeKutta< IntegrandClass, T >

Definition at line 29 of file RungeKutta.h.

Constructor & Destructor Documentation

◆ RungeKutta()

RungeKutta ( IntegrandClass &  integrand)
inline

Definition at line 101 of file RungeKutta.h.

101  : Integrand(integrand)
102  {
103  // Do nothing
104  }
IntegrandClass & Integrand
Definition: RungeKutta.h:32

Member Function Documentation

◆ Integrate()

void Integrate ( const Grid grid,
int  startPoint,
int  endPoint,
Array< T, 1 > &  result,
bool  scale = true 
)
inline

Definition at line 93 of file RungeKutta.h.

References RungeKutta< IntegrandClass, T >::IntegrateForw(), and RungeKutta< IntegrandClass, T >::IntegrateRev().

94  {
95  if (endPoint > startPoint)
96  IntegrateForw(grid, startPoint, endPoint, result, scale);
97  else
98  IntegrateRev(grid, startPoint, endPoint, result, scale);
99  }
void IntegrateForw(const Grid &grid, int startPoint, int endPoint, Array< T, 1 > &result, bool scale=true)
Definition: RungeKutta.h:35
void IntegrateRev(const Grid &grid, int startPoint, int endPoint, Array< T, 1 > &result, bool scale=true)
Definition: RungeKutta.h:63

◆ IntegrateForw()

void IntegrateForw ( const Grid grid,
int  startPoint,
int  endPoint,
Array< T, 1 > &  result,
bool  scale = true 
)
inlineprivate

Definition at line 35 of file RungeKutta.h.

References RungeKutta< IntegrandClass, T >::Integrand, and mag().

Referenced by RungeKutta< IntegrandClass, T >::Integrate().

36  {
37  T k1, k2, k3, k4;
38  T y, yplus;
39  double h, x;
40 
41  const static double OneSixth = 1.0 / 6.0;
42  const static double OneThird = 1.0 / 3.0;
43 
44  for (int i = startPoint; i < endPoint; i++)
45  {
46  x = grid(i);
47  h = grid(i + 1) - x;
48  y = result(i);
49  k1 = h * Integrand(x, y);
50  yplus = y + 0.5 * k1;
51  k2 = h * Integrand(x + 0.5 * h, yplus);
52  yplus = y + 0.5 * k2;
53  k3 = h * Integrand(x + 0.5 * h, yplus);
54  yplus = y + k3;
55  k4 = h * Integrand(x + h, yplus);
56  result(i + 1) = y + (OneSixth * (k1 + k4) + OneThird * (k2 + k3));
57  if (scale && mag(result(i + 1)) > 1.0e10)
58  for (int j = startPoint; j <= endPoint; j++)
59  result(j) *= 1.0e-10;
60  }
61  }
IntegrandClass & Integrand
Definition: RungeKutta.h:32
double mag(double x)
Definition: RungeKutta.h:22

◆ IntegrateRev()

void IntegrateRev ( const Grid grid,
int  startPoint,
int  endPoint,
Array< T, 1 > &  result,
bool  scale = true 
)
inlineprivate

Definition at line 63 of file RungeKutta.h.

References RungeKutta< IntegrandClass, T >::Integrand, and mag().

Referenced by RungeKutta< IntegrandClass, T >::Integrate().

64  {
65  T k1, k2, k3, k4;
66  T y, yplus;
67  double h, x;
68 
69  const static double OneSixth = 1.0 / 6.0;
70  const static double OneThird = 1.0 / 3.0;
71 
72  for (int i = startPoint; i > endPoint; i--)
73  {
74  x = grid(i);
75  h = grid(i - 1) - x;
76  y = result(i);
77  k1 = h * Integrand(x, y);
78  yplus = y + 0.5 * k1;
79  k2 = h * Integrand(x + 0.5 * h, yplus);
80  yplus = y + 0.5 * k2;
81  k3 = h * Integrand(x + 0.5 * h, yplus);
82  yplus = y + k3;
83  k4 = h * Integrand(x + h, yplus);
84  result(i - 1) = y + (OneSixth * (k1 + k4) + OneThird * (k2 + k3));
85  if (scale && mag(result(i - 1)) > 1.0e10)
86  for (int j = startPoint; j >= endPoint; j--)
87  result(j) *= 1.0e-10;
88  }
89  }
IntegrandClass & Integrand
Definition: RungeKutta.h:32
double mag(double x)
Definition: RungeKutta.h:22

Member Data Documentation

◆ Integrand

IntegrandClass& Integrand
private

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