QMCPACK
BsplineOneDimSolvers.h File Reference
+ Include dependency graph for BsplineOneDimSolvers.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SolvePeriodicInterp1D< T >
 dummy declaration to be specialized More...
 
struct  SolvePeriodicInterp1D< double >
 
struct  SolvePeriodicInterp1D< std::complex< double > >
 
struct  SolveFirstDerivInterp1D< T >
 
struct  SolveFirstDerivInterp1D< double >
 
struct  SolveFirstDerivInterp1D< std::complex< double > >
 
struct  SolveFirstDerivInterp1D< float >
 
struct  SolveFirstDerivInterp1D< std::complex< float > >
 

Functions

template<typename T >
void FuncSolvePeriodicInterp1D (const std::vector< T > &data, std::vector< T > &p)
 

Class Documentation

◆ SolvePeriodicInterp1D

struct SolvePeriodicInterp1D

template<typename T>
struct SolvePeriodicInterp1D< T >

dummy declaration to be specialized

Specializations for double and std::complex<double>

Definition at line 24 of file BsplineOneDimSolvers.h.

+ Collaboration diagram for SolvePeriodicInterp1D< T >:

◆ SolveFirstDerivInterp1D

struct SolveFirstDerivInterp1D

template<typename T>
struct SolveFirstDerivInterp1D< T >

Definition at line 130 of file BsplineOneDimSolvers.h.

+ Collaboration diagram for SolveFirstDerivInterp1D< T >:

Function Documentation

◆ FuncSolvePeriodicInterp1D()

void FuncSolvePeriodicInterp1D ( const std::vector< T > &  data,
std::vector< T > &  p 
)
inline

Definition at line 28 of file BsplineOneDimSolvers.h.

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

Referenced by SolvePeriodicInterp1D< double >::apply().

29 {
30  const T ratio = 0.25;
31  int N = data.size();
32  std::vector<T> d(N), gamma(N), mu(N);
33  //d = 1.5*data;
34  for (int i = 0; i < N; i++)
35  d[i] = 1.5 * data[i];
36  // First, eliminate leading coefficients
37  gamma[0] = ratio;
38  mu[0] = ratio;
39  mu[N - 1] = ratio;
40  gamma[N - 1] = 1.0;
41  for (int row = 1; row < (N - 1); row++)
42  {
43  double diag = 1.0 - mu[row - 1] * ratio;
44  double diagInv = 1.0 / diag;
45  gamma[row] = -ratio * gamma[row - 1] * diagInv;
46  mu[row] = diagInv * ratio;
47  d[row] = diagInv * (d[row] - ratio * d[row - 1]);
48  // Last row
49  d[N - 1] -= mu[N - 1] * d[row - 1];
50  gamma[N - 1] -= mu[N - 1] * gamma[row - 1];
51  mu[N - 1] = -mu[N - 1] * mu[row - 1];
52  }
53  // Last row: gamma(N-1) hold diagonal element
54  mu[N - 1] += ratio;
55  gamma[N - 1] -= mu[N - 1] * (mu[N - 2] + gamma[N - 2]);
56  d[N - 1] -= mu[N - 1] * d[N - 2];
57  p[N - 1] = d[N - 1] / gamma[N - 1];
58  // Now go back upward, back substituting
59  for (int row = N - 2; row >= 0; row--)
60  p[row] = d[row] - mu[row] * p[row + 1] - gamma[row] * p[N - 1];
61 }