QMCPACK
CubicBspline< T, GRIDTYPE, BC > Struct Template Reference
+ Inheritance diagram for CubicBspline< T, GRIDTYPE, BC >:
+ Collaboration diagram for CubicBspline< T, GRIDTYPE, BC >:

Public Types

using point_type = typename CubicBsplineGrid< T, GRIDTYPE, BC >::point_type
 
using value_type = typename CubicBsplineGrid< T, GRIDTYPE, BC >::value_type
 
using container_type = typename CubicBsplineGrid< T, GRIDTYPE, BC >::container_type
 

Public Member Functions

 CubicBspline ()
 default constructor More...
 
void Init (point_type start, point_type end, const container_type &datain, bool closed)
 
void Init (point_type start, point_type end, const container_type &datain, bool closed, T yp1, T ypn)
 
value_type getValue (point_type x)
 
value_type getDeriv (point_type x)
 
value_type getDeriv2 (point_type x)
 
value_type getDeriv3 (point_type x)
 
value_type operator() (T x)
 
value_type splint (T x)
 
value_type splint (point_type x, value_type &dy, value_type &d2y)
 
value_type interpolate (value_type p0, value_type p1, value_type p2, value_type p3, value_type &dy, value_type &d2y)
 
value_type interpolate0 (value_type p0, value_type p1, value_type p2, value_type p3)
 
value_type interpolate1 (value_type p0, value_type p1, value_type p2, value_type p3)
 
value_type interpolate2 (value_type p0, value_type p1, value_type p2, value_type p3)
 

Public Attributes

int i0
 index of current grid point More...
 
int i1
 
int i2
 
int i3
 
value_type OffSet
 constant shift More...
 
point_type A [16]
 coefficients More...
 
point_type dA [12]
 
point_type d2A [8]
 
point_type d3A [4]
 
container_type P
 The control points. More...
 

Detailed Description

template<class T, unsigned GRIDTYPE, unsigned BC>
struct CubicBspline< T, GRIDTYPE, BC >

Definition at line 23 of file CubicBspline.h.

Member Typedef Documentation

◆ container_type

using container_type = typename CubicBsplineGrid<T, GRIDTYPE, BC>::container_type

Definition at line 27 of file CubicBspline.h.

◆ point_type

using point_type = typename CubicBsplineGrid<T, GRIDTYPE, BC>::point_type

Definition at line 25 of file CubicBspline.h.

◆ value_type

using value_type = typename CubicBsplineGrid<T, GRIDTYPE, BC>::value_type

Definition at line 26 of file CubicBspline.h.

Constructor & Destructor Documentation

◆ CubicBspline()

CubicBspline ( )
inline

default constructor

Initialize linear coefficients

Definition at line 46 of file CubicBspline.h.

References CubicBspline< T, GRIDTYPE, BC >::A, CubicBspline< T, GRIDTYPE, BC >::d2A, CubicBspline< T, GRIDTYPE, BC >::d3A, and CubicBspline< T, GRIDTYPE, BC >::dA.

46  : OffSet(0.0)
47  {
48  A[0] = -1.0 / 6.0;
49  A[1] = 3.0 / 6.0;
50  A[2] = -3.0 / 6.0;
51  A[3] = 1.0 / 6.0;
52  A[4] = 3.0 / 6.0;
53  A[5] = -6.0 / 6.0;
54  A[6] = 3.0 / 6.0;
55  A[7] = 0.0 / 6.0;
56  A[8] = -3.0 / 6.0;
57  A[9] = 0.0 / 6.0;
58  A[10] = 3.0 / 6.0;
59  A[11] = 0.0 / 6.0;
60  A[12] = 1.0 / 6.0;
61  A[13] = 4.0 / 6.0;
62  A[14] = 1.0 / 6.0;
63  A[15] = 0.0 / 6.0;
64  dA[0] = -0.5;
65  dA[1] = 1.5;
66  dA[2] = -1.5;
67  dA[3] = 0.5;
68  dA[4] = 1.0;
69  dA[5] = -2.0;
70  dA[6] = 1.0;
71  dA[7] = 0.0;
72  dA[8] = -0.5;
73  dA[9] = 0.0;
74  dA[10] = 0.5;
75  dA[11] = 0.0;
76  d2A[0] = -1.0;
77  d2A[1] = 3.0;
78  d2A[2] = -3.0;
79  d2A[3] = 1.0;
80  d2A[4] = 1.0;
81  d2A[5] = -2.0;
82  d2A[6] = 1.0;
83  d2A[7] = 0.0;
84  d3A[0] = -1.0;
85  d3A[1] = 3.0;
86  d3A[2] = -3.0;
87  d3A[3] = 1.0;
88  }
value_type OffSet
constant shift
Definition: CubicBspline.h:36
point_type dA[12]
Definition: CubicBspline.h:38
point_type d3A[4]
Definition: CubicBspline.h:38
point_type A[16]
coefficients
Definition: CubicBspline.h:38
point_type d2A[8]
Definition: CubicBspline.h:38

Member Function Documentation

◆ getDeriv()

value_type getDeriv ( point_type  x)
inline

Definition at line 108 of file CubicBspline.h.

References CubicBspline< T, GRIDTYPE, BC >::i0, CubicBspline< T, GRIDTYPE, BC >::interpolate1(), CubicBspline< T, GRIDTYPE, BC >::OffSet, and CubicBspline< T, GRIDTYPE, BC >::P.

109  {
110  if (this->getGridPoint(x, i0))
111  return interpolate1(P[i0], P[i0 + 1], P[i0 + 2], P[i0 + 3]);
112  else
113  return OffSet;
114  }
value_type OffSet
constant shift
Definition: CubicBspline.h:36
container_type P
The control points.
Definition: CubicBspline.h:40
int i0
index of current grid point
Definition: CubicBspline.h:34
value_type interpolate1(value_type p0, value_type p1, value_type p2, value_type p3)
Definition: CubicBspline.h:194

◆ getDeriv2()

value_type getDeriv2 ( point_type  x)
inline

Definition at line 116 of file CubicBspline.h.

References CubicBspline< T, GRIDTYPE, BC >::i0, CubicBspline< T, GRIDTYPE, BC >::interpolate2(), CubicBspline< T, GRIDTYPE, BC >::OffSet, and CubicBspline< T, GRIDTYPE, BC >::P.

117  {
118  if (this->getGridPoint(x, i0))
119  return interpolate2(P[i0], P[i0 + 1], P[i0 + 2], P[i0 + 3]);
120  else
121  return OffSet;
122  }
value_type OffSet
constant shift
Definition: CubicBspline.h:36
container_type P
The control points.
Definition: CubicBspline.h:40
int i0
index of current grid point
Definition: CubicBspline.h:34
value_type interpolate2(value_type p0, value_type p1, value_type p2, value_type p3)
Definition: CubicBspline.h:201

◆ getDeriv3()

value_type getDeriv3 ( point_type  x)
inline

Definition at line 124 of file CubicBspline.h.

References CubicBspline< T, GRIDTYPE, BC >::d2A, CubicBspline< T, GRIDTYPE, BC >::i0, CubicBspline< T, GRIDTYPE, BC >::i1, CubicBspline< T, GRIDTYPE, BC >::i2, CubicBspline< T, GRIDTYPE, BC >::i3, CubicBspline< T, GRIDTYPE, BC >::OffSet, and CubicBspline< T, GRIDTYPE, BC >::P.

125  {
126  if (this->getGridPoint(x, i0))
127  return GridDeltaInv * GridDeltaInv * GridDeltaInv *
128  (tp[3] * (d2A[0] * P[i0] + d2A[1] * P[i1] + d2A[2] * P[i2] + d2A[3] * P[i3]));
129  else
130  return OffSet;
131  }
value_type OffSet
constant shift
Definition: CubicBspline.h:36
container_type P
The control points.
Definition: CubicBspline.h:40
int i0
index of current grid point
Definition: CubicBspline.h:34
point_type d2A[8]
Definition: CubicBspline.h:38

◆ getValue()

value_type getValue ( point_type  x)
inline

Definition at line 100 of file CubicBspline.h.

References CubicBspline< T, GRIDTYPE, BC >::i0, CubicBspline< T, GRIDTYPE, BC >::interpolate0(), CubicBspline< T, GRIDTYPE, BC >::OffSet, and CubicBspline< T, GRIDTYPE, BC >::P.

Referenced by CubicBspline< T, GRIDTYPE, BC >::operator()().

101  {
102  if (this->getGridPoint(x, i0))
103  return interpolate0(P[i0], P[i0 + 1], P[i0 + 2], P[i0 + 3]);
104  else
105  return OffSet;
106  }
value_type OffSet
constant shift
Definition: CubicBspline.h:36
value_type interpolate0(value_type p0, value_type p1, value_type p2, value_type p3)
Definition: CubicBspline.h:186
container_type P
The control points.
Definition: CubicBspline.h:40
int i0
index of current grid point
Definition: CubicBspline.h:34

◆ Init() [1/2]

void Init ( point_type  start,
point_type  end,
const container_type datain,
bool  closed 
)
inline

Definition at line 90 of file CubicBspline.h.

References CubicBspline< T, GRIDTYPE, BC >::P.

Referenced by CubicSplineBasisSet< RT >::reset().

91  {
92  this->spline(start, end, datain, P, closed);
93  }
container_type P
The control points.
Definition: CubicBspline.h:40

◆ Init() [2/2]

void Init ( point_type  start,
point_type  end,
const container_type datain,
bool  closed,
yp1,
ypn 
)
inline

Definition at line 95 of file CubicBspline.h.

References CubicBspline< T, GRIDTYPE, BC >::P.

96  {
97  this->spline(start, end, yp1, ypn, datain, P);
98  }
container_type P
The control points.
Definition: CubicBspline.h:40

◆ interpolate()

value_type interpolate ( value_type  p0,
value_type  p1,
value_type  p2,
value_type  p3,
value_type dy,
value_type d2y 
)
inline

Definition at line 169 of file CubicBspline.h.

Referenced by CubicBspline< T, GRIDTYPE, BC >::splint().

175  {
176  dy = GridDeltaInv *
177  (tp[1] * (-0.5 * p0 + 1.5 * p1 - 1.5 * p2 + 0.5 * p3) + tp[2] * (p0 - 2.0 * p1 + p2) +
178  tp[3] * (-0.5 * p0 + 0.5 * p2));
179  d2y = GridDeltaInv2 * (tp[2] * (-p0 + 3.0 * p1 - 3.0 * p2 + p3) + tp[3] * (p0 - 2.0 * p1 + p2));
180  const point_type onesixth = 1.0 / 6.0;
181  return onesixth *
182  (tp[0] * (-p0 + 3.0 * p1 - 3.0 * p2 + p3) + tp[1] * (3.0 * p0 - 6.0 * p1 + 3.0 * p2) +
183  tp[2] * (-3.0 * p0 + 3.0 * p2) + tp[3] * (p0 + 4.0 * p1 + p2));
184  }
typename CubicBsplineGrid< T, GRIDTYPE, BC >::point_type point_type
Definition: CubicBspline.h:25

◆ interpolate0()

value_type interpolate0 ( value_type  p0,
value_type  p1,
value_type  p2,
value_type  p3 
)
inline

Definition at line 186 of file CubicBspline.h.

Referenced by CubicBspline< T, GRIDTYPE, BC >::getValue(), and CubicBspline< T, GRIDTYPE, BC >::splint().

187  {
188  const point_type onesixth = 1.0 / 6.0;
189  return onesixth *
190  (tp[0] * (-p0 + 3.0 * p1 - 3.0 * p2 + p3) + tp[1] * (3.0 * p0 - 6.0 * p1 + 3.0 * p2) +
191  tp[2] * (-3.0 * p0 + 3.0 * p2) + tp[3] * (p0 + 4.0 * p1 + p2));
192  }
typename CubicBsplineGrid< T, GRIDTYPE, BC >::point_type point_type
Definition: CubicBspline.h:25

◆ interpolate1()

value_type interpolate1 ( value_type  p0,
value_type  p1,
value_type  p2,
value_type  p3 
)
inline

Definition at line 194 of file CubicBspline.h.

Referenced by CubicBspline< T, GRIDTYPE, BC >::getDeriv().

195  {
196  return GridDeltaInv *
197  (tp[1] * (-0.5 * p0 + 1.5 * p1 - 1.5 * p2 + 0.5 * p3) + tp[2] * (p0 - 2.0 * p1 + p2) +
198  tp[3] * (-0.5 * p0 + 0.5 * p2));
199  }

◆ interpolate2()

value_type interpolate2 ( value_type  p0,
value_type  p1,
value_type  p2,
value_type  p3 
)
inline

Definition at line 201 of file CubicBspline.h.

Referenced by CubicBspline< T, GRIDTYPE, BC >::getDeriv2().

202  {
203  return GridDeltaInv2 * (tp[2] * (-p0 + 3.0 * p1 - 3.0 * p2 + p3) + tp[3] * (p0 - 2.0 * p1 + p2));
204  }

◆ operator()()

value_type operator() ( x)
inline

Definition at line 133 of file CubicBspline.h.

References CubicBspline< T, GRIDTYPE, BC >::getValue().

133 { return getValue(x); }
value_type getValue(point_type x)
Definition: CubicBspline.h:100

◆ splint() [1/2]

value_type splint ( x)
inline

Definition at line 135 of file CubicBspline.h.

References CubicBspline< T, GRIDTYPE, BC >::i0, CubicBspline< T, GRIDTYPE, BC >::interpolate0(), CubicBspline< T, GRIDTYPE, BC >::OffSet, and CubicBspline< T, GRIDTYPE, BC >::P.

Referenced by CubicSplineBasisSet< RT >::df(), CubicSplineBasisSet< RT >::evaluate(), CubicSplineBasisSet< RT >::f(), and CubicSplineBasisSet< RT >::print().

136  {
137  if (this->getGridPoint(x, i0))
138  return interpolate0(P[i0], P[i0 + 1], P[i0 + 2], P[i0 + 3]);
139  else
140  return OffSet;
141  }
value_type OffSet
constant shift
Definition: CubicBspline.h:36
value_type interpolate0(value_type p0, value_type p1, value_type p2, value_type p3)
Definition: CubicBspline.h:186
container_type P
The control points.
Definition: CubicBspline.h:40
int i0
index of current grid point
Definition: CubicBspline.h:34

◆ splint() [2/2]

value_type splint ( point_type  x,
value_type dy,
value_type d2y 
)
inline

Definition at line 143 of file CubicBspline.h.

References CubicBspline< T, GRIDTYPE, BC >::i0, CubicBspline< T, GRIDTYPE, BC >::interpolate(), CubicBspline< T, GRIDTYPE, BC >::OffSet, and CubicBspline< T, GRIDTYPE, BC >::P.

144  {
145  if (this->getGridPoint(x, i0))
146  {
147  return interpolate(P[i0], P[i0 + 1], P[i0 + 2], P[i0 + 3], dy, d2y);
148  }
149  else
150  {
151  dy = 0.0;
152  d2y = 0.0;
153  return OffSet;
154  }
155  //Too slow
156  //dy= GridDeltaInv *
157  // (tp[1]*(dA[0]*P[i0]+dA[1]*P[i1]+dA[ 2]*P[i2]+dA[ 3]*P[i3])+
158  // tp[2]*(dA[4]*P[i0]+dA[5]*P[i1]+dA[ 6]*P[i2]+dA[ 7]*P[i3])+
159  // tp[3]*(dA[8]*P[i0]+dA[9]*P[i1]+dA[10]*P[i2]+dA[11]*P[i3]));
160  //d2y=GridDeltaInv2 *
161  // (tp[2]*(d2A[0]*P[i0]+d2A[1]*P[i1]+d2A[2]*P[i2]+d2A[3]*P[i3])+
162  // tp[3]*(d2A[4]*P[i0]+d2A[5]*P[i1]+d2A[6]*P[i2]+d2A[7]*P[i3]));
163  //return
164  // tp[0]*(A[ 0]*P[i0]+A[ 1]*P[i1]+A[ 2]*P[i2]+A[ 3]*P[i3])+
165  // tp[1]*(A[ 4]*P[i0]+A[ 5]*P[i1]+A[ 6]*P[i2]+A[ 7]*P[i3])+
166  // tp[2]*(A[ 8]*P[i0]+A[ 9]*P[i1]+A[10]*P[i2]+A[11]*P[i3])+
167  // tp[3]*(A[12]*P[i0]+A[13]*P[i1]+A[14]*P[i2]+A[15]*P[i3]);
168  }
value_type OffSet
constant shift
Definition: CubicBspline.h:36
container_type P
The control points.
Definition: CubicBspline.h:40
int i0
index of current grid point
Definition: CubicBspline.h:34
value_type interpolate(value_type p0, value_type p1, value_type p2, value_type p3, value_type &dy, value_type &d2y)
Definition: CubicBspline.h:169

Member Data Documentation

◆ A

point_type A[16]

coefficients

Definition at line 38 of file CubicBspline.h.

Referenced by CubicBspline< T, GRIDTYPE, BC >::CubicBspline().

◆ d2A

◆ d3A

point_type d3A[4]

Definition at line 38 of file CubicBspline.h.

Referenced by CubicBspline< T, GRIDTYPE, BC >::CubicBspline().

◆ dA

point_type dA[12]

Definition at line 38 of file CubicBspline.h.

Referenced by CubicBspline< T, GRIDTYPE, BC >::CubicBspline().

◆ i0

◆ i1

int i1

Definition at line 34 of file CubicBspline.h.

Referenced by CubicBspline< T, GRIDTYPE, BC >::getDeriv3().

◆ i2

int i2

Definition at line 34 of file CubicBspline.h.

Referenced by CubicBspline< T, GRIDTYPE, BC >::getDeriv3().

◆ i3

int i3

Definition at line 34 of file CubicBspline.h.

Referenced by CubicBspline< T, GRIDTYPE, BC >::getDeriv3().

◆ OffSet

◆ P


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