Doxygen
1.9.1
|
Files | |
file | tsgIndexManipulator.hpp |
Algorithms for manipulating sets of multi-indexes. | |
Classes | |
struct | TasGrid::MultiIndexManipulations::ProperWeights |
Holds anisotropic weights in a usable format. More... | |
Functions | |
MultiIndexSet | TasGrid::MultiIndexManipulations::generateFullTensorSet (std::vector< int > const &num_entries) |
Create a full-tensor multi-index set with num_entries in each direction. More... | |
MultiIndexSet | TasGrid::MultiIndexManipulations::generateLowerMultiIndexSet (size_t num_dimensions, std::function< bool(const std::vector< int > &index)> inside) |
Generate the multi-index with entries satisfying the inside(), assumes that inside() defines a lower-complete set. . More... | |
void | TasGrid::MultiIndexManipulations::completeSetToLower (MultiIndexSet &set) |
Expand the set with the minimum number of multi-indexes that will result in a lower complete set. . More... | |
std::vector< int > | TasGrid::MultiIndexManipulations::computeLevels (MultiIndexSet const &mset) |
Returns a vector that is the sum of entries of each multi-index in the set. More... | |
std::vector< int > | TasGrid::MultiIndexManipulations::getMaxIndexes (const MultiIndexSet &mset) |
Returns a vector with the maximum index in each dimension. More... | |
Data2D< int > | TasGrid::MultiIndexManipulations::computeDAGup (MultiIndexSet const &mset) |
Returns a Data2D structure where each strip holds the slot-index of the parents of indexes in mset (for each direction), using one-point-growth hierarchy. More... | |
MultiIndexSet | TasGrid::MultiIndexManipulations::selectFlaggedChildren (const MultiIndexSet &mset, const std::vector< bool > &flagged, const std::vector< int > &level_limits) |
Using the flagged map, create a set with the flagged children of mset but only if they obey the level_limits. More... | |
MultiIndexSet | TasGrid::MultiIndexManipulations::generateNestedPoints (const MultiIndexSet &tensors, std::function< int(int)> getNumPoints) |
Converts a set of nested tensors to the actual points, where each level has getNumPoints() in each direction. More... | |
MultiIndexSet | TasGrid::MultiIndexManipulations::generateNonNestedPoints (const MultiIndexSet &tensors, const OneDimensionalWrapper &wrapper) |
Converts a set of non-nested active tensors to the actual points, the wrapper gives mapping between level and point indexes. More... | |
void | TasGrid::MultiIndexManipulations::resortIndexes (const MultiIndexSet &iset, std::vector< std::vector< int >> &map, std::vector< std::vector< int >> &lines1d) |
Creates a map with sorted indexes dimension by dimension. More... | |
template<bool nested> | |
std::vector< int > | TasGrid::MultiIndexManipulations::referencePoints (const int levels[], const OneDimensionalWrapper &wrapper, const MultiIndexSet &points) |
Find the indexes of all points associated with the tensor with levels within the global points set. More... | |
std::vector< int > | TasGrid::MultiIndexManipulations::computeTensorWeights (MultiIndexSet const &mset) |
Computes the weights for the tensor linear combination, mset must be a lower complete set. More... | |
MultiIndexSet | TasGrid::MultiIndexManipulations::createActiveTensors (const MultiIndexSet &mset, const std::vector< int > &weights) |
Creates a set containing only the entries of mset that have non-zero weights. More... | |
void | TasGrid::MultiIndexManipulations::computeActiveTensorsWeights (MultiIndexSet const &tensors, MultiIndexSet &active_tensors, std::vector< int > &active_w) |
Uses the computeTensorWeights() and createActiveTensors() to extract the active tensors and the active (non-zero) weights. | |
MultiIndexSet | TasGrid::MultiIndexManipulations::createPolynomialSpace (const MultiIndexSet &tensors, std::function< int(int)> exactness) |
For a set of tensors compute the corresponding polynomial space assuming the 1D rules have given exactness(). More... | |
bool | TasGrid::MultiIndexManipulations::isLowerComplete (std::vector< int > const &point, MultiIndexSet const &mset, std::vector< int > &scratch) |
Assuming that mset is lower complete, return true if adding the point will preserve completeness. More... | |
MultiIndexSet | TasGrid::MultiIndexManipulations::getLargestCompletion (MultiIndexSet const ¤t, MultiIndexSet const &candidates) |
Return the largest subset of candidates such that adding it to current will preserve lower completeness. More... | |
template<bool limited> | |
MultiIndexSet | TasGrid::MultiIndexManipulations::addExclusiveChildren (const MultiIndexSet &tensors, const MultiIndexSet &exclude, const std::vector< int > level_limits) |
For a set of tensors create an mset that contain the children of indexes in tensors that are missing from exclude and obey the level_limits. More... | |
template<class IndexList , class RuleLike , class OutputIteratorLike > | |
OutputIteratorLike | TasGrid::MultiIndexManipulations::indexesToNodes (IndexList const &list, RuleLike const &rule, OutputIteratorLike nodes) |
Converts int-indexes to double-valued abscissas using the provided rule. More... | |
template<class IteratorLike , class RuleLike , class OutputIteratorLike > | |
OutputIteratorLike | TasGrid::MultiIndexManipulations::indexesToNodes (IteratorLike ibegin, size_t num_entries, RuleLike const &rule, OutputIteratorLike nodes) |
Overload that uses a begin and a number of entries. | |
template<class IndexList , class RuleLike > | |
std::vector< double > | TasGrid::MultiIndexManipulations::getIndexesToNodes (IndexList const &list, RuleLike const &rule) |
Overload that returns the result in a vector. | |
template<class IteratorLike , class RuleLike > | |
std::vector< double > | TasGrid::MultiIndexManipulations::getIndexesToNodes (IteratorLike ibegin, size_t num_entries, RuleLike const &rule) |
Overload that returns the result in a vector. | |
std::vector< int > | TasGrid::MultiIndexManipulations::inferAnisotropicWeights (AccelerationContext const *acceleration, TypeOneDRule rule, TypeDepth depth, MultiIndexSet const &points, std::vector< double > const &coefficients, double tol) |
Overload that returns the result in a vector. More... | |
template<bool use_parents_direction> | |
void | TasGrid::MultiIndexManipulations::repeatAddIndexes (std::function< bool(const std::vector< int > &index)> inside, std::vector< MultiIndexSet > &level_sets) |
Generate a series of level_sets where each set has the parents/children of the previous one that satisfy the inside() criteria. More... | |
MultiIndexSet | TasGrid::MultiIndexManipulations::unionSets (std::vector< MultiIndexSet > &level_sets) |
Retuns the union of all level_sets, all sets are destroyed in the process. More... | |
MultiIndexSet | TasGrid::MultiIndexManipulations::generateGeneralMultiIndexSet (size_t num_dimensions, std::function< bool(const std::vector< int > &index)> criteria) |
Generate the minimum lower complete multi-index set that includes the indexes satisfying criteria(), assumes criteria() defines a connected set. More... | |
template<bool check_limits> | |
MultiIndexSet | TasGrid::MultiIndexManipulations::selectGeneralSet (ProperWeights const &weights, std::function< int(int i)> rule_exactness, int normalized_offset, std::vector< int > const &level_limits) |
Generates the minimum lower complete set that contains all indexes with weights less than normalized_offset. More... | |
|
inline |
Create a full-tensor multi-index set with num_entries in each direction.
|
inline |
Generate the multi-index with entries satisfying the inside(), assumes that inside() defines a lower-complete set. .
void TasGrid::MultiIndexManipulations::completeSetToLower | ( | MultiIndexSet & | set | ) |
Expand the set with the minimum number of multi-indexes that will result in a lower complete set. .
std::vector< int > TasGrid::MultiIndexManipulations::computeLevels | ( | MultiIndexSet const & | mset | ) |
Returns a vector that is the sum of entries of each multi-index in the set.
std::vector< int > TasGrid::MultiIndexManipulations::getMaxIndexes | ( | const MultiIndexSet & | mset | ) |
Returns a vector with the maximum index in each dimension.
Data2D< int > TasGrid::MultiIndexManipulations::computeDAGup | ( | MultiIndexSet const & | mset | ) |
Returns a Data2D structure where each strip holds the slot-index of the parents of indexes in mset (for each direction), using one-point-growth hierarchy.
Adds -1 in places where the parents are missing.
MultiIndexSet TasGrid::MultiIndexManipulations::selectFlaggedChildren | ( | const MultiIndexSet & | mset, |
const std::vector< bool > & | flagged, | ||
const std::vector< int > & | level_limits | ||
) |
Using the flagged map, create a set with the flagged children of mset but only if they obey the level_limits.
MultiIndexSet TasGrid::MultiIndexManipulations::generateNestedPoints | ( | const MultiIndexSet & | tensors, |
std::function< int(int)> | getNumPoints | ||
) |
Converts a set of nested tensors to the actual points, where each level has getNumPoints() in each direction.
Working with nested points, it is more efficient to interpret the tensors as a surplus operators and generate only the surplus points; then take the union without repeated indexes. This can work if and only if tensors is a lower-complete set, i.e., the tensors in GridGlobal and not the active_tensors.
MultiIndexSet TasGrid::MultiIndexManipulations::generateNonNestedPoints | ( | const MultiIndexSet & | tensors, |
const OneDimensionalWrapper & | wrapper | ||
) |
Converts a set of non-nested active tensors to the actual points, the wrapper gives mapping between level and point indexes.
For each index in tensor, generate a local set of points and then remap them to the global index using the wrapper.getPointIndex().
void TasGrid::MultiIndexManipulations::resortIndexes | ( | const MultiIndexSet & | iset, |
std::vector< std::vector< int >> & | map, | ||
std::vector< std::vector< int >> & | lines1d | ||
) |
Creates a map with sorted indexes dimension by dimension.
iset | is a non-empty set of indexes |
map | (output) the i-th index in the order with d as the fastest changing (contiguous) dimension is map[d][i] |
lines1d | for each dimension d the indexes that match in all but d-dimension will be between lines1d[d][i] and lines1d[d][i+1] (not including the last entry) This is similar to the pntr index of row-compressed sparse matrix |
std::vector<int> TasGrid::MultiIndexManipulations::referencePoints | ( | const int | levels[], |
const OneDimensionalWrapper & | wrapper, | ||
const MultiIndexSet & | points | ||
) |
Find the indexes of all points associated with the tensor with levels within the global points set.
The order in which the tensors are formed here must match the order in which they will be used, e.g., when computing interpolation and quadrature weights.
std::vector< int > TasGrid::MultiIndexManipulations::computeTensorWeights | ( | MultiIndexSet const & | mset | ) |
Computes the weights for the tensor linear combination, mset must be a lower complete set.
|
inline |
Creates a set containing only the entries of mset that have non-zero weights.
MultiIndexSet TasGrid::MultiIndexManipulations::createPolynomialSpace | ( | const MultiIndexSet & | tensors, |
std::function< int(int)> | exactness | ||
) |
For a set of tensors compute the corresponding polynomial space assuming the 1D rules have given exactness().
|
inline |
Assuming that mset is lower complete, return true if adding the point will preserve completeness.
point | is the new point to add to an existing set |
mset | is an existing lower complete set |
scratch | is scratch space, must have size equal to point.size() and will be used for temporary storage the scratch reduces allocations |
|
inline |
Return the largest subset of candidates such that adding it to current will preserve lower completeness.
MultiIndexSet TasGrid::MultiIndexManipulations::addExclusiveChildren | ( | const MultiIndexSet & | tensors, |
const MultiIndexSet & | exclude, | ||
const std::vector< int > | level_limits | ||
) |
For a set of tensors create an mset that contain the children of indexes in tensors that are missing from exclude and obey the level_limits.
If limited is false, then the level_limits are ignored.
OutputIteratorLike TasGrid::MultiIndexManipulations::indexesToNodes | ( | IndexList const & | list, |
RuleLike const & | rule, | ||
OutputIteratorLike | nodes | ||
) |
Converts int-indexes to double-valued abscissas using the provided rule.
Nodes of the sparse grid are stored as multi-indexes in either vectors or MultiIndexSet classes. The nodes are converted to double precision numbers according to a specified one-dimensional rule.
IndexList | is either a MultiIndexSet or a std::vector<int>, both of which have a begin and end methods, the begin and end must allow iteration over a range of integers. |
RuleLike | is either a OneDimensionalWrapper, derived from BaseRuleLocalPolynomial, or RuleWavelet, or any other class with getNode method that converts an int to a double; GridSequence class provides the getNode() method too. |
OutputIteratorLike | indicates where the write the output, e.g., an iterator or an array, the output matches with OutputIteratorLike as defined by std::transform. |
list | defines a range of integers to be converted to double precision numbers. |
rule | is a class with getNode method that defines the conversion. |
nodes | marks the beginning of the output range. |
Overloads are provided that work with an ibegin iterator and a number of entries in place of the list, as well as returning the result in a std::vector<double> as opposed to writing to a nodes iterator. See the brief descriptions at the top of the page.
std::vector< int > TasGrid::MultiIndexManipulations::inferAnisotropicWeights | ( | AccelerationContext const * | acceleration, |
TypeOneDRule | rule, | ||
TypeDepth | depth, | ||
MultiIndexSet const & | points, | ||
std::vector< double > const & | coefficients, | ||
double | tol | ||
) |
Overload that returns the result in a vector.
Infers the weights that best describe the decay-rate of the normalized coefficients given the rule and depth. The points represent either the polynomial powers of the frequencies of the Fourier transform and tol is the cutoff tolerance, i.e., use only the coefficients with magnitude exceeding tol.
void TasGrid::MultiIndexManipulations::repeatAddIndexes | ( | std::function< bool(const std::vector< int > &index)> | inside, |
std::vector< MultiIndexSet > & | level_sets | ||
) |
Generate a series of level_sets where each set has the parents/children of the previous one that satisfy the inside() criteria.
On entry, level_sets must constain at least one set. The function takes the last set in level_sets and adds a new set of eithe the parents or children that also satisfy the inside() condition. The process is repeated until the new set is empty.
|
inline |
Retuns the union of all level_sets, all sets are destroyed in the process.
|
inline |
Generate the minimum lower complete multi-index set that includes the indexes satisfying criteria(), assumes criteria() defines a connected set.
MultiIndexSet TasGrid::MultiIndexManipulations::selectGeneralSet | ( | ProperWeights const & | weights, |
std::function< int(int i)> | rule_exactness, | ||
int | normalized_offset, | ||
std::vector< int > const & | level_limits | ||
) |
Generates the minimum lower complete set that contains all indexes with weights less than normalized_offset.
The weight of an index uses the weights combined with the rule_exactness(). Called only for contour type_curved and caches values on-the-fly.
If check_limits is false, then level_limits are ignored for speedup.