QMCPACK
CenterGrid Class Reference
+ Inheritance diagram for CenterGrid:
+ Collaboration diagram for CenterGrid:

Public Member Functions

GridType Type () override
 Returns the type of the grid (i.e. linear, optimal, etc) More...
 
int ReverseMap (double x) override
 Returns the index of the nearest point below r. More...
 
void Write (IOSectionClass &out) override
 
void Read (IOSectionClass &in) override
 
void Init (double start, double end, double ratio, int numPoints)
 
- Public Member Functions inherited from Grid
double operator() (int i) const
 The i'th point in the grid. More...
 
double * data ()
 
Array< double, 1 > & Points ()
 
virtual ~Grid ()
 

Private Attributes

double a
 
double aInv
 
double b
 
double bInv
 
double center
 
int HalfPoints
 
bool Odd
 
double EvenHalf
 
int OddOne
 

Additional Inherited Members

- Public Attributes inherited from Grid
double Start
 First and last grid points. More...
 
double End
 
int NumPoints
 Number of points in the grid. More...
 
- Protected Attributes inherited from Grid
Array< double, 1 > grid
 Contains the grid points. More...
 

Detailed Description

Definition at line 442 of file Grid.h.

Member Function Documentation

◆ Init()

void Init ( double  start,
double  end,
double  ratio,
int  numPoints 
)
inline

Definition at line 464 of file Grid.h.

References a, qmcplusplus::abs(), aInv, b, bInv, center, Grid::End, EvenHalf, Grid::grid, HalfPoints, qmcplusplus::log(), Grid::NumPoints, Odd, OddOne, Array< T, D, ALLOC >::resize(), sign(), and Grid::Start.

465  {
466  assert(ratio > 1.0);
467  Start = start;
468  End = end;
469  center = 0.5 * (start + end);
470  NumPoints = numPoints;
471  HalfPoints = numPoints / 2;
472  Odd = ((numPoints % 2) == 1);
473  b = log(ratio) / (double)(HalfPoints - 1);
474  bInv = 1.0 / b;
475  grid.resize(numPoints);
476  if (Odd)
477  {
478  EvenHalf = 0.0;
479  OddOne = 1;
480  a = 0.5 * (end - start) / expm1(b * HalfPoints);
481  aInv = 1.0 / a;
482  for (int i = -HalfPoints; i <= HalfPoints; i++)
483  {
484  double sign = (i < 0) ? -1.0 : 1.0;
485  grid(i + HalfPoints) = sign * a * expm1(b * std::abs(i)) + center;
486  }
487  }
488  else
489  {
490  EvenHalf = 0.5;
491  OddOne = 0;
492  a = 0.5 * (end - start) / expm1(b * (-0.5 + HalfPoints));
493  aInv = 1.0 / a;
494  for (int i = -HalfPoints; i < HalfPoints; i++)
495  {
496  double sign = (i < 0) ? -1.0 : 1.0;
497  grid(i + HalfPoints) = sign * a * expm1(b * std::abs(0.5 + i)) + center;
498  }
499  }
500  }
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
Array< double, 1 > grid
Contains the grid points.
Definition: Grid.h:47
int NumPoints
Number of points in the grid.
Definition: Grid.h:54
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
double EvenHalf
Definition: Grid.h:448
double a
Definition: Grid.h:445
double aInv
Definition: Grid.h:445
double b
Definition: Grid.h:445
double sign(double x)
Definition: Standard.h:73
MakeReturn< UnaryNode< FnLog, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t log(const Vector< T1, C1 > &l)
int HalfPoints
Definition: Grid.h:446
double Start
First and last grid points.
Definition: Grid.h:51
double center
Definition: Grid.h:445
bool Odd
Definition: Grid.h:447
double bInv
Definition: Grid.h:445
double End
Definition: Grid.h:51
int OddOne
Definition: Grid.h:449

◆ Read()

void Read ( IOSectionClass in)
inlineoverridevirtual

Implements Grid.

Definition at line 463 of file Grid.h.

463 {}

◆ ReverseMap()

int ReverseMap ( double  r)
inlineoverridevirtual

Returns the index of the nearest point below r.

Implements Grid.

Definition at line 456 of file Grid.h.

References qmcplusplus::abs(), aInv, bInv, center, EvenHalf, qmcplusplus::floor(), and HalfPoints.

457  {
458  x -= center;
459  double index = copysign(log1p(std::abs(x) * aInv) * bInv, x);
460  return (int)floor(HalfPoints + index - EvenHalf);
461  }
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
double EvenHalf
Definition: Grid.h:448
double aInv
Definition: Grid.h:445
int HalfPoints
Definition: Grid.h:446
double center
Definition: Grid.h:445
double bInv
Definition: Grid.h:445
MakeReturn< UnaryNode< FnFloor, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t floor(const Vector< T1, C1 > &l)

◆ Type()

GridType Type ( )
inlineoverridevirtual

Returns the type of the grid (i.e. linear, optimal, etc)

Implements Grid.

Definition at line 454 of file Grid.h.

References CENTER.

454 { return CENTER; }
Definition: Grid.h:38

◆ Write()

void Write ( IOSectionClass out)
inlineoverridevirtual

Implements Grid.

Definition at line 462 of file Grid.h.

462 {}

Member Data Documentation

◆ a

double a
private

Definition at line 445 of file Grid.h.

Referenced by Init().

◆ aInv

double aInv
private

Definition at line 445 of file Grid.h.

Referenced by Init(), and ReverseMap().

◆ b

double b
private

Definition at line 445 of file Grid.h.

Referenced by Init().

◆ bInv

double bInv
private

Definition at line 445 of file Grid.h.

Referenced by Init(), and ReverseMap().

◆ center

double center
private

Definition at line 445 of file Grid.h.

Referenced by Init(), and ReverseMap().

◆ EvenHalf

double EvenHalf
private

Definition at line 448 of file Grid.h.

Referenced by Init(), and ReverseMap().

◆ HalfPoints

int HalfPoints
private

Definition at line 446 of file Grid.h.

Referenced by Init(), and ReverseMap().

◆ Odd

bool Odd
private

Definition at line 447 of file Grid.h.

Referenced by Init().

◆ OddOne

int OddOne
private

Definition at line 449 of file Grid.h.

Referenced by Init().


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