Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
PLMD::SparseGrid Class Reference

#include <Grid.h>

Inheritance diagram for PLMD::SparseGrid:
Inheritance graph
[legend]

Public Types

typedef std::size_t index_t
 

Public Member Functions

 SparseGrid (const std::string &funcl, const std::vector< Value * > &args, const std::vector< std::string > &gmin, const std::vector< std::string > &gmax, const std::vector< unsigned > &nbin, bool dospline, bool usederiv)
 
virtual ~SparseGrid ()=default
 
void addKernel (const KernelFunctions &kernel)
 add a kernel function to the grid More...
 
void addValue (const std::vector< unsigned > &indices, double value)
 
void addValue (const std::vector< unsigned > &indices, double value)
 
void addValue (index_t index, double value) override
 add to grid value More...
 
virtual void addValue (index_t index, double value)=0
 add to grid value More...
 
void addValueAndDerivatives (const std::vector< unsigned > &indices, double value, std::vector< double > &der)
 
void addValueAndDerivatives (const std::vector< unsigned > &indices, double value, std::vector< double > &der)
 
void addValueAndDerivatives (index_t index, double value, std::vector< double > &der) override
 add to grid value and derivatives More...
 
virtual void addValueAndDerivatives (index_t index, double value, std::vector< double > &der)=0
 add to grid value and derivatives More...
 
double findMaximalPathMinimum (const std::vector< double > &source, const std::vector< double > &sink)
 Find the maximum over paths of the minimum value of the gridded function along the paths for all paths of neighboring grid lattice points from a source point to a sink point. More...
 
std::vector< std::string > getArgNames () const
 get argument names of this grid More...
 
double getBinVolume () const
 get bin volume More...
 
unsigned getDimension () const
 get grid dimension More...
 
std::vector< double > getDx () const
 get bin size More...
 
double getDx (index_t j) const
 
index_t getIndex (const std::vector< double > &x) const
 
index_t getIndex (const std::vector< unsigned > &indices) const
 
index_t getIndex (const unsigned *indices, std::size_t indices_size) const
 
std::vector< unsigned > getIndices (const std::vector< double > &x) const
 
void getIndices (const std::vector< double > &x, std::vector< unsigned > &rindex) const
 
void getIndices (const std::vector< double > &x, unsigned *rindex_data, std::size_t rindex_size) const
 
std::vector< unsigned > getIndices (index_t index) const
 
void getIndices (index_t index, std::vector< unsigned > &rindex) const
 methods to handle grid indices More...
 
void getIndices (index_t index, unsigned *rindex_data, std::size_t rindex_size) const
 
std::vector< bool > getIsPeriodic () const
 get if periodic More...
 
std::vector< std::string > getMax () const
 get upper boundary More...
 
index_t getMaxSize () const
 
double getMaxValue () const override
 get maximum value More...
 
std::vector< std::string > getMin () const
 get lower boundary More...
 
double getMinValue () const override
 get minimum value More...
 
std::vector< unsigned > getNbin () const
 get number of bins More...
 
std::vector< index_tgetNearestNeighbors (const index_t index) const
 get nearest neighbors (those separated by exactly one lattice unit) More...
 
std::vector< index_tgetNearestNeighbors (const std::vector< unsigned > &indices) const
 
std::vector< index_tgetNeighbors (const std::vector< double > &x, const std::vector< unsigned > &neigh) const
 
std::vector< index_tgetNeighbors (const std::vector< unsigned > &indices, const std::vector< unsigned > &neigh) const
 
std::vector< index_tgetNeighbors (index_t index, const std::vector< unsigned > &neigh) const
 get neighbors More...
 
std::vector< double > getPoint (const std::vector< double > &x) const
 
void getPoint (const std::vector< double > &x, std::vector< double > &point) const
 
std::vector< double > getPoint (const std::vector< unsigned > &indices) const
 
void getPoint (const std::vector< unsigned > &indices, std::vector< double > &point) const
 
void getPoint (const unsigned *indices_data, std::size_t indices_size, double *point, std::size_t point_size) const
 
void getPoint (const unsigned *indices_data, std::size_t indices_size, std::vector< double > &point) const
 
std::vector< double > getPoint (index_t index) const
 
void getPoint (index_t index, std::vector< double > &point) const
 faster versions relying on preallocated vectors More...
 
index_t getSize () const override
 get grid size More...
 
double getValue (const std::vector< double > &x) const
 
double getValue (const std::vector< double > &x) const
 this is to access to Grid:: version of these methods (allowing overloading of virtual methods) More...
 
double getValue (const std::vector< unsigned > &indices) const
 
double getValue (const std::vector< unsigned > &indices) const
 this is to access to Grid:: version of these methods (allowing overloading of virtual methods) More...
 
double getValue (index_t index) const override
 get grid value More...
 
virtual double getValue (index_t index) const=0
 this is to access to Grid:: version of these methods (allowing overloading of virtual methods) More...
 
double getValueAndDerivatives (const std::vector< double > &x, std::vector< double > &der) const
 
double getValueAndDerivatives (const std::vector< double > &x, std::vector< double > &der) const
 
double getValueAndDerivatives (const std::vector< unsigned > &indices, std::vector< double > &der) const
 
double getValueAndDerivatives (const std::vector< unsigned > &indices, std::vector< double > &der) const
 
double getValueAndDerivatives (index_t index, double *der, std::size_t der_size) const override
 get grid value and derivatives More...
 
virtual double getValueAndDerivatives (index_t index, double *der, std::size_t der_size) const=0
 get grid value and derivatives More...
 
double getValueAndDerivatives (index_t index, std::vector< double > &der) const
 
double getValueAndDerivatives (index_t index, std::vector< double > &der) const
 
bool hasDerivatives () const
 get if the grid has derivatives More...
 
void Init (const std::string &funcl, const std::vector< std::string > &names, const std::vector< std::string > &gmin, const std::vector< std::string > &gmax, const std::vector< unsigned > &nbin, bool dospline, bool usederiv, const std::vector< bool > &isperiodic, const std::vector< std::string > &pmin, const std::vector< std::string > &pmax)
 this is the real initializator More...
 
void resetToDefaultOutputFmt ()
 reset output format to the default %14.9f format More...
 
void setOutputFmt (const std::string &ss)
 set output format More...
 
void setValue (const std::vector< unsigned > &indices, double value)
 
void setValue (const std::vector< unsigned > &indices, double value)
 
void setValue (index_t index, double value) override
 set grid value More...
 
virtual void setValue (index_t index, double value)=0
 set grid value More...
 
void setValueAndDerivatives (const std::vector< unsigned > &indices, double value, std::vector< double > &der)
 
void setValueAndDerivatives (const std::vector< unsigned > &indices, double value, std::vector< double > &der)
 
void setValueAndDerivatives (index_t index, double value, std::vector< double > &der) override
 set grid value and derivatives More...
 
virtual void setValueAndDerivatives (index_t index, double value, std::vector< double > &der)=0
 set grid value and derivatives More...
 
void writeCubeFile (OFile &, const double &lunit)
 dump grid to gaussian cube file More...
 
void writeHeader (OFile &file)
 write header for grid file More...
 
void writeToFile (OFile &) override
 dump grid on file More...
 

Static Public Member Functions

static std::unique_ptr< GridBasecreate (const std::string &, const std::vector< Value * > &, IFile &, bool, bool, bool)
 read grid from file More...
 
static std::unique_ptr< GridBasecreate (const std::string &, const std::vector< Value * > &, IFile &, const std::vector< std::string > &, const std::vector< std::string > &, const std::vector< unsigned > &, bool, bool, bool)
 read grid from file and check boundaries are what is expected from input More...
 

Static Public Attributes

static constexpr std::size_t maxdim =16
 Maximum dimension (exaggerated value). More...
 

Protected Member Functions

unsigned getSplineNeighbors (const unsigned *indices, std::size_t indices_size, index_t *neighbors, std::size_t neighbors_size) const
 get "neighbors" for spline More...
 

Protected Attributes

AcceleratorHandler accelerator
 
std::vector< std::string > argnames
 
unsigned dimension_
 
bool dospline_
 
std::vector< double > dx_
 
std::string fmt_
 
std::string funcname
 
std::vector< double > max_
 
index_t maxsize_
 
std::vector< double > min_
 
std::vector< unsigned > nbin_
 
std::vector< bool > pbc_
 
std::vector< std::string > str_max_
 
std::vector< std::string > str_min_
 
bool usederiv_
 

Private Attributes

std::map< index_t, std::vector< double > > der_
 
std::map< index_t, double > map_
 

Member Typedef Documentation

◆ index_t

typedef std::size_t PLMD::GridBase::index_t
inherited

Constructor & Destructor Documentation

◆ SparseGrid()

PLMD::SparseGrid::SparseGrid ( const std::string &  funcl,
const std::vector< Value * > &  args,
const std::vector< std::string > &  gmin,
const std::vector< std::string > &  gmax,
const std::vector< unsigned > &  nbin,
bool  dospline,
bool  usederiv 
)
inline

◆ ~SparseGrid()

virtual PLMD::SparseGrid::~SparseGrid ( )
virtualdefault

Member Function Documentation

◆ addKernel()

void PLMD::GridBase::addKernel ( const KernelFunctions kernel)
inherited

add a kernel function to the grid

◆ addValue() [1/4]

void PLMD::GridBase::addValue ( const std::vector< unsigned > &  indices,
double  value 
)
inherited

◆ addValue() [2/4]

void PLMD::GridBase::addValue

◆ addValue() [3/4]

void PLMD::SparseGrid::addValue ( index_t  index,
double  value 
)
overridevirtual

add to grid value

Implements PLMD::GridBase.

◆ addValue() [4/4]

virtual void PLMD::GridBase::addValue

add to grid value

◆ addValueAndDerivatives() [1/4]

void PLMD::GridBase::addValueAndDerivatives ( const std::vector< unsigned > &  indices,
double  value,
std::vector< double > &  der 
)
inherited

◆ addValueAndDerivatives() [2/4]

void PLMD::GridBase::addValueAndDerivatives

◆ addValueAndDerivatives() [3/4]

void PLMD::SparseGrid::addValueAndDerivatives ( index_t  index,
double  value,
std::vector< double > &  der 
)
overridevirtual

add to grid value and derivatives

Implements PLMD::GridBase.

◆ addValueAndDerivatives() [4/4]

virtual void PLMD::GridBase::addValueAndDerivatives

add to grid value and derivatives

◆ create() [1/2]

std::unique_ptr< GridBase > PLMD::GridBase::create ( const std::string &  funcl,
const std::vector< Value * > &  args,
IFile ifile,
bool  dosparse,
bool  dospline,
bool  doder 
)
staticinherited

read grid from file

◆ create() [2/2]

std::unique_ptr< GridBase > PLMD::GridBase::create ( const std::string &  funcl,
const std::vector< Value * > &  args,
IFile ifile,
const std::vector< std::string > &  gmin,
const std::vector< std::string > &  gmax,
const std::vector< unsigned > &  nbin,
bool  dosparse,
bool  dospline,
bool  doder 
)
staticinherited

read grid from file and check boundaries are what is expected from input

◆ findMaximalPathMinimum()

double PLMD::GridBase::findMaximalPathMinimum ( const std::vector< double > &  source,
const std::vector< double > &  sink 
)
inherited

Find the maximum over paths of the minimum value of the gridded function along the paths for all paths of neighboring grid lattice points from a source point to a sink point.

◆ getArgNames()

std::vector< std::string > PLMD::GridBase::getArgNames ( ) const
inherited

get argument names of this grid

◆ getBinVolume()

double PLMD::GridBase::getBinVolume ( ) const
inherited

get bin volume

◆ getDimension()

unsigned PLMD::GridBase::getDimension ( ) const
inherited

get grid dimension

◆ getDx() [1/2]

std::vector< double > PLMD::GridBase::getDx ( ) const
inherited

get bin size

◆ getDx() [2/2]

double PLMD::GridBase::getDx ( index_t  j) const
inherited

◆ getIndex() [1/3]

GridBase::index_t PLMD::GridBase::getIndex ( const std::vector< double > &  x) const
inlineinherited

◆ getIndex() [2/3]

GridBase::index_t PLMD::GridBase::getIndex ( const std::vector< unsigned > &  indices) const
inlineinherited

◆ getIndex() [3/3]

GridBase::index_t PLMD::GridBase::getIndex ( const unsigned *  indices,
std::size_t  indices_size 
) const
inlineinherited

◆ getIndices() [1/6]

std::vector< unsigned > PLMD::GridBase::getIndices ( const std::vector< double > &  x) const
inlineinherited

◆ getIndices() [2/6]

void PLMD::GridBase::getIndices ( const std::vector< double > &  x,
std::vector< unsigned > &  rindex 
) const
inlineinherited

◆ getIndices() [3/6]

void PLMD::GridBase::getIndices ( const std::vector< double > &  x,
unsigned *  rindex_data,
std::size_t  rindex_size 
) const
inlineinherited

◆ getIndices() [4/6]

std::vector< unsigned > PLMD::GridBase::getIndices ( index_t  index) const
inlineinherited

◆ getIndices() [5/6]

void PLMD::GridBase::getIndices ( index_t  index,
std::vector< unsigned > &  rindex 
) const
inlineinherited

methods to handle grid indices

◆ getIndices() [6/6]

void PLMD::GridBase::getIndices ( index_t  index,
unsigned *  rindex_data,
std::size_t  rindex_size 
) const
inlineinherited

◆ getIsPeriodic()

std::vector< bool > PLMD::GridBase::getIsPeriodic ( ) const
inherited

get if periodic

◆ getMax()

std::vector< std::string > PLMD::GridBase::getMax ( ) const
inherited

get upper boundary

◆ getMaxSize()

Grid::index_t PLMD::SparseGrid::getMaxSize ( ) const

◆ getMaxValue()

double PLMD::SparseGrid::getMaxValue ( ) const
overridevirtual

get maximum value

Implements PLMD::GridBase.

◆ getMin()

std::vector< std::string > PLMD::GridBase::getMin ( ) const
inherited

get lower boundary

◆ getMinValue()

double PLMD::SparseGrid::getMinValue ( ) const
overridevirtual

get minimum value

Implements PLMD::GridBase.

◆ getNbin()

std::vector< unsigned > PLMD::GridBase::getNbin ( ) const
inherited

get number of bins

◆ getNearestNeighbors() [1/2]

std::vector< GridBase::index_t > PLMD::GridBase::getNearestNeighbors ( const index_t  index) const
inherited

get nearest neighbors (those separated by exactly one lattice unit)

◆ getNearestNeighbors() [2/2]

std::vector< GridBase::index_t > PLMD::GridBase::getNearestNeighbors ( const std::vector< unsigned > &  indices) const
inherited

◆ getNeighbors() [1/3]

std::vector< GridBase::index_t > PLMD::GridBase::getNeighbors ( const std::vector< double > &  x,
const std::vector< unsigned > &  neigh 
) const
inlineinherited

◆ getNeighbors() [2/3]

std::vector< GridBase::index_t > PLMD::GridBase::getNeighbors ( const std::vector< unsigned > &  indices,
const std::vector< unsigned > &  neigh 
) const
inlineinherited

◆ getNeighbors() [3/3]

std::vector< GridBase::index_t > PLMD::GridBase::getNeighbors ( index_t  index,
const std::vector< unsigned > &  neigh 
) const
inlineinherited

get neighbors

◆ getPoint() [1/8]

std::vector< double > PLMD::GridBase::getPoint ( const std::vector< double > &  x) const
inlineinherited

◆ getPoint() [2/8]

void PLMD::GridBase::getPoint ( const std::vector< double > &  x,
std::vector< double > &  point 
) const
inlineinherited

◆ getPoint() [3/8]

std::vector< double > PLMD::GridBase::getPoint ( const std::vector< unsigned > &  indices) const
inlineinherited

◆ getPoint() [4/8]

void PLMD::GridBase::getPoint ( const std::vector< unsigned > &  indices,
std::vector< double > &  point 
) const
inlineinherited

◆ getPoint() [5/8]

void PLMD::GridBase::getPoint ( const unsigned *  indices_data,
std::size_t  indices_size,
double *  point,
std::size_t  point_size 
) const
inlineinherited

◆ getPoint() [6/8]

void PLMD::GridBase::getPoint ( const unsigned *  indices_data,
std::size_t  indices_size,
std::vector< double > &  point 
) const
inlineinherited

◆ getPoint() [7/8]

std::vector< double > PLMD::GridBase::getPoint ( index_t  index) const
inlineinherited

◆ getPoint() [8/8]

void PLMD::GridBase::getPoint ( index_t  index,
std::vector< double > &  point 
) const
inlineinherited

faster versions relying on preallocated vectors

◆ getSize()

Grid::index_t PLMD::SparseGrid::getSize ( ) const
overridevirtual

get grid size

Implements PLMD::GridBase.

◆ getSplineNeighbors()

unsigned PLMD::GridBase::getSplineNeighbors ( const unsigned *  indices,
std::size_t  indices_size,
index_t neighbors,
std::size_t  neighbors_size 
) const
protectedinherited

get "neighbors" for spline

◆ getValue() [1/6]

double PLMD::GridBase::getValue ( const std::vector< double > &  x) const
inherited

◆ getValue() [2/6]

double PLMD::GridBase::getValue

this is to access to Grid:: version of these methods (allowing overloading of virtual methods)

◆ getValue() [3/6]

double PLMD::GridBase::getValue ( const std::vector< unsigned > &  indices) const
inherited

◆ getValue() [4/6]

double PLMD::GridBase::getValue

this is to access to Grid:: version of these methods (allowing overloading of virtual methods)

◆ getValue() [5/6]

double PLMD::SparseGrid::getValue ( index_t  index) const
overridevirtual

get grid value

Implements PLMD::GridBase.

◆ getValue() [6/6]

virtual double PLMD::GridBase::getValue

this is to access to Grid:: version of these methods (allowing overloading of virtual methods)

◆ getValueAndDerivatives() [1/8]

double PLMD::GridBase::getValueAndDerivatives ( const std::vector< double > &  x,
std::vector< double > &  der 
) const
inherited

◆ getValueAndDerivatives() [2/8]

double PLMD::GridBase::getValueAndDerivatives

◆ getValueAndDerivatives() [3/8]

double PLMD::GridBase::getValueAndDerivatives ( const std::vector< unsigned > &  indices,
std::vector< double > &  der 
) const
inherited

◆ getValueAndDerivatives() [4/8]

double PLMD::GridBase::getValueAndDerivatives

◆ getValueAndDerivatives() [5/8]

double PLMD::SparseGrid::getValueAndDerivatives ( index_t  index,
double *  der,
std::size_t  der_size 
) const
overridevirtual

get grid value and derivatives

Implements PLMD::GridBase.

◆ getValueAndDerivatives() [6/8]

virtual double PLMD::GridBase::getValueAndDerivatives

get grid value and derivatives

◆ getValueAndDerivatives() [7/8]

double PLMD::GridBase::getValueAndDerivatives ( index_t  index,
std::vector< double > &  der 
) const
inherited

◆ getValueAndDerivatives() [8/8]

double PLMD::GridBase::getValueAndDerivatives

◆ hasDerivatives()

bool PLMD::GridBase::hasDerivatives ( ) const
inlineinherited

get if the grid has derivatives

◆ Init()

void PLMD::GridBase::Init ( const std::string &  funcl,
const std::vector< std::string > &  names,
const std::vector< std::string > &  gmin,
const std::vector< std::string > &  gmax,
const std::vector< unsigned > &  nbin,
bool  dospline,
bool  usederiv,
const std::vector< bool > &  isperiodic,
const std::vector< std::string > &  pmin,
const std::vector< std::string > &  pmax 
)
inherited

this is the real initializator

◆ resetToDefaultOutputFmt()

void PLMD::GridBase::resetToDefaultOutputFmt ( )
inlineinherited

reset output format to the default %14.9f format

◆ setOutputFmt()

void PLMD::GridBase::setOutputFmt ( const std::string &  ss)
inlineinherited

set output format

◆ setValue() [1/4]

void PLMD::GridBase::setValue ( const std::vector< unsigned > &  indices,
double  value 
)
inherited

◆ setValue() [2/4]

void PLMD::GridBase::setValue

◆ setValue() [3/4]

void PLMD::SparseGrid::setValue ( index_t  index,
double  value 
)
overridevirtual

set grid value

Implements PLMD::GridBase.

◆ setValue() [4/4]

virtual void PLMD::GridBase::setValue

set grid value

◆ setValueAndDerivatives() [1/4]

void PLMD::GridBase::setValueAndDerivatives ( const std::vector< unsigned > &  indices,
double  value,
std::vector< double > &  der 
)
inherited

◆ setValueAndDerivatives() [2/4]

void PLMD::GridBase::setValueAndDerivatives

◆ setValueAndDerivatives() [3/4]

void PLMD::SparseGrid::setValueAndDerivatives ( index_t  index,
double  value,
std::vector< double > &  der 
)
overridevirtual

set grid value and derivatives

Implements PLMD::GridBase.

◆ setValueAndDerivatives() [4/4]

virtual void PLMD::GridBase::setValueAndDerivatives

set grid value and derivatives

◆ writeCubeFile()

void PLMD::GridBase::writeCubeFile ( OFile ofile,
const double &  lunit 
)
inherited

dump grid to gaussian cube file

◆ writeHeader()

void PLMD::GridBase::writeHeader ( OFile file)
inherited

write header for grid file

◆ writeToFile()

void PLMD::SparseGrid::writeToFile ( OFile ofile)
overridevirtual

dump grid on file

Implements PLMD::GridBase.

Member Data Documentation

◆ accelerator

AcceleratorHandler PLMD::GridBase::accelerator
protectedinherited

◆ argnames

std::vector<std::string> PLMD::GridBase::argnames
protectedinherited

◆ der_

std::map< index_t,std::vector<double> > PLMD::SparseGrid::der_
private

◆ dimension_

unsigned PLMD::GridBase::dimension_
protectedinherited

◆ dospline_

bool PLMD::GridBase::dospline_
protectedinherited

◆ dx_

std::vector<double> PLMD::GridBase::dx_
protectedinherited

◆ fmt_

std::string PLMD::GridBase::fmt_
protectedinherited

◆ funcname

std::string PLMD::GridBase::funcname
protectedinherited

◆ map_

std::map<index_t,double> PLMD::SparseGrid::map_
private

◆ max_

std::vector<double> PLMD::GridBase::max_
protectedinherited

◆ maxdim

constexpr std::size_t PLMD::GridBase::maxdim =16
staticconstexprinherited

Maximum dimension (exaggerated value).

Can be used to replace local std::vectors with std::arrays (allocated on stack).

◆ maxsize_

index_t PLMD::GridBase::maxsize_
protectedinherited

◆ min_

std::vector<double> PLMD::GridBase::min_
protectedinherited

◆ nbin_

std::vector<unsigned> PLMD::GridBase::nbin_
protectedinherited

◆ pbc_

std::vector<bool> PLMD::GridBase::pbc_
protectedinherited

◆ str_max_

std::vector<std::string> PLMD::GridBase::str_max_
protectedinherited

◆ str_min_

std::vector<std::string> PLMD::GridBase::str_min_
protectedinherited

◆ usederiv_

bool PLMD::GridBase::usederiv_
protectedinherited

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