All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Attributes | List of all members
PLMD::SparseGrid Class Reference

#include <Grid.h>

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

Public Member Functions

 SparseGrid (const std::string &funcl, 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)
 
unsigned getSize () const
 get grid size More...
 
unsigned getMaxSize () const
 
double getValue (unsigned index) const
 get grid value More...
 
double getValueAndDerivatives (unsigned index, std::vector< double > &der) const
 get grid value and derivatives More...
 
void setValue (unsigned index, double value)
 set grid value More...
 
void setValueAndDerivatives (unsigned index, double value, std::vector< double > &der)
 set grid value and derivatives More...
 
void addValue (unsigned index, double value)
 add to grid value More...
 
void addValueAndDerivatives (unsigned index, double value, std::vector< double > &der)
 add to grid value and derivatives More...
 
void writeToFile (OFile &)
 dump grid on file More...
 
virtual ~SparseGrid ()
 
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...
 
std::vector< unsigned > getIndices (unsigned index) const
 methods to handle grid indices More...
 
std::vector< unsigned > getIndices (const std::vector< double > &x) const
 
unsigned getIndex (const std::vector< unsigned > &indices) const
 
unsigned getIndex (const std::vector< double > &x) const
 
std::vector< double > getPoint (unsigned index) const
 
std::vector< double > getPoint (const std::vector< unsigned > &indices) const
 
std::vector< double > getPoint (const std::vector< double > &x) const
 
void getPoint (unsigned 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< unsigned > getNeighbors (unsigned index, const std::vector< unsigned > &neigh) const
 get neighbors More...
 
std::vector< unsigned > getNeighbors (const std::vector< unsigned > &indices, const std::vector< unsigned > &neigh) const
 
std::vector< unsigned > getNeighbors (const std::vector< double > &x, const std::vector< unsigned > &neigh) 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 getMinValue () const
 get minimum value More...
 
virtual double getMaxValue () const
 get maximum value 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 (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...
 
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 (std::string ss)
 set output format More...
 

Static Public Member Functions

static Gridcreate (const std::string &, std::vector< Value * >, IFile &, bool, bool, bool)
 read grid from file More...
 
static Gridcreate (const std::string &, 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< unsigned > getSplineNeighbors (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_
 
unsigned maxsize_
 
unsigned dimension_
 
bool dospline_
 
bool usederiv_
 
std::string fmt_
 

Private Types

typedef std::map< unsigned,
double >::const_iterator 
iterator
 
typedef std::map< unsigned,
std::vector< double >
>::const_iterator 
iterator_der
 

Private Attributes

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

Member Typedef Documentation

typedef std::map<unsigned,double>::const_iterator PLMD::SparseGrid::iterator
private
typedef std::map<unsigned,std::vector<double> >::const_iterator PLMD::SparseGrid::iterator_der
private

Constructor & Destructor Documentation

PLMD::SparseGrid::SparseGrid ( const std::string &  funcl,
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
virtual PLMD::SparseGrid::~SparseGrid ( )
inlinevirtual

Member Function Documentation

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

add a kernel function to the grid

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

add to grid value

Reimplemented from PLMD::Grid.

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

add to grid value and derivatives

Reimplemented from PLMD::Grid.

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

void PLMD::SparseGrid::clear ( )
protectedvirtual

clear grid

Reimplemented from PLMD::Grid.

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

read grid from file

Grid * PLMD::Grid::create ( const std::string &  funcl,
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

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

get argument names of this grid

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

get bin volume

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

get grid dimension

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

get bin size

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

methods to handle grid indices

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

get if periodic

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

get upper boundary

unsigned PLMD::SparseGrid::getMaxSize ( ) const
double PLMD::Grid::getMaxValue ( ) const
virtualinherited

get maximum value

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

get lower boundary

double PLMD::Grid::getMinValue ( ) const
virtualinherited

get minimum value

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

get number of bins

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

get neighbors

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

faster versions relying on preallocated vectors

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

get grid size

Reimplemented from PLMD::Grid.

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

get "neighbors" for spline

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

get grid value

Reimplemented from PLMD::Grid.

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

get grid value and derivatives

Reimplemented from PLMD::Grid.

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

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

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

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

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

Scale all grid values and derivatives by a constant factor.

void PLMD::Grid::setMinToZero ( )
virtualinherited

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

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

set output format

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

set grid value

Reimplemented from PLMD::Grid.

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

set grid value and derivatives

Reimplemented from PLMD::Grid.

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

write header for grid file

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

dump grid on file

Reimplemented from PLMD::Grid.

Member Data Documentation

std::vector<std::string> PLMD::Grid::argnames
protectedinherited
std::map< unsigned,std::vector<double> > PLMD::SparseGrid::der_
private
unsigned PLMD::Grid::dimension_
protectedinherited
bool PLMD::Grid::dospline_
protectedinherited
std::vector<double> PLMD::Grid::dx_
protectedinherited
std::string PLMD::Grid::fmt_
protectedinherited
std::string PLMD::Grid::funcname
protectedinherited
std::map<unsigned,double> PLMD::SparseGrid::map_
private
std::vector<double> PLMD::Grid::max_
protectedinherited
unsigned PLMD::Grid::maxsize_
protectedinherited
std::vector<double> PLMD::Grid::min_
protectedinherited
std::vector<unsigned> PLMD::Grid::nbin_
protectedinherited
std::vector<bool> PLMD::Grid::pbc_
protectedinherited
std::vector<std::string> PLMD::Grid::str_max_
protectedinherited
std::vector<std::string> PLMD::Grid::str_min_
protectedinherited
bool PLMD::Grid::usederiv_
protectedinherited

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