Public Types | Public Member Functions | Static Public Member Functions | 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 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)
 
index_t getSize () const
 get grid size More...
 
index_t getMaxSize () const
 
double getValue (index_t index) const
 get grid value More...
 
double getValueAndDerivatives (index_t index, std::vector< double > &der) const
 get grid value and derivatives More...
 
void setValue (index_t index, double value)
 set grid value More...
 
void setValueAndDerivatives (index_t index, double value, std::vector< double > &der)
 set grid value and derivatives More...
 
void addValue (index_t index, double value)
 add to grid value More...
 
void addValueAndDerivatives (index_t index, double value, std::vector< double > &der)
 add to grid value and derivatives More...
 
void writeToFile (OFile &)
 dump grid on file More...
 
virtual ~SparseGrid ()
 
virtual double getMaxValue () const
 get maximum value More...
 
virtual double getMinValue () const
 get minimum value More...
 
virtual double getValue (index_t index) const
 this is to access to Grid:: version of these methods (allowing overloading of virtual methods) More...
 
virtual double getValue (const std::vector< unsigned > &indices) const
 this is to access to Grid:: version of these methods (allowing overloading of virtual methods) More...
 
virtual double getValue (const std::vector< double > &x) const
 this is to access to Grid:: version of these methods (allowing overloading of virtual methods) More...
 
virtual double getValueAndDerivatives (index_t index, std::vector< double > &der) const
 get grid value and derivatives More...
 
virtual double getValueAndDerivatives (const std::vector< unsigned > &indices, std::vector< double > &der) const
 
virtual double getValueAndDerivatives (const std::vector< double > &x, std::vector< double > &der) const
 
virtual void setValue (index_t index, double value)
 set grid value More...
 
virtual void setValue (const std::vector< unsigned > &indices, double value)
 
virtual void setValueAndDerivatives (index_t index, double value, std::vector< double > &der)
 set grid value and derivatives More...
 
virtual void setValueAndDerivatives (const std::vector< unsigned > &indices, double value, std::vector< double > &der)
 
virtual void addValue (index_t index, double value)
 add to grid value More...
 
virtual void addValue (const std::vector< unsigned > &indices, double value)
 
virtual void addValueAndDerivatives (index_t index, double value, std::vector< double > &der)
 add to grid value and derivatives More...
 
virtual void addValueAndDerivatives (const std::vector< unsigned > &indices, double value, std::vector< double > &der)
 
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, bool doclear, const std::vector< bool > &isperiodic, const std::vector< std::string > &pmin, const std::vector< std::string > &pmax)
 this is the real initializator More...
 
std::vector< std::string > getMin () const
 get lower boundary More...
 
std::vector< std::string > getMax () const
 get upper boundary More...
 
std::vector< double > getDx () const
 get bin size More...
 
double getBinVolume () const
 get bin volume More...
 
std::vector< unsigned > getNbin () const
 get number of bins More...
 
std::vector< bool > getIsPeriodic () const
 get if periodic More...
 
unsigned getDimension () const
 get grid dimension More...
 
std::vector< std::string > getArgNames () const
 get argument names of this grid More...
 
bool hasDerivatives () const
 get if the grid has derivatives More...
 
std::vector< unsigned > getIndices (index_t index) const
 methods to handle grid indices More...
 
std::vector< unsigned > getIndices (const std::vector< double > &x) const
 
index_t getIndex (const std::vector< unsigned > &indices) const
 
index_t getIndex (const std::vector< double > &x) const
 
std::vector< double > getPoint (index_t index) const
 
std::vector< double > getPoint (const std::vector< unsigned > &indices) const
 
std::vector< double > getPoint (const std::vector< double > &x) const
 
void getPoint (index_t index, std::vector< double > &point) const
 faster versions relying on preallocated vectors More...
 
void getPoint (const std::vector< unsigned > &indices, std::vector< double > &point) const
 
void getPoint (const std::vector< double > &x, std::vector< double > &point) const
 
std::vector< index_tgetNeighbors (index_t index, const std::vector< unsigned > &neigh) const
 get neighbors More...
 
std::vector< index_tgetNeighbors (const std::vector< unsigned > &indices, const std::vector< unsigned > &neigh) const
 
std::vector< index_tgetNeighbors (const std::vector< double > &x, const std::vector< unsigned > &neigh) const
 
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
 
void writeHeader (OFile &file)
 write header for grid file More...
 
virtual double getValue (const std::vector< unsigned > &indices) const
 
virtual double getValue (const std::vector< double > &x) const
 
virtual double getValueAndDerivatives (const std::vector< unsigned > &indices, std::vector< double > &der) const
 
virtual double getValueAndDerivatives (const std::vector< double > &x, std::vector< double > &der) const
 
double getDifferenceFromContour (const std::vector< double > &x, std::vector< double > &der) const
 Get the difference from the contour. More...
 
void findSetOfPointsOnContour (const double &target, const std::vector< bool > &nosearch, unsigned &npoints, std::vector< std::vector< double > > &points)
 Find a set of points on a contour in the function. More...
 
virtual void setValue (const std::vector< unsigned > &indices, double value)
 
virtual void setValueAndDerivatives (const std::vector< unsigned > &indices, double value, std::vector< double > &der)
 
virtual void addValue (const std::vector< unsigned > &indices, double value)
 
virtual void addValueAndDerivatives (const std::vector< unsigned > &indices, double value, std::vector< double > &der)
 
virtual void scaleAllValuesAndDerivatives (const double &scalef)
 Scale all grid values and derivatives by a constant factor. More...
 
virtual void logAllValuesAndDerivatives (const double &scalef)
 Takes the scalef times the logarithm of all grid values and derivatives. More...
 
virtual void setMinToZero ()
 Set the minimum value of the grid to zero and translates accordingly. More...
 
virtual void applyFunctionAllValuesAndDerivatives (double(*func)(double val), double(*funcder)(double valder))
 apply function: takes pointer to function that accepts a double and apply More...
 
void addKernel (const KernelFunctions &kernel)
 add a kernel function to the grid More...
 
void writeCubeFile (OFile &, const double &lunit)
 dump grid to gaussian cube file More...
 
Grid project (const std::vector< std::string > &proj, WeightBase *ptr2obj)
 project a high dimensional grid onto a low dimensional one: this should be changed at some time to enable many types of weighting More...
 
void projectOnLowDimension (double &val, std::vector< int > &varHigh, WeightBase *ptr2obj)
 
void setOutputFmt (const std::string &ss)
 set output format More...
 
void resetToDefaultOutputFmt ()
 reset output format to the default %14.9f format More...
 
double integrate (std::vector< unsigned > &npoints)
 Integrate the function calculated on the grid. More...
 
void mpiSumValuesAndDerivatives (Communicator &comm)
 
virtual 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...
 

Static Public Member Functions

static Gridcreate (const std::string &, const std::vector< Value *> &, IFile &, bool, bool, bool)
 read grid from file More...
 
static Gridcreate (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...
 

Protected Member Functions

void clear ()
 clear grid More...
 
std::vector< index_tgetSplineNeighbors (const std::vector< unsigned > &indices) const
 get "neighbors" for spline More...
 

Protected Attributes

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

Private Attributes

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

Member Typedef Documentation

◆ index_t

typedef size_t PLMD::Grid::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 ( )
inlinevirtual

Member Function Documentation

◆ addKernel()

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

add a kernel function to the grid

◆ addValue() [1/4]

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

◆ addValue() [2/4]

void PLMD::Grid::addValue

add to grid value

◆ addValue() [3/4]

void PLMD::Grid::addValue

◆ addValue() [4/4]

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

add to grid value

Reimplemented from PLMD::Grid.

◆ addValueAndDerivatives() [1/4]

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

◆ addValueAndDerivatives() [2/4]

void PLMD::Grid::addValueAndDerivatives

add to grid value and derivatives

◆ addValueAndDerivatives() [3/4]

void PLMD::Grid::addValueAndDerivatives

◆ addValueAndDerivatives() [4/4]

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

add to grid value and derivatives

Reimplemented from PLMD::Grid.

◆ applyFunctionAllValuesAndDerivatives()

void PLMD::Grid::applyFunctionAllValuesAndDerivatives ( double(*)(double val)  func,
double(*)(double valder)  funcder 
)
virtualinherited

apply function: takes pointer to function that accepts a double and apply

◆ clear()

void PLMD::SparseGrid::clear ( )
protectedvirtual

clear grid

Reimplemented from PLMD::Grid.

◆ create() [1/2]

Grid * PLMD::Grid::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]

Grid * PLMD::Grid::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::Grid::findMaximalPathMinimum ( const std::vector< double > &  source,
const std::vector< double > &  sink 
)
virtualinherited

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.

◆ findSetOfPointsOnContour()

void PLMD::Grid::findSetOfPointsOnContour ( const double &  target,
const std::vector< bool > &  nosearch,
unsigned &  npoints,
std::vector< std::vector< double > > &  points 
)
inherited

Find a set of points on a contour in the function.

◆ getArgNames()

vector< string > PLMD::Grid::getArgNames ( ) const
inherited

get argument names of this grid

◆ getBinVolume()

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

get bin volume

◆ getDifferenceFromContour()

double PLMD::Grid::getDifferenceFromContour ( const std::vector< double > &  x,
std::vector< double > &  der 
) const
inherited

Get the difference from the contour.

◆ getDimension()

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

get grid dimension

◆ getDx()

vector< double > PLMD::Grid::getDx ( ) const
inherited

get bin size

◆ getIndex() [1/2]

Grid::index_t PLMD::Grid::getIndex ( const std::vector< unsigned > &  indices) const
inherited

◆ getIndex() [2/2]

Grid::index_t PLMD::Grid::getIndex ( const std::vector< double > &  x) const
inherited

◆ getIndices() [1/2]

vector< unsigned > PLMD::Grid::getIndices ( index_t  index) const
inherited

methods to handle grid indices

◆ getIndices() [2/2]

vector< unsigned > PLMD::Grid::getIndices ( const std::vector< double > &  x) const
inherited

◆ getIsPeriodic()

vector< bool > PLMD::Grid::getIsPeriodic ( ) const
inherited

get if periodic

◆ getMax()

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

get upper boundary

◆ getMaxSize()

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

◆ getMaxValue()

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

get maximum value

Reimplemented from PLMD::Grid.

◆ getMin()

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

get lower boundary

◆ getMinValue()

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

get minimum value

Reimplemented from PLMD::Grid.

◆ getNbin()

vector< unsigned > PLMD::Grid::getNbin ( ) const
inherited

get number of bins

◆ getNearestNeighbors() [1/2]

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

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

◆ getNearestNeighbors() [2/2]

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

◆ getNeighbors() [1/3]

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

get neighbors

◆ getNeighbors() [2/3]

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

◆ getNeighbors() [3/3]

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

◆ getPoint() [1/6]

vector< double > PLMD::Grid::getPoint ( index_t  index) const
inherited

◆ getPoint() [2/6]

vector< double > PLMD::Grid::getPoint ( const std::vector< unsigned > &  indices) const
inherited

◆ getPoint() [3/6]

vector< double > PLMD::Grid::getPoint ( const std::vector< double > &  x) const
inherited

◆ getPoint() [4/6]

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

faster versions relying on preallocated vectors

◆ getPoint() [5/6]

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

◆ getPoint() [6/6]

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

◆ getSize()

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

get grid size

Reimplemented from PLMD::Grid.

◆ getSplineNeighbors()

vector< Grid::index_t > PLMD::Grid::getSplineNeighbors ( const std::vector< unsigned > &  indices) const
protectedinherited

get "neighbors" for spline

◆ getValue() [1/6]

double PLMD::Grid::getValue ( const std::vector< unsigned > &  indices) const
virtualinherited

◆ getValue() [2/6]

double PLMD::Grid::getValue ( const std::vector< double > &  x) const
virtualinherited

◆ getValue() [3/6]

double PLMD::Grid::getValue

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

◆ getValue() [4/6]

double PLMD::Grid::getValue

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

◆ getValue() [5/6]

double PLMD::Grid::getValue

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

◆ getValue() [6/6]

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

get grid value

Reimplemented from PLMD::Grid.

◆ getValueAndDerivatives() [1/6]

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

◆ getValueAndDerivatives() [2/6]

double PLMD::Grid::getValueAndDerivatives ( const std::vector< double > &  x,
std::vector< double > &  der 
) const
virtualinherited

◆ getValueAndDerivatives() [3/6]

double PLMD::Grid::getValueAndDerivatives

get grid value and derivatives

◆ getValueAndDerivatives() [4/6]

double PLMD::Grid::getValueAndDerivatives

◆ getValueAndDerivatives() [5/6]

double PLMD::Grid::getValueAndDerivatives

◆ getValueAndDerivatives() [6/6]

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

get grid value and derivatives

Reimplemented from PLMD::Grid.

◆ hasDerivatives()

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

get if the grid has derivatives

◆ Init()

void PLMD::Grid::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,
bool  doclear,
const std::vector< bool > &  isperiodic,
const std::vector< std::string > &  pmin,
const std::vector< std::string > &  pmax 
)
inherited

this is the real initializator

◆ integrate()

double PLMD::Grid::integrate ( std::vector< unsigned > &  npoints)
inherited

Integrate the function calculated on the grid.

◆ logAllValuesAndDerivatives()

void PLMD::Grid::logAllValuesAndDerivatives ( const double &  scalef)
virtualinherited

Takes the scalef times the logarithm of all grid values and derivatives.

◆ mpiSumValuesAndDerivatives()

void PLMD::Grid::mpiSumValuesAndDerivatives ( Communicator comm)
inherited

◆ project()

Grid PLMD::Grid::project ( const std::vector< std::string > &  proj,
WeightBase ptr2obj 
)
inherited

project a high dimensional grid onto a low dimensional one: this should be changed at some time to enable many types of weighting

◆ projectOnLowDimension()

void PLMD::Grid::projectOnLowDimension ( double &  val,
std::vector< int > &  varHigh,
WeightBase ptr2obj 
)
inherited

◆ resetToDefaultOutputFmt()

void PLMD::Grid::resetToDefaultOutputFmt ( )
inlineinherited

reset output format to the default %14.9f format

◆ scaleAllValuesAndDerivatives()

void PLMD::Grid::scaleAllValuesAndDerivatives ( const double &  scalef)
virtualinherited

Scale all grid values and derivatives by a constant factor.

◆ setMinToZero()

void PLMD::Grid::setMinToZero ( )
virtualinherited

Set the minimum value of the grid to zero and translates accordingly.

◆ setOutputFmt()

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

set output format

◆ setValue() [1/4]

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

◆ setValue() [2/4]

void PLMD::Grid::setValue

set grid value

◆ setValue() [3/4]

void PLMD::Grid::setValue

◆ setValue() [4/4]

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

set grid value

Reimplemented from PLMD::Grid.

◆ setValueAndDerivatives() [1/4]

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

◆ setValueAndDerivatives() [2/4]

void PLMD::Grid::setValueAndDerivatives

◆ setValueAndDerivatives() [3/4]

void PLMD::Grid::setValueAndDerivatives

set grid value and derivatives

◆ setValueAndDerivatives() [4/4]

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

set grid value and derivatives

Reimplemented from PLMD::Grid.

◆ writeCubeFile()

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

dump grid to gaussian cube file

◆ writeHeader()

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

write header for grid file

◆ writeToFile()

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

dump grid on file

Reimplemented from PLMD::Grid.

Member Data Documentation

◆ argnames

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

◆ der_

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

◆ dimension_

unsigned PLMD::Grid::dimension_
protectedinherited

◆ dospline_

bool PLMD::Grid::dospline_
protectedinherited

◆ dx_

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

◆ fmt_

std::string PLMD::Grid::fmt_
protectedinherited

◆ funcname

std::string PLMD::Grid::funcname
protectedinherited

◆ map_

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

◆ max_

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

◆ maxsize_

index_t PLMD::Grid::maxsize_
protectedinherited

◆ min_

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

◆ nbin_

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

◆ pbc_

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

◆ str_max_

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

◆ str_min_

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

◆ usederiv_

bool PLMD::Grid::usederiv_
protectedinherited

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