6#ifndef CHEBYSHEV_ESTIMATOR
7#define CHEBYSHEV_ESTIMATOR
13#include "../core/common.h"
14#include "../core/random.h"
29 template<
typename FloatType = real_t>
37 if(
options.domain.size() != 1) {
38 throw std::runtime_error(
39 "estimator::quadrature1D only works on mono-dimensional domains"
62 for (
unsigned int i = 1;
i <
options.iterations; ++
i) {
64 x = domain.
a +
i *
dx;
92 res.meanErr = (
sum *
dx / 3.0) / length;
93 res.rmsErr = std::sqrt((
sumSqr *
dx / 3.0) / length);
121 if(
options.domain.size() != 1) {
122 throw std::runtime_error(
123 "estimator::discrete1D only works on mono-dimensional domains"
147 maxErr = std::max(maxErr,
diff);
168 template<
typename FloatType = real_t>
179 if(
options.domain.size() != 1) {
180 throw std::runtime_error(
181 "estimator::montecarlo1D only works on mono-dimensional domains"
191 for (
int i = 0;
i <
options.iterations; ++
i) {
228 typename Vector = std::vector<FloatType>
242 throw std::runtime_error(
243 "The estimation domain's dimension does not match "
244 "the instantiated number of dimensions "
245 "in estimator::montecarlo"
261 for (
int i = 0;
i <
options.iterations; ++
i) {
long double prec_t
Floating-point type of higher precision, used in computations, such as error estimation.
Definition common.h:42
double real_t
Floating-point type, used as default for function arguments.
Definition common.h:37
auto quadrature1D()
Use Simpson's quadrature scheme to approximate error integrals for univariate real functions (endofun...
Definition estimator.h:30
auto montecarlo(std::shared_ptr< random::random_context > rnd_ctx, unsigned int dimensions)
Use crude Monte Carlo integration to approximate error integrals for multivariate real functions.
Definition estimator.h:230
auto montecarlo1D(std::shared_ptr< random::random_context > rnd_ctx)
Use crude Monte Carlo integration to approximate error integrals for univariate real functions.
Definition estimator.h:169
auto discrete1D()
Use a discrete estimator over a lattice of points, here implemented in one dimension,...
Definition estimator.h:113
General namespace of the framework.
Definition benchmark.h:22
constexpr FloatType get_nan()
Get a quiet NaN of the specified floating point type.
Definition common.h:65
std::function< Type(Type)> EndoFunction
An endofunction is a function which has the same type of input and output, such as a real function of...
Definition common.h:60
Structures for precision testing.
A structure holding the options for precision estimation.
Definition prec_structures.h:77
A structure holding the result of precision estimation.
Definition prec_structures.h:25
prec_t maxErr
Estimated maximum absolute error on interval.
Definition prec_structures.h:37
prec_t absErr
Estimated absolute error on interval.
Definition prec_structures.h:49
An interval on the real numbers.
Definition interval.h:16
real_t length() const
Returns the length of the interval.
Definition interval.h:33
double a
Lower extreme of the interval.
Definition interval.h:19
double b
Upper extreme of the interval.
Definition interval.h:22
A source of pseudorandom numbers.
Definition random.h:39
real_t uniform(real_t a, real_t b)
Generate a uniformly distributed random number.
Definition random.h:76