本文整理匯總了C++中Interval::maxima方法的典型用法代碼示例。如果您正苦於以下問題:C++ Interval::maxima方法的具體用法?C++ Interval::maxima怎麽用?C++ Interval::maxima使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Interval
的用法示例。
在下文中一共展示了Interval::maxima方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: makeBoxAround
BoxT
makeBoxAround(
const Interval<DIM, T>& interval) const
{
Vector<DIM, T> lower = interval.minima();
Vector<DIM, T> upper = interval.maxima();
return makeBoxAround(lower, upper);
}
示例2: integral
virtual
T
value(const Interval<DIM, T>& interval,
const uint order) override
{
const uint numberOfQuadraturePoints = order + 1;
calculateNewNodesAndWeightsIfNecessary(order);
const auto index = indexFromOrder(order);
auto nodes =
mPreviouslyCalculatedUnscaledNodes[index];
auto weights =
mPreviouslyCalculatedUnscaledWeights[index];
assert(numberOfQuadraturePoints == nodes.size());
assert(weights.size() == nodes.size());
std::array<std::vector<T>, DIM> arrayOfNodes, arrayOfWeights;
arrayOfNodes.fill(nodes);
arrayOfWeights.fill(weights);
const auto minima = interval.minima();
const auto maxima = interval.maxima();
GaussLegendreOps<DIM, T>::scaleNodes(minima, maxima, arrayOfNodes);
GaussLegendreOps<DIM, T>::scaleWeights(minima, maxima, arrayOfWeights);
const auto allIndices = this->calculateAllIndicies(
numberOfQuadraturePoints);
T integral(0.0);
for (auto indices : allIndices) {
std::array<T, DIM> weights, nodes;
for (uint i = 0; i < DIM; ++i) {
assert(i < indices.size());
assert(indices[i] < numberOfQuadraturePoints);
weights[i] = arrayOfWeights[i][indices[i]];
nodes[i] = arrayOfNodes[i][indices[i]];
}
Vector<DIM, T> location(nodes);
assert(interval.isInside(location));
const auto weight = ContainerUtilities::product<DIM, T>(
weights);
integral += weight * mFunc(location);
}
return integral;
}