SG++-Doxygen-Documentation
Loading...
Searching...
No Matches
sgpp::combigrid::IndexVectorRange Class Reference

Class for iterating over the indices contained in a FullGrid via ranged-based for loops. More...

#include <IndexVectorRange.hpp>

Public Member Functions

IndexVectorIterator begin () const
 Returns the beginning of the range, i.e., the IndexVectorIterator that corresponds to the minimum index.
 
IndexVectorIterator end () const
 Returns the end of the range, i.e., the IndexVectorIterator that corresponds to the maximum index.
 
size_t find (const IndexVector &index) const
 Finds the given index in the range and returns it position.
 
void getIndices (std::vector< IndexVector > &indices) const
 Converts this range to a vector of indices, which will contain all indices that are within this range.
 
 IndexVectorRange ()
 Default constructor, corresponds to the zero-dimensional case.
 
 IndexVectorRange (const FullGrid &grid)
 Constructor for FullGrid instances.
 
 IndexVectorRange (const IndexVector &minIndex, const IndexVector &maxIndex)
 Constructor for custom-defined minimum and maximum indices.
 
void setGrid (const FullGrid &grid)
 Sets minimum and maximum index of the range to that of the given FullGrid.
 

Static Public Member Functions

static void getPoints (const FullGrid &grid, base::DataMatrix &points)
 Save all grid points of a FullGrid in a DataMatrix.
 

Protected Attributes

size_t dim
 dimensionality
 
IndexVector maxIndex
 vector of maximum 1D indices
 
IndexVector minIndex
 vector of minimum 1D indices
 
IndexVector numberOfIndexVectors
 number of indices in 1D for all dimensions
 
size_t totalNumberOfIndexVectors
 total number of indices
 

Detailed Description

Class for iterating over the indices contained in a FullGrid via ranged-based for loops.

This is basically equivalent to NumPy's and MATLAB's meshgrid function, as it loops over the Cartesian product of the sets of 1D indices.

The order is as follows: \((0, 0, 0, \dotsc, 0)\), \((1, 0, 0, \dotsc, 0)\), ..., \((n_1, 0, 0, \dotsc, 0)\), \((0, 1, 0, \dotsc, 0)\), ..., \((1, 1, 0, \dotsc, 0)\), ..., \((n_1, 1, 0, \dotsc, 0)\), ..., \((n_1, n_2, 0, \dotsc, 0)\), etc. (i.e., like enumerating indices of a matrix in column-major order).

Constructor & Destructor Documentation

◆ IndexVectorRange() [1/3]

sgpp::combigrid::IndexVectorRange::IndexVectorRange ( )
inline

Default constructor, corresponds to the zero-dimensional case.

◆ IndexVectorRange() [2/3]

sgpp::combigrid::IndexVectorRange::IndexVectorRange ( const FullGrid grid)
inlineexplicit

Constructor for FullGrid instances.

Parameters
gridfull grid

References grid(), setGrid(), and sgpp::combigrid::FullGrid::TwoToThePowerOfL.

◆ IndexVectorRange() [3/3]

sgpp::combigrid::IndexVectorRange::IndexVectorRange ( const IndexVector minIndex,
const IndexVector maxIndex 
)
inline

Constructor for custom-defined minimum and maximum indices.

Parameters
minIndexvector of minimum 1D indices
maxIndexvector of maximum 1D indices

References dim, maxIndex, minIndex, numberOfIndexVectors, and totalNumberOfIndexVectors.

Member Function Documentation

◆ begin()

IndexVectorIterator sgpp::combigrid::IndexVectorRange::begin ( ) const
inline

Returns the beginning of the range, i.e., the IndexVectorIterator that corresponds to the minimum index.

Returns
iterator that corresponds to the minimum index

References maxIndex, and minIndex.

Referenced by getIndices().

◆ end()

IndexVectorIterator sgpp::combigrid::IndexVectorRange::end ( ) const
inline

Returns the end of the range, i.e., the IndexVectorIterator that corresponds to the maximum index.

Returns
iterator that corresponds to the maximum index

References maxIndex, minIndex, sgpp::combigrid::IndexVectorIterator::setSequenceNumber(), and totalNumberOfIndexVectors.

Referenced by getIndices().

◆ find()

size_t sgpp::combigrid::IndexVectorRange::find ( const IndexVector index) const
inline

Finds the given index in the range and returns it position.

Only returns reasonable values if the index is actually in the range.

Parameters
indexindex to find
Returns
sequence number in the range

References dim, minIndex, and numberOfIndexVectors.

Referenced by sgpp::combigrid::OperationUPFullGrid::apply(), sgpp::combigrid::CombinationGrid::combineSparseGridValues(), sgpp::combigrid::CombinationGrid::combineSparseGridValues(), sgpp::combigrid::CombinationGrid::distributeValuesToFullGrid(), and sgpp::combigrid::CombinationGrid::distributeValuesToFullGrids().

◆ getIndices()

void sgpp::combigrid::IndexVectorRange::getIndices ( std::vector< IndexVector > &  indices) const
inline

Converts this range to a vector of indices, which will contain all indices that are within this range.

Parameters
[out]indicesvector of indices (contents will be overwritten)

References begin(), and end().

◆ getPoints()

static void sgpp::combigrid::IndexVectorRange::getPoints ( const FullGrid grid,
base::DataMatrix points 
)
inlinestatic

◆ setGrid()

Member Data Documentation

◆ dim

◆ maxIndex

IndexVector sgpp::combigrid::IndexVectorRange::maxIndex
protected

vector of maximum 1D indices

Referenced by begin(), end(), IndexVectorRange(), and setGrid().

◆ minIndex

IndexVector sgpp::combigrid::IndexVectorRange::minIndex
protected

vector of minimum 1D indices

Referenced by begin(), end(), find(), IndexVectorRange(), and setGrid().

◆ numberOfIndexVectors

IndexVector sgpp::combigrid::IndexVectorRange::numberOfIndexVectors
protected

number of indices in 1D for all dimensions

Referenced by find(), IndexVectorRange(), and setGrid().

◆ totalNumberOfIndexVectors

size_t sgpp::combigrid::IndexVectorRange::totalNumberOfIndexVectors
protected

total number of indices

Referenced by end(), getPoints(), IndexVectorRange(), and setGrid().


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