本文整理汇总了C++中GridStorage::end方法的典型用法代码示例。如果您正苦于以下问题:C++ GridStorage::end方法的具体用法?C++ GridStorage::end怎么用?C++ GridStorage::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridStorage
的用法示例。
在下文中一共展示了GridStorage::end方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sweep_rec
/**
* Descends on all dimensions beside dim_sweep. Class functor for dim_sweep.
* Boundaries are not regarded
*
* @param source coefficients of the sparse grid
* @param result coefficients of the function computed by sweep
* @param index current grid position
* @param dim_list list of dimensions, that should be handled
* @param dim_rem number of remaining dims
* @param dim_sweep static dimension, in this dimension the functor is executed
*/
void sweep_rec(DataMatrix& source, DataMatrix& result, grid_iterator& index,
std::vector<size_t>& dim_list, size_t dim_rem,
size_t dim_sweep) {
functor(source, result, index, dim_sweep);
// dimension recursion unrolled
for (size_t d = 0; d < dim_rem; d++) {
size_t current_dim = dim_list[d];
if (index.hint()) {
continue;
}
index.leftChild(current_dim);
if (!storage->end(index.seq())) {
sweep_rec(source, result, index, dim_list, d + 1, dim_sweep);
}
index.stepRight(current_dim);
if (!storage->end(index.seq())) {
sweep_rec(source, result, index, dim_list, d + 1, dim_sweep);
}
index.up(current_dim);
}
}
示例2: sweep_Boundary_rec
/**
* Descends on all dimensions beside dim_sweep. Class functor for dim_sweep.
* Boundaries are regarded
*
* @param source coefficients of the sparse grid
* @param result coefficients of the function computed by sweep
* @param index current grid position
* @param dim_list list of dimensions, that should be handled
* @param dim_rem number of remaining dims
* @param dim_sweep static dimension, in this dimension the functor is executed
*/
void sweep_Boundary_rec(DataMatrix& source, DataMatrix& result,
grid_iterator& index,
std::vector<size_t>& dim_list, size_t dim_rem,
size_t dim_sweep) {
if (dim_rem == 0) {
functor(source, result, index, dim_sweep);
} else {
typedef GridStorage::index_type::level_type level_type;
typedef GridStorage::index_type::index_type index_type;
level_type current_level;
index_type current_index;
index.get(dim_list[dim_rem - 1], current_level, current_index);
// handle level greater zero
if (current_level > 0) {
// given current point to next dim
sweep_Boundary_rec(source, result, index, dim_list, dim_rem - 1,
dim_sweep);
if (!index.hint()) {
index.leftChild(dim_list[dim_rem - 1]);
if (!storage->end(index.seq())) {
sweep_Boundary_rec(source, result, index, dim_list, dim_rem,
dim_sweep);
}
index.stepRight(dim_list[dim_rem - 1]);
if (!storage->end(index.seq())) {
sweep_Boundary_rec(source, result, index, dim_list, dim_rem,
dim_sweep);
}
index.up(dim_list[dim_rem - 1]);
}
} else { // handle level zero
sweep_Boundary_rec(source, result, index, dim_list, dim_rem - 1,
dim_sweep);
index.resetToRightLevelZero(dim_list[dim_rem - 1]);
sweep_Boundary_rec(source, result, index, dim_list, dim_rem - 1,
dim_sweep);
if (!index.hint()) {
index.resetToLevelOne(dim_list[dim_rem - 1]);
if (!storage->end(index.seq())) {
sweep_Boundary_rec(source, result, index, dim_list, dim_rem,
dim_sweep);
}
}
index.resetToLeftLevelZero(dim_list[dim_rem - 1]);
}
}
}
示例3: rec
/**
* Recursive traversal of the "tree" of basis functions for evaluation, used in operator().
* For a given evaluation point \f$x\f$, it stores tuples (std::pair) of
* \f$(i,\phi_i(x))\f$ in the result vector for all basis functions that are non-zero.
*
* @param basis a sparse grid basis
* @param point evaluation point within the domain
* @param current_dim the dimension currently looked at (recursion parameter)
* @param value the value of the evaluation of the current basis function up to (excluding) dimension current_dim (product of the evaluations of the one-dimensional ones)
* @param working iterator working on the GridStorage of the basis
* @param source array of indices for each dimension (identifying the indices of the current grid point)
* @param alpha the spars grid's ansatzfunctions coefficients
* @param result reference to a float_t into which the result should be stored
*/
void rec(BASIS& basis, const DataVector& point, size_t current_dim,
float_t value, GridStorage::grid_iterator& working,
GridStorage::index_type::index_type* source, const DataVector& alpha,
float_t& result) {
typedef GridStorage::index_type::level_type level_type;
typedef GridStorage::index_type::index_type index_type;
const unsigned int BITS_IN_BYTE = 8;
// maximum possible level for the index type
const level_type max_level = static_cast<level_type> (
sizeof(index_type) * BITS_IN_BYTE - 1);
index_type src_index = source[current_dim];
level_type work_level = 1;
while (true) {
size_t seq = working.seq();
if (storage->end(seq)) {
break;
} else {
index_type work_index;
level_type temp;
working.get(current_dim, temp, work_index);
float_t new_value = basis.eval(work_level, work_index,
point[current_dim]);
new_value *= value;
if (current_dim == storage->dim() - 1) {
result += (alpha[seq] * new_value);
} else {
rec(basis, point, current_dim + 1, new_value,
working, source, alpha, result);
}
}
if (working.hint()) {
break;
}
// this decides in which direction we should descend by evaluating
// the corresponding bit
// the bits are coded from left to right starting with level 1
// being in position max_level
bool right = (src_index & (1 << (max_level - work_level))) > 0;
++work_level;
if (right) {
working.rightChild(current_dim);
} else {
working.leftChild(current_dim);
}
}
working.resetToLevelOne(current_dim);
}
示例4: end
virtual typename GridStorageAccessInterface<TBASE>::const_iterator end() const
{
return ConstAccessIteratorImpl<T, TBASE, std::vector<T> >(storage->end());
}