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

This class provides the generation functionality of sparse grids based on hashmaps. More...

#include <HashGenerator.hpp>

Public Member Functions

void cliques (GridStorage &storage, level_t level, size_t clique_size, double T=0)
 Generates a regular sparse grid of level levels, without boundaries where dimensions are splitted into a groups with only certain number of dimensions completely connected in a clique. More...
 
void full (GridStorage &storage, level_t level)
 Generates a full grid of level level, without boundaries. More...
 
void fullWithBoundary (GridStorage &storage, level_t level)
 Generates a full grid of level level, with boundary grid points. More...
 
void regular (GridStorage &storage, level_t level, double T=0)
 Generates a regular sparse grid of level levels, without boundaries. More...
 
void regular_inter (GridStorage &storage, level_t level, const std::unordered_set< std::vector< bool >> &terms, double T=0)
 
void regularInter (GridStorage &storage, level_t level, const std::vector< std::vector< size_t >> &terms, double T=0)
 Generates a regular sparse grid of level level, without boundaries. More...
 
void regularWithBoundaries (GridStorage &storage, level_t level, level_t boundaryLevel=1)
 Generates a regular sparse grid of level levels with boundaries. More...
 
void regularWithPeriodicBoundaries (GridStorage &storage, level_t level, double T=0)
 Generates a regular sparse grid of level levels with boundaries. More...
 
void squareRoot (GridStorage &storage, level_t level)
 Generates a regular square root grid of level level with boundaries. More...
 
void truncated (GridStorage &storage, level_t level, level_t k)
 Generates a truncated boundary grid containing all gridpoints with li<l-k and |l|<l+(dim-1)*k. More...
 

Protected Member Functions

void boundaries_rec (GridStorage &storage, GridPoint &index, size_t current_dim, level_t current_level, level_t level)
 recursive construction of the spare grid with boundaries, classic level 0 approach, only for level 0 and 1 More...
 
void boundaries_truncated_rec (GridStorage &storage, GridPoint &index, size_t current_dim, level_t current_level, level_t level, bool bLevelZero)
 recursive construction of the spare grid without boundaries More...
 
void boundaries_Truncated_rec_1d (GridStorage &storage, GridPoint &index, level_t current_level, level_t level, bool bLevelZero)
 generate points of the last dimension (dim == 0), version of pentagon cut in sub space scheme More...
 
void cliques_iter (GridStorage &storage, level_t n, size_t clique_size, double T=0)
 
void createFullGridIterative (GridStorage &storage, level_t n)
 Generate a full grid iteratively (much faster than recursively) without grid points on the boundary. More...
 
void createFullGridTruncatedIterative (GridStorage &storage, level_t n)
 Generate a full grid iteratively (much faster than recursively) with truncated boundary. More...
 
void decodeCoords (DataVector &coords, std::vector< bool > &result)
 
void regular_boundary_truncated_iter (GridStorage &storage, level_t n, level_t boundaryLevel=1, double T=0)
 Generate a regular sparse grid iteratively (much faster than recursively) with truncated boundary, i.e., the sparse grid on the \((d-1)\)-dimensional faces of \([0, 1]^d\) has a coarser level than the main axes \(x_t = 0.5, t = 1, ..., d\). More...
 
void regular_inter_iter (GridStorage &storage, level_t n, const std::unordered_set< std::vector< bool >> &terms, double T=0)
 
void regular_iter (GridStorage &storage, level_t n, double T=0)
 Generate a regular sparse grid iteratively (much faster than recursively) without grid points on the boundary. More...
 
void regular_periodic_boundary_iter (GridStorage &storage, level_t n, double T=0)
 Generate a regular sparse grid iteratively (much faster than recursively) with periodic boundary. More...
 
void square_rec (GridStorage &storage, GridPoint &index, size_t current_dim, level_t level, level_t small_level, bool tail, size_t sum)
 recursive construction of a square root grid with boundaries More...
 
void trunc_rec (GridStorage &storage, GridPoint &index, size_t current_dim, level_t current_level, level_t level, level_t minlevel)
 recursive construction of a super truncated grid with boundaries More...
 

Detailed Description

This class provides the generation functionality of sparse grids based on hashmaps.

Grids with and without boundaries are supported.

For boundary grids two cases are supported:

  1. the classic sparse grid with level 0 and a diagonal cut through the sub space scheme.
  2. a modified boundary grid with level 0 and a pentagon cut trough the sub space scheme.

Furthermore, the creation of full grids (in the hierarchical basis) is supported.

Member Function Documentation

◆ boundaries_rec()

void sgpp::base::HashGenerator::boundaries_rec ( GridStorage storage,
GridPoint index,
size_t  current_dim,
level_t  current_level,
level_t  level 
)
inlineprotected

recursive construction of the spare grid with boundaries, classic level 0 approach, only for level 0 and 1

Parameters
storagehashmap that stores the grid points
indexpoint's index
current_dimcurrent working dimension
current_levelcurrent level in this construction step
levelmaximum level of the sparse grid

References sgpp::base::HashGridPoint::get(), sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::isLeaf(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridPoint::setLeaf().

Referenced by regularWithBoundaries().

◆ boundaries_truncated_rec()

void sgpp::base::HashGenerator::boundaries_truncated_rec ( GridStorage storage,
GridPoint index,
size_t  current_dim,
level_t  current_level,
level_t  level,
bool  bLevelZero 
)
inlineprotected

recursive construction of the spare grid without boundaries

Parameters
storagehashmap that stores the grid points
indexpoint's index
current_dimcurrent working dimension
current_levelcurrent level in this construction step
levelmaximum level of the sparse grid generate points of the last dimension (dim == 0), without boundaries
storagethe hashmap that stores the grid points
indexpoint's index that should be created on the grid
current_levelcurrent level of the grid generation
levelmaximum level of grid recursive construction of the spare grid with boundaries, pentagon cut
storagehashmap that stores the grid points
indexpoint's index
current_dimcurrent working dimension
current_levelcurrent level in this construction step
levelmaximum level of the sparse grid
bLevelZerospecifies if the current index has a level zero component

References boundaries_Truncated_rec_1d(), sgpp::base::HashGridPoint::get(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridPoint::setLeaf().

◆ boundaries_Truncated_rec_1d()

void sgpp::base::HashGenerator::boundaries_Truncated_rec_1d ( GridStorage storage,
GridPoint index,
level_t  current_level,
level_t  level,
bool  bLevelZero 
)
inlineprotected

generate points of the last dimension (dim == 0), version of pentagon cut in sub space scheme

Parameters
storagethe hashmap that stores the grid points
indexpoint's index that should be created on the grid
current_levelcurrent level of the grid generation
levelmaximum level of grid
bLevelZerospecifies if the current index has a level zero component

References python.statsfileInfo::i, sgpp::base::HashGridStorage::insert(), and sgpp::base::HashGridPoint::push().

Referenced by boundaries_truncated_rec().

◆ cliques()

void sgpp::base::HashGenerator::cliques ( GridStorage storage,
level_t  level,
size_t  clique_size,
double  T = 0 
)
inline

Generates a regular sparse grid of level levels, without boundaries where dimensions are splitted into a groups with only certain number of dimensions completely connected in a clique.

Parameters
storageHashmap that stores the grid points
levelGrid level (non-negative value)
clique_sizenumber of dimensions in a clique
Tmodifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensor-product approximation spaces

References cliques_iter(), sgpp::base::HashGridStorage::getDimension(), and sgpp::base::HashGridStorage::getSize().

Referenced by sgpp::base::StandardGridGenerator::cliques(), sgpp::base::PeriodicGridGenerator::cliques(), and sgpp::base::PrewaveletGridGenerator::cliques().

◆ cliques_iter()

◆ createFullGridIterative()

void sgpp::base::HashGenerator::createFullGridIterative ( GridStorage storage,
level_t  n 
)
inlineprotected

Generate a full grid iteratively (much faster than recursively) without grid points on the boundary.

Parameters
storagePointer to the storage object into which the grid points should be stored
nLevel of full grid

References g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), python.statsfileInfo::i, sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridStorage::update().

Referenced by full().

◆ createFullGridTruncatedIterative()

void sgpp::base::HashGenerator::createFullGridTruncatedIterative ( GridStorage storage,
level_t  n 
)
inlineprotected

Generate a full grid iteratively (much faster than recursively) with truncated boundary.

Parameters
storagePointer to the storage object into which the grid points should be stored
nLevel of full grid

References g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), python.statsfileInfo::i, sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridStorage::update().

Referenced by fullWithBoundary().

◆ decodeCoords()

void sgpp::base::HashGenerator::decodeCoords ( DataVector coords,
std::vector< bool > &  result 
)
inlineprotected

◆ full()

void sgpp::base::HashGenerator::full ( GridStorage storage,
level_t  level 
)
inline

Generates a full grid of level level, without boundaries.

Parameters
storageHashmap that stores the grid points
levelGrid level (non-negative value)

References createFullGridIterative(), and sgpp::base::HashGridStorage::getSize().

Referenced by sgpp::base::StandardGridGenerator::full(), and sgpp::base::PrewaveletGridGenerator::full().

◆ fullWithBoundary()

void sgpp::base::HashGenerator::fullWithBoundary ( GridStorage storage,
level_t  level 
)
inline

Generates a full grid of level level, with boundary grid points.

Parameters
storageHashmap that stores the grid points
levelGrid level (non-negative value)

References createFullGridTruncatedIterative(), and sgpp::base::HashGridStorage::getSize().

Referenced by sgpp::base::StretchedBoundaryGridGenerator::full(), sgpp::base::L0BoundaryGridGenerator::full(), and sgpp::base::BoundaryGridGenerator::full().

◆ regular()

void sgpp::base::HashGenerator::regular ( GridStorage storage,
level_t  level,
double  T = 0 
)
inline

Generates a regular sparse grid of level levels, without boundaries.

Parameters
storageHashmap that stores the grid points
levelGrid level (non-negative value)
Tmodifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensor-product approximation spaces. The effect of T can be seen in:
generalisedGrid.svg

References sgpp::base::HashGridStorage::getSize(), and regular_iter().

Referenced by sgpp::base::StandardGridGenerator::regular(), and sgpp::base::PrewaveletGridGenerator::regular().

◆ regular_boundary_truncated_iter()

void sgpp::base::HashGenerator::regular_boundary_truncated_iter ( GridStorage storage,
level_t  n,
level_t  boundaryLevel = 1,
double  T = 0 
)
inlineprotected

Generate a regular sparse grid iteratively (much faster than recursively) with truncated boundary, i.e., the sparse grid on the \((d-1)\)-dimensional faces of \([0, 1]^d\) has a coarser level than the main axes \(x_t = 0.5, t = 1, ..., d\).

The function adds all hierarchical subspaces \(W_{\vec{\ell}}\) where

  • \(\norm{\vec{\ell}}_1 \le n + d - 1\) with \(\forall_t\; \ell_t \ge 1\),
  • \(\norm{\vec{\ell}}_1 \le n + d - b - N_{\vec{\ell}}\) with \(N_{\vec{\ell}} := |\{t \mid \ell_t = 0\}| \ge 1\), or
  • \(\vec{\ell} = \vec{0}\).

The previous implementation inserted the 1D boundary grid points at higher levels (e.g., at boundaryLevel = 2), which led to the effect that corner points were missing in higher-dimensional grids: For example, if \(d = 2\), \(n = 3\), and \(\mathtt{boundaryLevel} = 3\), then the four corners had level sum \(2 \cdot \mathtt{boundaryLevel} = 6\) (which is greater than \(n + d - 1 = 4\)), thus they were missing in the sparse grid. The midpoints of the four edges, however, had level sum \(\mathtt{boundaryLevel} + 1 = 4 \le n + d - 1\) and were thus included in the grid. To get the corners into the grid, too, one would have to choose \(n \ge 4\).

In contrast, the new implementation makes sure that the corners will always appear first in the grid when increasing the level \(n = 1, 2, 3, \dotsc\) of the regular grid.

Parameters
storagepointer to storage object into which the grid points should be stored
nlevel of regular sparse grid
boundaryLevel1 + how much levels the boundary is coarser than the main axes, 1 means same level, 2 means one level coarser, etc.; must be >= 1
Tmodifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensor-product approximation spaces

References chess::dim, g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), python.statsfileInfo::i, sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), python.painlesscg::sd(), analyse_erg::tmp, and sgpp::base::HashGridStorage::update().

Referenced by regularWithBoundaries().

◆ regular_inter()

void sgpp::base::HashGenerator::regular_inter ( GridStorage storage,
level_t  level,
const std::unordered_set< std::vector< bool >> &  terms,
double  T = 0 
)
inline

◆ regular_inter_iter()

◆ regular_iter()

void sgpp::base::HashGenerator::regular_iter ( GridStorage storage,
level_t  n,
double  T = 0 
)
inlineprotected

Generate a regular sparse grid iteratively (much faster than recursively) without grid points on the boundary.

Parameters
storagepointer to storage object into which the grid points should be stored
nlevel of regular sparse grid
Tmodifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensor-product approximation spaces

References g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridPoint::getLevelSum(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), python.statsfileInfo::i, sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridStorage::update().

Referenced by regular().

◆ regular_periodic_boundary_iter()

void sgpp::base::HashGenerator::regular_periodic_boundary_iter ( GridStorage storage,
level_t  n,
double  T = 0 
)
inlineprotected

Generate a regular sparse grid iteratively (much faster than recursively) with periodic boundary.

Parameters
storagePointer to storage object into which the grid points should be stored
nLevel of regular sparse grid
Tmodifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensor-product approximation spaces

References g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridPoint::getLevelSum(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), python.statsfileInfo::i, sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), python.painlesscg::sd(), and sgpp::base::HashGridStorage::update().

Referenced by regularWithPeriodicBoundaries().

◆ regularInter()

void sgpp::base::HashGenerator::regularInter ( GridStorage storage,
level_t  level,
const std::vector< std::vector< size_t >> &  terms,
double  T = 0 
)
inline

Generates a regular sparse grid of level level, without boundaries.

The resulting grid only contains interactions that are in the vector terms.

Parameters
storageHashmap that stores the grid points
levelGrid level (non-negative value)
termscontrols the desired interaction terms. For example, if we want to include grid points that model an interaction between the first and the second predictor, we would include the vector [1,2] in terms.
Tmodifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensor-product approximation spaces.

References chess::dim, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getSize(), python.statsfileInfo::i, and regular_inter().

Referenced by sgpp::base::StandardGridGenerator::regularInter().

◆ regularWithBoundaries()

void sgpp::base::HashGenerator::regularWithBoundaries ( GridStorage storage,
level_t  level,
level_t  boundaryLevel = 1 
)
inline

Generates a regular sparse grid of level levels with boundaries.

Parameters
storageHashmap, that stores the grid points
levelmaximum level of the sparse grid (non-negative value)
boundaryLevellevel at which the boundary points should be inserted

References boundaries_rec(), sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getSize(), level, chess::point, and regular_boundary_truncated_iter().

Referenced by sgpp::base::StretchedBoundaryGridGenerator::regular(), sgpp::base::L0BoundaryGridGenerator::regular(), and sgpp::base::BoundaryGridGenerator::regular().

◆ regularWithPeriodicBoundaries()

void sgpp::base::HashGenerator::regularWithPeriodicBoundaries ( GridStorage storage,
level_t  level,
double  T = 0 
)
inline

Generates a regular sparse grid of level levels with boundaries.

Parameters
storageHashmap, that stores the grid points
levelmaximum level of the sparse grid (non-negative value)
Tmodifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensor-product approximation spaces

References sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getSize(), chess::point, and regular_periodic_boundary_iter().

Referenced by sgpp::base::PeriodicGridGenerator::regular().

◆ square_rec()

void sgpp::base::HashGenerator::square_rec ( GridStorage storage,
GridPoint index,
size_t  current_dim,
level_t  level,
level_t  small_level,
bool  tail,
size_t  sum 
)
inlineprotected

recursive construction of a square root grid with boundaries

Parameters
storagehashmap that stores the grid points
indexpoint's index
current_dimcurrent working dimension
levelmaximum level of the square root grid
small_levellevel of coarsest descretization
tailtrue if there is a level of the index>level/2
sumsum of all levels

If a level of the node equals level, and all the others equal small_level, the node is a leaf This is equivalent to saying the sum of levels equals small_level*(dim-1)+level

If the level of the node is smaller than small_level or we didn't have yet a level greater than small_level(!tail) and the level is smaller then level then we can then proceed to the next level on this dimension, otherwise we reached the maximum possible level*

References sgpp::base::HashGridPoint::get(), sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridPoint::setLeaf().

Referenced by squareRoot().

◆ squareRoot()

void sgpp::base::HashGenerator::squareRoot ( GridStorage storage,
level_t  level 
)
inline

Generates a regular square root grid of level level with boundaries.

Parameters
storageHashmap, that stores the grid points
levelmaximum level of the square root grid (non-negative value)

Change here to the following code to take the [n/2]+1 grid as small level for odd numbers(and also change FullGridSet getSquare method) int small_level=ceil(level/2); if (level%2==0) level–;

References sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getSize(), level, chess::point, and square_rec().

Referenced by sgpp::base::SquareRootGridGenerator::regular().

◆ trunc_rec()

void sgpp::base::HashGenerator::trunc_rec ( GridStorage storage,
GridPoint index,
size_t  current_dim,
level_t  current_level,
level_t  level,
level_t  minlevel 
)
inlineprotected

recursive construction of a super truncated grid with boundaries

Parameters
storagehashmap that stores the grid points
indexpoint's index
current_dimcurrent working dimension
current_levelthe current level of the gridpoint so far, starts from minlevel*dim
levelthe maximum level of the gridpoint
minlevelthe level limit given by the user(tells us which fullgrids won't be present in the construction of the sparse grid)

If the source level of the node is smaller than minlevel we don't increase the variable current_level(since we started with minlevel*dim) This trick makes it possible to introduce all nodes with source_level<minlevel without a separate treatment

if the source_level is already >=minlevel we can proceed naturally and increase the current_level which represents the sum of levels so far

References sgpp::base::HashGridPoint::get(), sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::isLeaf(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridPoint::setLeaf().

Referenced by truncated().

◆ truncated()

void sgpp::base::HashGenerator::truncated ( GridStorage storage,
level_t  level,
level_t  k 
)
inline

Generates a truncated boundary grid containing all gridpoints with li<l-k and |l|<l+(dim-1)*k.

Parameters
storageHashmap, that stores the grid points
levelmaximum level of the square root grid (non-negative value)
kthe parameter which determines the maximum level of the gridpoints for every dimension

References sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getSize(), chess::point, and trunc_rec().

Referenced by sgpp::base::GeneralizedBoundaryGridGenerator::truncated().


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