QMCPACK
NumericalGrid< T, CT > Struct Template Reference

One-Dimensional numerical grid with arbitrary grid spacings. More...

+ Inheritance diagram for NumericalGrid< T, CT >:
+ Collaboration diagram for NumericalGrid< T, CT >:

Public Member Functions

 NumericalGrid ()
 
template<class VA >
 NumericalGrid (const VA &nv)
 
std::unique_ptr< OneDimGridBase< T, CT > > makeClone () const override
 
template<class IT >
void assign (IT g_first, IT g_last)
 
void resize (int n)
 
int locate (T r) const override
 evaluate the index of r More...
 
void set (T ri, T rf, int n) override
 Set the grid given the parameters. More...
 
- Public Member Functions inherited from OneDimGridBase< T, CT >
 OneDimGridBase ()
 
virtual ~OneDimGridBase ()=default
 
int getGridTag () const
 
int getIndex (T r) const
 
T & operator[] (int i)
 assign a value More...
 
T & operator() (int i)
 assign a value More...
 
operator[] (int i) const
 return a value More...
 
operator() (int i) const
 return a value More...
 
const T * data () const
 
T * data ()
 
dh () const
 return the differential spacing of the grid More...
 
r (int i) const
 returns $ r(i)$ More...
 
dr (int i) const
 returns $ r(i+1)-r(i)$ More...
 
int size () const
 returns the size of the grid More...
 
rmin () const
 return the first grid point More...
 
rmax () const
 return the last grid point More...
 
template<typename T1 >
int getIndexAndDistanceFromGridPoint (T r, T1 &dist) const
 

Additional Inherited Members

- Public Types inherited from OneDimGridBase< T, CT >
using value_type = T
 
using Array_t = CT
 
- Public Attributes inherited from OneDimGridBase< T, CT >
int GridTag
 
int num_points
 
value_type lower_bound
 
value_type upper_bound
 
value_type Delta
 differential spacing of the grid More...
 
double DeltaInv
 
Array_t X
 array to store the radial grid data More...
 

Detailed Description

template<class T, class CT = Vector<T>>
struct qmcplusplus::NumericalGrid< T, CT >

One-Dimensional numerical grid with arbitrary grid spacings.

Non-Analytic grid, uses an array of values (typically read in from a file).

Definition at line 277 of file OneDimGridBase.h.

Constructor & Destructor Documentation

◆ NumericalGrid() [1/2]

◆ NumericalGrid() [2/2]

NumericalGrid ( const VA &  nv)
inline

Definition at line 289 of file OneDimGridBase.h.

References NumericalGrid< T, CT >::assign(), CUSTOM_1DGRID, and OneDimGridBase< T, CT >::GridTag.

290  {
292  assign(nv.begin(), nv.end());
293  }
void assign(IT g_first, IT g_last)

Member Function Documentation

◆ assign()

void assign ( IT  g_first,
IT  g_last 
)
inline

Definition at line 302 of file OneDimGridBase.h.

References copy(), OneDimGridBase< T, CT >::Delta, OneDimGridBase< T, CT >::lower_bound, OneDimGridBase< T, CT >::num_points, OneDimGridBase< T, CT >::upper_bound, and OneDimGridBase< T, CT >::X.

Referenced by NumericalGrid< T, CT >::NumericalGrid().

303  {
304  num_points = g_last - g_first;
305  X.resize(num_points);
306  copy(g_first, g_last, X.begin());
307  lower_bound = X[0];
308  upper_bound = X[num_points - 1];
309  int nf = num_points / 2;
310  Delta = X[nf] - X[nf - 1];
311  }
Array_t X
array to store the radial grid data
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
value_type Delta
differential spacing of the grid

◆ locate()

int locate ( r) const
inlineoverridevirtual

evaluate the index of r

Parameters
rcurrent position

The grid index satisfies $ X[Loc] \ge r < X[Loc+1]$.

Implements OneDimGridBase< T, CT >.

Definition at line 319 of file OneDimGridBase.h.

References OneDimGridBase< T, CT >::num_points, OneDimGridBase< T, CT >::r(), and OneDimGridBase< T, CT >::X.

320  {
321  int k;
322  int klo = 0;
323  int khi = num_points;
324  //int khi=this->size()-1;
325  while (khi - klo > 1)
326  {
327  k = (khi + klo) >> 1;
328  if (X[k] > r)
329  khi = k;
330  else
331  klo = k;
332  }
333  return klo;
334  }
Array_t X
array to store the radial grid data
T r(int i) const
returns

◆ makeClone()

std::unique_ptr<OneDimGridBase<T, CT> > makeClone ( ) const
inlineoverridevirtual

Implements OneDimGridBase< T, CT >.

Definition at line 295 of file OneDimGridBase.h.

296  {
297  return std::make_unique<NumericalGrid<T, CT>>(*this);
298  }

◆ resize()

void resize ( int  n)
inline

Definition at line 313 of file OneDimGridBase.h.

References qmcplusplus::n, and OneDimGridBase< T, CT >::X.

Referenced by OneDimNumGridFunctor< T >::put().

314  {
315  if (X.size() != n)
316  X.resize(n);
317  }
Array_t X
array to store the radial grid data

◆ set()

void set ( ri,
rf,
int  n 
)
inlineoverridevirtual

Set the grid given the parameters.

Parameters
riinitial grid point
rffinal grid point
nnumber of grid points

Implements OneDimGridBase< T, CT >.

Definition at line 336 of file OneDimGridBase.h.

References OneDimGridBase< T, CT >::lower_bound, qmcplusplus::n, OneDimGridBase< T, CT >::num_points, and OneDimGridBase< T, CT >::upper_bound.

337  {
338  lower_bound = ri;
339  upper_bound = rf;
340  num_points = n;
341  //X.resize(n);
342  //Delta = 0.0;
343  }

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