QMCPACK
SolvePeriodicInterp1D< double > Struct Template Reference
+ Collaboration diagram for SolvePeriodicInterp1D< double >:

Static Public Member Functions

static void apply (const std::vector< double > &data, std::vector< double > &p)
 
template<typename CT >
static void apply (const CT &data, CT &p, int N)
 

Detailed Description

template<>
struct SolvePeriodicInterp1D< double >

Definition at line 64 of file BsplineOneDimSolvers.h.

Member Function Documentation

◆ apply() [1/2]

static void apply ( const std::vector< double > &  data,
std::vector< double > &  p 
)
inlinestatic

Definition at line 66 of file BsplineOneDimSolvers.h.

References FuncSolvePeriodicInterp1D().

67  {
69  }
void FuncSolvePeriodicInterp1D(const std::vector< T > &data, std::vector< T > &p)

◆ apply() [2/2]

static void apply ( const CT &  data,
CT &  p,
int  N 
)
inlinestatic

Definition at line 72 of file BsplineOneDimSolvers.h.

References qmcplusplus::Units::force::N.

73  {
74  const double ratio = 0.25;
75  CT d(N), gamma(N), mu(N);
76  for (int i = 0; i < N; i++)
77  d[i] = 1.5 * data[i];
78  // First, eliminate leading coefficients
79  gamma[0] = ratio;
80  mu[0] = ratio;
81  mu[N - 1] = ratio;
82  gamma[N - 1] = 1.0;
83  for (int row = 1; row < (N - 1); row++)
84  {
85  double diag = 1.0 - mu[row - 1] * ratio;
86  double diagInv = 1.0 / diag;
87  gamma[row] = -ratio * gamma[row - 1] * diagInv;
88  mu[row] = diagInv * ratio;
89  d[row] = diagInv * (d[row] - ratio * d[row - 1]);
90  // Last row
91  d[N - 1] -= mu[N - 1] * d[row - 1];
92  gamma[N - 1] -= mu[N - 1] * gamma[row - 1];
93  mu[N - 1] = -mu[N - 1] * mu[row - 1];
94  }
95  // Last row: gamma(N-1) hold diagonal element
96  mu[N - 1] += ratio;
97  gamma[N - 1] -= mu[N - 1] * (mu[N - 2] + gamma[N - 2]);
98  d[N - 1] -= mu[N - 1] * d[N - 2];
99  p[N] = d[N - 1] / gamma[N - 1];
100  // Now go back upward, back substituting
101  for (int row = N - 2; row >= 0; row--)
102  p[row + 1] = d[row] - mu[row] * p[row + 2] - gamma[row] * p[N];
103  }

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