limes 3.1.0
Composable Calculus Expressions for C++20
Loading...
Searching...
No Matches
methods.hpp File Reference

Integration method objects for composable numerical integration. More...

#include <cstddef>
#include <optional>
#include <random>
#include <functional>
#include "concepts.hpp"
#include "../algorithms/integrators/integrators.hpp"
#include "../algorithms/quadrature/quadrature.hpp"
+ Include dependency graph for methods.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  limes::methods::gauss_legendre< N, T >
 N-point Gauss-Legendre quadrature, achieving degree 2N-1 polynomial exactness. More...
 
struct  limes::methods::is_integration_method< gauss_legendre< N, T > >
 
struct  limes::methods::adaptive< T >
 Adaptive integration with recursive interval subdivision until convergence. More...
 
struct  limes::methods::is_integration_method< adaptive< T > >
 
struct  limes::methods::monte_carlo< T >
 Monte Carlo integration using random sampling. Error decreases as O(1/sqrt(n)). More...
 
struct  limes::methods::is_integration_method< monte_carlo< T > >
 
struct  limes::methods::simpson< N, T >
 Simpson's 1/3 rule with N subdivisions (N must be even). Achieves O(h^4) convergence. More...
 
struct  limes::methods::is_integration_method< simpson< N, T > >
 
struct  limes::methods::trapezoidal< N, T >
 Trapezoidal rule with N subdivisions. Achieves O(h^2) convergence. More...
 
struct  limes::methods::is_integration_method< trapezoidal< N, T > >
 
struct  limes::methods::adaptive_composed< BaseMethod, T >
 Wraps any base method with adaptive interval subdivision until convergence. More...
 
struct  limes::methods::is_integration_method< adaptive_composed< M, T > >
 

Namespaces

namespace  limes
 
namespace  limes::methods
 

Typedefs

template<typename T = double>
using limes::methods::default_method = adaptive< T >
 The default integration method (adaptive Gauss-Legendre)
 

Functions

template<std::size_t N, typename T = double>
constexpr auto limes::methods::gauss ()
 Factory for Gauss-Legendre quadrature.
 
template<typename T = double>
constexpr auto limes::methods::adaptive_method (T tol=T(1e-10))
 Factory for adaptive integration.
 
template<typename T = double>
constexpr auto limes::methods::monte_carlo_method (std::size_t n)
 Factory for Monte Carlo integration.
 
template<std::size_t N, typename T = double>
constexpr auto limes::methods::simpson_method ()
 Factory for Simpson's rule.
 
template<std::size_t N, typename T = double>
constexpr auto limes::methods::trapezoidal_method ()
 Factory for trapezoidal rule.
 
template<typename M , typename T = double>
constexpr auto limes::methods::make_adaptive (M base_method, T tol=T(1e-10))
 Factory for adaptive composition of any base method.
 

Detailed Description

Integration method objects for composable numerical integration.

Methods are first-class objects passed to .eval() on integrals to control how integration is performed.

using namespace limes::expr;
using namespace limes::methods;
auto x = arg<0>;
auto I = integral(sin(x)).over<0>(0.0, 3.14159);
auto r1 = I.eval(gauss<7>());
auto r2 = I.eval(adaptive_method().with_tolerance(1e-12));
auto r3 = I.eval(monte_carlo_method(100000).with_seed(42));
auto r4 = I.eval(simpson_method<100>());
Expression layer for composable calculus.
Definition analysis.hpp:7

Definition in file methods.hpp.