33 #include <boost/math/tools/polynomial.hpp> 35 namespace xerus {
namespace misc {
38 double integrate(
const std::function<
double(
double)>& _f,
double _a,
double _b,
double _eps = std::numeric_limits<double>::epsilon(),
uint _minIter = 4,
uint _maxIter = 6,
uint _branchFactor = 7,
uint _maxRecursion = 10,
bool _relativeError =
true);
40 double integrate_segmented(
const std::function<
double(
double)> &_f,
double _a,
double _b,
double _segmentation,
double _eps = 1e-8,
uint _minIter = 4,
uint _maxIter = 6,
uint _branchFactor = 8,
uint _maxRecursion = 10);
42 double find_root_bisection(
const std::function<
double(
double)> &_f,
double _min,
double _max,
double _epsilon = 1e-14);
55 std::vector<double> coefficients;
59 Polynomial(std::vector<double> _coeff);
63 Polynomial& operator+=(
const Polynomial &_rhs);
65 Polynomial& operator-=(
const Polynomial &_rhs);
67 Polynomial& operator*=(
double _rhs);
69 Polynomial& operator/=(
double _rhs);
71 Polynomial
operator*(
const Polynomial &_rhs)
const;
75 double operator()(
double x)
const;
77 double scalar_product(
const Polynomial &_rhs,
const std::function<
double (
double)> &_weight,
double _minX,
double _maxX)
const;
79 double norm(
const std::function<
double (
double)> &_weight,
double _minX,
double _maxX)
const;
82 Polynomial &orthogonolize(
const std::vector<Polynomial> &_orthoBase,
const std::function<
double (
double)> &_weight,
double _minX,
double _maxX);
85 static std::vector<Polynomial> build_orthogonal_base(
size_t _N,
const std::function<
double (
double)> &_weight,
double _minX,
double _maxX);
90 template<
class ft_type>
93 virtual void push_back(ft_type _val) = 0;
94 virtual ft_type best_estimate()
const = 0;
95 virtual ft_type error_approximate()
const = 0;
96 virtual void reset() = 0;
105 template<
class ft_type>
108 static constexpr ft_type epsilon = std::numeric_limits<ft_type>::epsilon();
112 static ft_type shanks(ft_type x1, ft_type x2, ft_type x3);
114 void push_back(ft_type _val)
override;
116 ft_type best_estimate()
const override;
118 ft_type error_approximate()
const override;
120 void reset()
override;
131 template<
class ft_type>
134 static constexpr ft_type epsilon = std::numeric_limits<ft_type>::epsilon();
138 static ft_type richard(
size_t n, ft_type x1, ft_type x2);
140 void push_back(ft_type _val)
override;
142 ft_type best_estimate()
const override;
144 ft_type error_approximate()
const override;
146 void reset()
override;
double integrate_segmented(const std::function< double(double)> &_f, double _a, double _b, double _segmentation, double _eps=1e-8, uint _minIter=4, uint _maxIter=6, uint _branchFactor=8, uint _maxRecursion=10)
The main namespace of xerus.
Tensor operator*(const value_t _factor, Tensor _tensor)
Calculates the entrywise multiplication of the Tensor _tensor with the constant _factor.
double find_root_bisection(const std::function< double(double)> &_f, double _min, double _max, double _epsilon=1e-14)
__attribute__((const)) T difference(T _a
double integrate(const std::function< double(double)> &_f, double _a, double _b, double _eps=std::numeric_limits< double >::epsilon(), uint _minIter=4, uint _maxIter=6, uint _branchFactor=7, uint _maxRecursion=10, bool _relativeError=true)
Performs a Romberg Integration (richardson extrapolation of regular riemannian sum) + adaptive refine...
Header file for global shorthand notations of elementary integer types and attribute lists...