SG++-Doxygen-Documentation
sgpp::base::GridDataBase Class Reference

Class that allows to keep a storage of arbitrary grid points. More...

#include <GridDataBase.hpp>

Public Types

typedef grid_map::const_iterator grid_map_const_iterator
 
typedef grid_map::iterator grid_map_iterator
 

Public Member Functions

grid_map_iterator begin ()
 Return iterator to beginning. More...
 
void clear ()
 Clears database, removing all entries. More...
 
size_t dim () const
 Returns the dimensionality of the grid points. More...
 
grid_map_iterator end ()
 Return iterator to end. More...
 
double get (GridPoint *gi)
 Get value for grid point from database. More...
 
 GridDataBase (size_t dim)
 Standard Constructor, creating an empty database with dimensionality dim. More...
 
 GridDataBase (Grid *grid, DataVector &values)
 Constructor, copying from existing grid and values. More...
 
 GridDataBase (const std::string &filename)
 Constructor, reading from existing database. More...
 
bool hasKey (GridPoint *gi)
 Test, whether database already contains a grid point. More...
 
void load (const std::string filename)
 Loads database in ASCII or binary format. More...
 
void remove (GridPoint *gi)
 Remove grid point from database. More...
 
void save (std::string filename, char ftype=GridDataBase::ascii)
 Save database to file. More...
 
void set (GridPoint *gi, double value)
 Store (grid point - value) pair in database. More...
 
void setValuesFor (Grid *grid, DataVector &values)
 Set values for given grid from stored ones in database. More...
 
size_t size () const
 Returns the number of grid points that are currently stored in the database. More...
 
std::string toString ()
 Returns std::string representation of database. More...
 
 ~GridDataBase ()
 Destructor. More...
 

Static Public Attributes

static const char ascii = 'a'
 
static const char binary = 'b'
 

Detailed Description

Class that allows to keep a storage of arbitrary grid points.

It has the functionality of a dictionary that is used for storing and retrieving grid points. Internally, a hash_map is used.

Note: GridDataBase currently supports only to store pairs of (grid point -> double).

Member Typedef Documentation

◆ grid_map_const_iterator

typedef grid_map::const_iterator sgpp::base::GridDataBase::grid_map_const_iterator

◆ grid_map_iterator

typedef grid_map::iterator sgpp::base::GridDataBase::grid_map_iterator

Constructor & Destructor Documentation

◆ GridDataBase() [1/3]

sgpp::base::GridDataBase::GridDataBase ( size_t  dim)
explicit

Standard Constructor, creating an empty database with dimensionality dim.

Parameters
dimthe dimensionality of the grid points

◆ GridDataBase() [2/3]

sgpp::base::GridDataBase::GridDataBase ( Grid grid,
DataVector values 
)

Constructor, copying from existing grid and values.

Parameters
gridthe grid to copy from
valuesthe initial values

References sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSequenceNumber(), sgpp::base::HashGridStorage::getSize(), sgpp::base::Grid::getStorage(), and python.statsfileInfo::i.

◆ GridDataBase() [3/3]

sgpp::base::GridDataBase::GridDataBase ( const std::string &  filename)
explicit

Constructor, reading from existing database.

Parameters
filenamefilename of database file

References dim(), and python.datasetAnalysis::ftype.

◆ ~GridDataBase()

sgpp::base::GridDataBase::~GridDataBase ( )

Destructor.

References clear().

Member Function Documentation

◆ begin()

GridDataBase::grid_map_iterator sgpp::base::GridDataBase::begin ( )

Return iterator to beginning.

Entries are of type pair<GridPoint, double>.

Returns
iterator to beginning.

Referenced by dim().

◆ clear()

void sgpp::base::GridDataBase::clear ( )

Clears database, removing all entries.

Dimensionality is maintained.

Referenced by ~GridDataBase().

◆ dim()

size_t sgpp::base::GridDataBase::dim ( ) const
inline

Returns the dimensionality of the grid points.

Returns
the dimensionality of the grid points

References ascii, begin(), end(), load(), and save().

Referenced by python.uq.dists.KDEDist.KDEDist::cov(), python.uq.dists.NatafDist.NatafDist::getDim(), GridDataBase(), load(), python.uq.dists.KDEDist.KDEDist::rvs(), and python.uq.dists.NatafDist.NatafDist::rvs().

◆ end()

GridDataBase::grid_map_iterator sgpp::base::GridDataBase::end ( )

Return iterator to end.

Returns
iterator to end.

Referenced by dim().

◆ get()

double sgpp::base::GridDataBase::get ( GridPoint gi)

Get value for grid point from database.

Return NULL if not existant.

Parameters
gia grid point
Returns
value

References sgpp::base::HashGridPoint::toString().

◆ hasKey()

bool sgpp::base::GridDataBase::hasKey ( GridPoint gi)

Test, whether database already contains a grid point.

Parameters
gia grid point
Returns
false, if grid point not in database

◆ load()

void sgpp::base::GridDataBase::load ( const std::string  filename)

Loads database in ASCII or binary format.

Adds (grid point - value) mappings to current database. Overwrites existing entries. To load a new database, use GridDataBase::GridDataBase(std::string filename).

Parameters
filenamename of file

References ascii, binary, dim(), python.utils.converter::filename, python.datasetAnalysis::ftype, and sgpp::base::HashGridPoint::set().

Referenced by dim().

◆ remove()

void sgpp::base::GridDataBase::remove ( GridPoint gi)

Remove grid point from database.

Do nothing, if not in database.

Parameters
gigrid point

Referenced by python.uq.uq_setting.UQSetting.UQSetting::cleanUp().

◆ save()

void sgpp::base::GridDataBase::save ( std::string  filename,
char  ftype = GridDataBase::ascii 
)

Save database to file.

Overwrites existing files without warning! Writes either ASCII (default) or binary format.

Parameters
filenamename of file
ftypefiletype (either ASCII, GridDataBase::asc (default), or binary, GridDataBase::bin)

References ascii.

Referenced by dim().

◆ set()

void sgpp::base::GridDataBase::set ( GridPoint gi,
double  value 
)

Store (grid point - value) pair in database.

Parameters
gia grid point
valuethe value to store

◆ setValuesFor()

void sgpp::base::GridDataBase::setValuesFor ( Grid grid,
DataVector values 
)

Set values for given grid from stored ones in database.

Parameters
grida grid
valuesthe corresponding coefficient vector

References sgpp::base::HashGridStorage::begin(), sgpp::base::HashGridStorage::end(), and sgpp::base::Grid::getStorage().

◆ size()

size_t sgpp::base::GridDataBase::size ( ) const
inline

Returns the number of grid points that are currently stored in the database.

Returns
the size of the database

◆ toString()

Member Data Documentation

◆ ascii

const char sgpp::base::GridDataBase::ascii = 'a'
static

Referenced by dim(), load(), and save().

◆ binary

const char sgpp::base::GridDataBase::binary = 'b'
static

Referenced by load().


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