QMCPACK
OneDimCubicSplineLinearGrid< T > Class Template Reference

combined OneDimCubicSpline and LinearGrid OneDimCubicSpline contains OneDimGridBase pointer and calls its virtual function members. More...

+ Collaboration diagram for OneDimCubicSplineLinearGrid< T >:

Public Member Functions

 OneDimCubicSplineLinearGrid (const OneDimCubicSpline< T > &cublis_spliner)
 
splint (T r) const
 compute the function value at r More...
 
const auto & get_m_Y () const
 
const auto & get_m_Y2 () const
 
get_first_deriv () const
 
get_const_value () const
 
get_r_min () const
 
get_r_max () const
 
const auto & get_X () const
 
double get_delta_inv () const
 

Static Public Member Functions

static T splint (T r_min, T r_max, const T *X, T delta_inv, const T *m_Y, const T *m_Y2, T first_deriv, T const_value, T r)
 compute the function value at r. More...
 

Private Attributes

Vector< T, OffloadAllocator< T > > m_Y_
 data for the function on the grid More...
 
Vector< T, OffloadAllocator< T > > m_Y2_
 data for the function on the grid More...
 
first_deriv_
 first derivative for handling r < r_min_ More...
 
const_value_
 const value for handling r > r_max_ More...
 
r_min_
 use spline above r_min_. If below, use first deriv extrapolation More...
 
r_max_
 use spline below r_min_. If above, use const value More...
 
Vector< T, OffloadAllocator< T > > X_
 the location of grid points More...
 
double delta_inv_
 1/grid space More...
 

Detailed Description

template<class T>
class qmcplusplus::OneDimCubicSplineLinearGrid< T >

combined OneDimCubicSpline and LinearGrid OneDimCubicSpline contains OneDimGridBase pointer and calls its virtual function members.

This doesn't work well on a GPU. Since the use case is OneDimCubicSpline with LinearGrid. We fuse both classes and avoid any virtual functions. There are two splint functions. The one with one paramemter r is intended for testing or being called on the CPU. The static one with many parameters is intended to be used(inlined) inside a GPU kernel.

Definition at line 29 of file OneDimCubicSplineLinearGrid.h.

Constructor & Destructor Documentation

◆ OneDimCubicSplineLinearGrid()

OneDimCubicSplineLinearGrid ( const OneDimCubicSpline< T > &  cublis_spliner)
inline

Definition at line 32 of file OneDimCubicSplineLinearGrid.h.

References OneDimCubicSplineLinearGrid< T >::const_value_, OneDimCubicSpline< Td, Tg, CTd, CTg >::ConstValue, OneDimCubicSplineLinearGrid< T >::delta_inv_, OneDimCubicSpline< Td, Tg, CTd, CTg >::first_deriv, OneDimCubicSplineLinearGrid< T >::first_deriv_, OneDimGridFunctor< Td, Tg, CTd, CTg >::grid(), OneDimCubicSpline< Td, Tg, CTd, CTg >::m_Y, OneDimCubicSpline< Td, Tg, CTd, CTg >::m_Y2, OneDimCubicSplineLinearGrid< T >::m_Y2_, OneDimCubicSplineLinearGrid< T >::m_Y_, OneDimCubicSplineLinearGrid< T >::r_max_, OneDimCubicSplineLinearGrid< T >::r_min_, and OneDimCubicSplineLinearGrid< T >::X_.

33  {
34  auto& grid = dynamic_cast<const LinearGrid<T>&>(cublis_spliner.grid());
35  r_min_ = grid.rmin();
36  r_max_ = grid.rmax();
37  delta_inv_ = grid.DeltaInv;
38 
39  const size_t num_points = grid.size();
40  X_.resize(num_points);
41  for (size_t i = 0; i < num_points; i++)
42  X_[i] = *(grid.data() + i);
43 
44  first_deriv_ = cublis_spliner.first_deriv;
45  const_value_ = cublis_spliner.ConstValue;
46  m_Y_.resize(num_points);
47  m_Y2_.resize(num_points);
48  for (size_t i = 0; i < num_points; i++)
49  {
50  m_Y_[i] = cublis_spliner.m_Y[i];
51  m_Y2_[i] = cublis_spliner.m_Y2[i];
52  }
53  X_.updateTo();
54  m_Y_.updateTo();
55  m_Y2_.updateTo();
56  }
T first_deriv_
first derivative for handling r < r_min_
T r_max_
use spline below r_min_. If above, use const value
Vector< T, OffloadAllocator< T > > m_Y_
data for the function on the grid
T const_value_
const value for handling r > r_max_
Linear Grid inherets from Grid.
Definition: Grid.h:73
Vector< T, OffloadAllocator< T > > X_
the location of grid points
T r_min_
use spline above r_min_. If below, use first deriv extrapolation
const grid_type & grid() const
return the radial grid
Vector< T, OffloadAllocator< T > > m_Y2_
data for the function on the grid
data_type m_Y
data for the function on the grid

Member Function Documentation

◆ get_const_value()

T get_const_value ( ) const
inline

Definition at line 97 of file OneDimCubicSplineLinearGrid.h.

References OneDimCubicSplineLinearGrid< T >::const_value_.

97 { return const_value_; }
T const_value_
const value for handling r > r_max_

◆ get_delta_inv()

double get_delta_inv ( ) const
inline

◆ get_first_deriv()

T get_first_deriv ( ) const
inline

Definition at line 96 of file OneDimCubicSplineLinearGrid.h.

References OneDimCubicSplineLinearGrid< T >::first_deriv_.

96 { return first_deriv_; }
T first_deriv_
first derivative for handling r < r_min_

◆ get_m_Y()

const auto& get_m_Y ( ) const
inline

Definition at line 94 of file OneDimCubicSplineLinearGrid.h.

References OneDimCubicSplineLinearGrid< T >::m_Y_.

94 { return m_Y_; }
Vector< T, OffloadAllocator< T > > m_Y_
data for the function on the grid

◆ get_m_Y2()

const auto& get_m_Y2 ( ) const
inline

Definition at line 95 of file OneDimCubicSplineLinearGrid.h.

References OneDimCubicSplineLinearGrid< T >::m_Y2_.

95 { return m_Y2_; }
Vector< T, OffloadAllocator< T > > m_Y2_
data for the function on the grid

◆ get_r_max()

T get_r_max ( ) const
inline

Definition at line 100 of file OneDimCubicSplineLinearGrid.h.

References OneDimCubicSplineLinearGrid< T >::r_max_.

100 { return r_max_; }
T r_max_
use spline below r_min_. If above, use const value

◆ get_r_min()

T get_r_min ( ) const
inline

Definition at line 99 of file OneDimCubicSplineLinearGrid.h.

References OneDimCubicSplineLinearGrid< T >::r_min_.

99 { return r_min_; }
T r_min_
use spline above r_min_. If below, use first deriv extrapolation

◆ get_X()

const auto& get_X ( ) const
inline

Definition at line 101 of file OneDimCubicSplineLinearGrid.h.

References OneDimCubicSplineLinearGrid< T >::X_.

101 { return X_; }
Vector< T, OffloadAllocator< T > > X_
the location of grid points

◆ splint() [1/2]

T splint ( r) const
inline

compute the function value at r

Definition at line 60 of file OneDimCubicSplineLinearGrid.h.

References OneDimCubicSplineLinearGrid< T >::const_value_, OneDimCubicSplineLinearGrid< T >::delta_inv_, OneDimCubicSplineLinearGrid< T >::first_deriv_, OneDimCubicSplineLinearGrid< T >::m_Y2_, OneDimCubicSplineLinearGrid< T >::m_Y_, OneDimCubicSplineLinearGrid< T >::r_max_, OneDimCubicSplineLinearGrid< T >::r_min_, and OneDimCubicSplineLinearGrid< T >::X_.

61  {
62  return splint(r_min_, r_max_, X_.data(), delta_inv_, m_Y_.data(), m_Y2_.data(), first_deriv_, const_value_, r);
63  }
T first_deriv_
first derivative for handling r < r_min_
T r_max_
use spline below r_min_. If above, use const value
Vector< T, OffloadAllocator< T > > m_Y_
data for the function on the grid
T const_value_
const value for handling r > r_max_
T splint(T r) const
compute the function value at r
Vector< T, OffloadAllocator< T > > X_
the location of grid points
T r_min_
use spline above r_min_. If below, use first deriv extrapolation
Vector< T, OffloadAllocator< T > > m_Y2_
data for the function on the grid

◆ splint() [2/2]

static T splint ( r_min,
r_max,
const T *  X,
delta_inv,
const T *  m_Y,
const T *  m_Y2,
first_deriv,
const_value,
r 
)
inlinestatic

compute the function value at r.

Need to pass in all the parameters.

Definition at line 68 of file OneDimCubicSplineLinearGrid.h.

References CubicSplineEvaluator< T >::cubicInterpolate(), and qmcplusplus::floor().

77  {
78  if (r < r_min)
79  {
80  return m_Y[0] + first_deriv * (r - r_min);
81  }
82  else if (r >= r_max)
83  {
84  return const_value;
85  }
86 
87  const size_t loc = std::floor((r - r_min) * delta_inv);
88  const T dist = r - X[loc];
89  const T delta = X[loc + 1] - X[loc];
90  CubicSplineEvaluator<T> eval(dist, delta);
91  return eval.cubicInterpolate(m_Y[loc], m_Y[loc + 1], m_Y2[loc], m_Y2[loc + 1]);
92  }
MakeReturn< UnaryNode< FnFloor, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t floor(const Vector< T1, C1 > &l)

Member Data Documentation

◆ const_value_

◆ delta_inv_

◆ first_deriv_

◆ m_Y2_

◆ m_Y_

◆ r_max_

T r_max_
private

◆ r_min_

T r_min_
private

◆ X_


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