SG++

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<lk and l<l+(dim1)*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 \((d1)\)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...  
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:
Furthermore, the creation of full grids (in the hierarchical basis) is supported.

inlineprotected 
recursive construction of the spare grid with boundaries, classic level 0 approach, only for level 0 and 1
storage  hashmap that stores the grid points 
index  point's index 
current_dim  current working dimension 
current_level  current level in this construction step 
level  maximum 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().

inlineprotected 
recursive construction of the spare grid without boundaries
storage  hashmap that stores the grid points 
index  point's index 
current_dim  current working dimension 
current_level  current level in this construction step 
level  maximum level of the sparse grid generate points of the last dimension (dim == 0), without boundaries 
storage  the hashmap that stores the grid points 
index  point's index that should be created on the grid 
current_level  current level of the grid generation 
level  maximum level of grid recursive construction of the spare grid with boundaries, pentagon cut 
storage  hashmap that stores the grid points 
index  point's index 
current_dim  current working dimension 
current_level  current level in this construction step 
level  maximum level of the sparse grid 
bLevelZero  specifies 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().

inlineprotected 
generate points of the last dimension (dim == 0), version of pentagon cut in sub space scheme
storage  the hashmap that stores the grid points 
index  point's index that should be created on the grid 
current_level  current level of the grid generation 
level  maximum level of grid 
bLevelZero  specifies if the current index has a level zero component 
References sgpp::base::HashGridStorage::insert(), and sgpp::base::HashGridPoint::push().
Referenced by boundaries_truncated_rec().

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.
storage  Hashmap that stores the grid points 
level  Grid level (nonnegative value) 
clique_size  number of dimensions in a clique 
T  modifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensorproduct approximation spaces 
References cliques_iter(), sgpp::base::HashGridStorage::getDimension(), and sgpp::base::HashGridStorage::getSize().
Referenced by sgpp::base::PeriodicGridGenerator::cliques(), sgpp::base::StandardGridGenerator::cliques(), and sgpp::base::PrewaveletGridGenerator::cliques().

inlineprotected 
References g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridPoint::getLevelSum(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridStorage::update().
Referenced by cliques().

inlineprotected 
Generate a full grid iteratively (much faster than recursively) without grid points on the boundary.
storage  Pointer to the storage object into which the grid points should be stored 
n  Level of full grid 
References g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridStorage::update().
Referenced by full().

inlineprotected 
Generate a full grid iteratively (much faster than recursively) with truncated boundary.
storage  Pointer to the storage object into which the grid points should be stored 
n  Level of full grid 
References g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridStorage::update().
Referenced by fullWithBoundary().

inlineprotected 
References sgpp::base::DataVector::getSize().
Referenced by regular_inter_iter().

inline 
Generates a full grid of level level
, without boundaries.
storage  Hashmap that stores the grid points 
level  Grid level (nonnegative value) 
References createFullGridIterative(), and sgpp::base::HashGridStorage::getSize().
Referenced by sgpp::base::StandardGridGenerator::full(), and sgpp::base::PrewaveletGridGenerator::full().

inline 
Generates a full grid of level level
, with boundary grid points.
storage  Hashmap that stores the grid points 
level  Grid level (nonnegative value) 
References createFullGridTruncatedIterative(), and sgpp::base::HashGridStorage::getSize().
Referenced by sgpp::base::StretchedBoundaryGridGenerator::full(), sgpp::base::L0BoundaryGridGenerator::full(), and sgpp::base::BoundaryGridGenerator::full().

inline 
Generates a regular sparse grid of level levels, without boundaries.
storage  Hashmap that stores the grid points 
level  Grid level (nonnegative value) 
T  modifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensorproduct approximation spaces. The effect of T can be seen in: 
References sgpp::base::HashGridStorage::getSize(), and regular_iter().
Referenced by sgpp::base::StandardGridGenerator::regular(), and sgpp::base::PrewaveletGridGenerator::regular().

inlineprotected 
Generate a regular sparse grid iteratively (much faster than recursively) with truncated boundary, i.e., the sparse grid on the \((d1)\)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
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 higherdimensional 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.
storage  pointer to storage object into which the grid points should be stored 
n  level of regular sparse grid 
boundaryLevel  1 + how much levels the boundary is coarser than the main axes, 1 means same level, 2 means one level coarser, etc.; must be >= 1 
T  modifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensorproduct approximation spaces 
References g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), analyse_erg::tmp, and sgpp::base::HashGridStorage::update().
Referenced by regularWithBoundaries().

inline 
References sgpp::base::HashGridStorage::getSize(), and regular_inter_iter().
Referenced by regularInter().

inlineprotected 
References decodeCoords(), g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridPoint::getLevelSum(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridStorage::update().
Referenced by regular_inter().

inlineprotected 
Generate a regular sparse grid iteratively (much faster than recursively) without grid points on the boundary.
storage  pointer to storage object into which the grid points should be stored 
n  level of regular sparse grid 
T  modifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensorproduct approximation spaces 
References g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridPoint::getLevelSum(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridStorage::update().
Referenced by regular().

inlineprotected 
Generate a regular sparse grid iteratively (much faster than recursively) with periodic boundary.
storage  Pointer to storage object into which the grid points should be stored 
n  Level of regular sparse grid 
T  modifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensorproduct approximation spaces 
References g, sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridPoint::getLevelSum(), sgpp::base::HashGridStorage::getPoint(), sgpp::base::HashGridStorage::getSize(), sgpp::base::HashGridStorage::insert(), sgpp::base::HashGridPoint::push(), and sgpp::base::HashGridStorage::update().
Referenced by regularWithPeriodicBoundaries().

inline 
Generates a regular sparse grid of level level, without boundaries.
The resulting grid only contains interactions that are in the vector terms.
storage  Hashmap that stores the grid points 
level  Grid level (nonnegative value) 
terms  controls 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. 
T  modifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensorproduct approximation spaces. 
References sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getSize(), and regular_inter().
Referenced by sgpp::base::StandardGridGenerator::regularInter().

inline 
Generates a regular sparse grid of level levels with boundaries.
storage  Hashmap, that stores the grid points 
level  maximum level of the sparse grid (nonnegative value) 
boundaryLevel  level at which the boundary points should be inserted 
References boundaries_rec(), sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getSize(), level, and regular_boundary_truncated_iter().
Referenced by sgpp::base::StretchedBoundaryGridGenerator::regular(), sgpp::base::L0BoundaryGridGenerator::regular(), and sgpp::base::BoundaryGridGenerator::regular().

inline 
Generates a regular sparse grid of level levels with boundaries.
storage  Hashmap, that stores the grid points 
level  maximum level of the sparse grid (nonnegative value) 
T  modifier for subgrid selection, T = 0 implies standard sparse grid. For further information see Griebel and Knapek's paper optimized tensorproduct approximation spaces 
References sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getSize(), and regular_periodic_boundary_iter().
Referenced by sgpp::base::PeriodicGridGenerator::regular().

inlineprotected 
recursive construction of a square root grid with boundaries
storage  hashmap that stores the grid points 
index  point's index 
current_dim  current working dimension 
level  maximum level of the square root grid 
small_level  level of coarsest descretization 
tail  true if there is a level of the index>level/2 
sum  sum 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*(dim1)+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().

inline 
Generates a regular square root grid of level level with boundaries.
storage  Hashmap, that stores the grid points 
level  maximum level of the square root grid (nonnegative 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, sgpp::base::HashGridPoint::push(), and square_rec().
Referenced by sgpp::base::SquareRootGridGenerator::regular().

inlineprotected 
recursive construction of a super truncated grid with boundaries
storage  hashmap that stores the grid points 
index  point's index 
current_dim  current working dimension 
current_level  the current level of the gridpoint so far, starts from minlevel*dim 
level  the maximum level of the gridpoint 
minlevel  the 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().

inline 
Generates a truncated boundary grid containing all gridpoints with li<lk and l<l+(dim1)*k.
storage  Hashmap, that stores the grid points 
level  maximum level of the square root grid (nonnegative value) 
k  the parameter which determines the maximum level of the gridpoints for every dimension 
References sgpp::base::HashGridStorage::getDimension(), sgpp::base::HashGridStorage::getSize(), sgpp::base::HashGridPoint::push(), and trunc_rec().
Referenced by sgpp::base::GeneralizedBoundaryGridGenerator::truncated().