#include <cmath>
#include <iostream>
#include <vector>
double prod = 1.0;
prod *= exp(-x[dim] * x[dim]);
}
return prod;
}
void testEfficientPCE() {
size_t d = 5;
auto functionBasis = std::make_shared<sgpp::combigrid::OrthogonalPolynomialBasis1D>(config);
for (size_t q = 2; q < 8; ++q) {
d, func);
op->getLevelManager()->addRegularLevels(q);
double mean = pce->mean();
double variance = pce->variance();
std::cout <<
"Time: " << stopwatch.
elapsedSeconds() /
static_cast<double>(op->numGridPoints())
<< std::endl;
std::cout << "---------------------------------------------------------" << std::endl;
std::cout << "#gp = " << op->getLevelManager()->numGridPoints() << std::endl;
std::cout << "E(u) = " << mean << std::endl;
std::cout << "Var(u) = " << variance << std::endl;
std::cout << "---------------------------------------------------------" << std::endl;
}
}
size_t d = 5;
auto functionBasis = std::make_shared<sgpp::combigrid::OrthogonalPolynomialBasis1D>(config);
std::vector<std::shared_ptr<sgpp::combigrid::AbstractInfiniteFunctionBasis1D>> functionBases(
d, functionBasis);
for (size_t q = 2; q < 8; ++q) {
std::vector<std::shared_ptr<sgpp::combigrid::AbstractPointHierarchy>> pointHierarchies(
std::shared_ptr<sgpp::combigrid::AbstractCombigridStorage> storage =
std::make_shared<sgpp::combigrid::CombigridTreeStorage>(pointHierarchies, true, func);
auto levelManager = std::make_shared<sgpp::combigrid::AveragingLevelManager>();
auto op = std::make_shared<sgpp::combigrid::CombigridTensorOperation>(
pointHierarchies, tensorEvaluators, levelManager, storage, summationType);
levelManager->addRegularLevels(q);
auto result = op->getResult();
std::cout << "Time: "
<< stopwatch.elapsedSeconds() / static_cast<double>(levelManager->numGridPoints())
<< std::endl;
std::cout << "---------------------------------------------------------" << std::endl;
std::cout << "#gp = " << levelManager->numGridPoints() << std::endl;
std::cout <<
"Var(u) = " <<
std::pow(result.norm(), 2) <<
"\n";
std::cout << "---------------------------------------------------------" << std::endl;
}
}
void oldSpeedtest() {
size_t dim = 6;
auto op =
{
op->evaluate(10, parameter);
std::cout << "Number of grid points: " << op->numGridPoints() << "\n";
}
{
for (
size_t i = 0;
i < 10; ++
i) {
op->evaluate(10, parameter);
}
std::cout << "Number of grid points: " << op->numGridPoints() << "\n";
}
}
return 0;
}