limes 3.1.0
Composable Calculus Expressions for C++20
Loading...
Searching...
No Matches
limes::expr::Integral< E, Dim, Lo, Hi > Struct Template Reference

Definite integral expression node. More...

#include <integral.hpp>

Public Types

using value_type = typename E::value_type
 
using integrand_type = E
 
using lower_bound_type = Lo
 
using upper_bound_type = Hi
 

Public Member Functions

constexpr Integral (E e, Lo lo, Hi hi, value_type tol=value_type(1e-10)) noexcept
 
algorithms::integration_result< value_typeeval (std::span< value_type const > args) const
 
algorithms::integration_result< value_typeeval () const
 
template<typename Method >
requires methods::is_integration_method_v<Method>
algorithms::integration_result< value_typeeval (Method const &method, std::span< value_type const > args) const
 Evaluate the integral using a specific integration method.
 
template<typename Method >
requires methods::is_integration_method_v<Method>
algorithms::integration_result< value_typeeval (Method const &method) const
 Evaluate the integral using a specific method (no outer arguments)
 
algorithms::integration_result< value_typeevaluate (std::span< value_type const > args) const
 
algorithms::integration_result< value_typeevaluate () const
 
template<std::size_t NewDim, typename NewLo , typename NewHi >
constexpr auto over (NewLo lo, NewHi hi) const
 
template<std::size_t NewDim>
constexpr auto over (value_type lo, value_type hi) const
 
std::string to_string () const
 
template<std::size_t SplitDim = Dim>
constexpr auto split (value_type point) const
 
template<std::size_t D1, std::size_t D2>
requires is_integral_v<E>
constexpr auto swap () const
 
template<typename Phi , typename Jacobian >
constexpr auto transform (Phi phi, Jacobian jacobian, value_type new_lower, value_type new_upper) const
 
constexpr auto with_tolerance (value_type tol) const
 Set new tolerance for this integral.
 

Public Attributes

integrand
 
Lo lower
 
Hi upper
 
value_type tolerance
 

Static Public Attributes

static constexpr std::size_t dim_v = Dim
 
static constexpr std::size_t arity_v = (E::arity_v > 0) ? (E::arity_v - 1) : 0
 

Detailed Description

template<typename E, std::size_t Dim, typename Lo, typename Hi>
struct limes::expr::Integral< E, Dim, Lo, Hi >

Definite integral expression node.

Represents the integral ∫ₐᵇ f(x₀,...,xₙ) dxₐᵢₘ where:

  • E is the integrand expression
  • Dim is the dimension being integrated over
  • Lo and Hi are the bounds (constant or expression-valued)

The arity of the result is one less than the integrand's arity, since dimension Dim is consumed by the integration.

Template Parameters
EIntegrand expression type
DimThe variable dimension being integrated (0-indexed)
LoLower bound type (ConstBound or ExprBound)
HiUpper bound type (ConstBound or ExprBound)
Domain Operations
  • split(point) — Split integral at a point: [a,b] → [a,c] + [c,b]
  • swap<D1,D2>() — Swap integration order (Fubini's theorem)
  • ‘transform(φ, φ’, c, d)` — Change of variables
Method-based Evaluation
I.eval(); // Default (adaptive)
I.eval(gauss<7>()); // Gauss-Legendre
I.eval(monte_carlo_method(10000)); // Monte Carlo
See also
IntegralBuilder Fluent builder
integral() Entry point function

Definition at line 210 of file integral.hpp.

Member Typedef Documentation

◆ integrand_type

template<typename E , std::size_t Dim, typename Lo , typename Hi >
using limes::expr::Integral< E, Dim, Lo, Hi >::integrand_type = E

Definition at line 212 of file integral.hpp.

◆ lower_bound_type

template<typename E , std::size_t Dim, typename Lo , typename Hi >
using limes::expr::Integral< E, Dim, Lo, Hi >::lower_bound_type = Lo

Definition at line 213 of file integral.hpp.

◆ upper_bound_type

template<typename E , std::size_t Dim, typename Lo , typename Hi >
using limes::expr::Integral< E, Dim, Lo, Hi >::upper_bound_type = Hi

Definition at line 214 of file integral.hpp.

◆ value_type

template<typename E , std::size_t Dim, typename Lo , typename Hi >
using limes::expr::Integral< E, Dim, Lo, Hi >::value_type = typename E::value_type

Definition at line 211 of file integral.hpp.

Constructor & Destructor Documentation

◆ Integral()

template<typename E , std::size_t Dim, typename Lo , typename Hi >
constexpr limes::expr::Integral< E, Dim, Lo, Hi >::Integral ( e,
Lo  lo,
Hi  hi,
value_type  tol = value_type(1e-10) 
)
inlineconstexprnoexcept

Definition at line 224 of file integral.hpp.

Member Function Documentation

◆ eval() [1/4]

◆ eval() [2/4]

template<typename E , std::size_t Dim, typename Lo , typename Hi >
template<typename Method >
requires methods::is_integration_method_v<Method>
algorithms::integration_result< value_type > limes::expr::Integral< E, Dim, Lo, Hi >::eval ( Method const &  method) const
inline

Evaluate the integral using a specific method (no outer arguments)

Definition at line 259 of file integral.hpp.

References limes::expr::Integral< E, Dim, Lo, Hi >::eval().

◆ eval() [3/4]

template<typename E , std::size_t Dim, typename Lo , typename Hi >
template<typename Method >
requires methods::is_integration_method_v<Method>
algorithms::integration_result< value_type > limes::expr::Integral< E, Dim, Lo, Hi >::eval ( Method const &  method,
std::span< value_type const >  args 
) const
inline

Evaluate the integral using a specific integration method.

Definition at line 247 of file integral.hpp.

References limes::expr::Integral< E, Dim, Lo, Hi >::integrand, limes::expr::Integral< E, Dim, Lo, Hi >::lower, and limes::expr::Integral< E, Dim, Lo, Hi >::upper.

◆ eval() [4/4]

template<typename E , std::size_t Dim, typename Lo , typename Hi >
algorithms::integration_result< value_type > limes::expr::Integral< E, Dim, Lo, Hi >::eval ( std::span< value_type const >  args) const
inline

◆ evaluate() [1/2]

template<typename E , std::size_t Dim, typename Lo , typename Hi >
algorithms::integration_result< value_type > limes::expr::Integral< E, Dim, Lo, Hi >::evaluate ( ) const
inline

Definition at line 271 of file integral.hpp.

References limes::expr::Integral< E, Dim, Lo, Hi >::eval().

◆ evaluate() [2/2]

template<typename E , std::size_t Dim, typename Lo , typename Hi >
algorithms::integration_result< value_type > limes::expr::Integral< E, Dim, Lo, Hi >::evaluate ( std::span< value_type const >  args) const
inline

Definition at line 265 of file integral.hpp.

References limes::expr::Integral< E, Dim, Lo, Hi >::eval().

◆ over() [1/2]

template<typename E , std::size_t Dim, typename Lo , typename Hi >
template<std::size_t NewDim, typename NewLo , typename NewHi >
constexpr auto limes::expr::Integral< E, Dim, Lo, Hi >::over ( NewLo  lo,
NewHi  hi 
) const
inlineconstexpr

◆ over() [2/2]

template<typename E , std::size_t Dim, typename Lo , typename Hi >
template<std::size_t NewDim>
constexpr auto limes::expr::Integral< E, Dim, Lo, Hi >::over ( value_type  lo,
value_type  hi 
) const
inlineconstexpr

Definition at line 286 of file integral.hpp.

References limes::expr::Integral< E, Dim, Lo, Hi >::tolerance.

◆ split()

template<typename E , std::size_t Dim, typename Lo , typename Hi >
template<std::size_t SplitDim = Dim>
constexpr auto limes::expr::Integral< E, Dim, Lo, Hi >::split ( value_type  point) const
inlineconstexpr

Split the integration domain at a given point

Returns a pair of integrals: [lower, point] and [point, upper] Invariant: left.evaluate() + right.evaluate() ≈ original.evaluate()

Example: auto I = integral(f).over<0>(0.0, 1.0); auto [left, right] = I.split(0.5); // left integrates from 0 to 0.5 // right integrates from 0.5 to 1

Definition at line 315 of file integral.hpp.

References limes::expr::Integral< E, Dim, Lo, Hi >::integrand, limes::expr::Integral< E, Dim, Lo, Hi >::lower, limes::expr::Integral< E, Dim, Lo, Hi >::tolerance, and limes::expr::Integral< E, Dim, Lo, Hi >::upper.

◆ swap()

template<typename E , std::size_t Dim, typename Lo , typename Hi >
template<std::size_t D1, std::size_t D2>
requires is_integral_v<E>
constexpr auto limes::expr::Integral< E, Dim, Lo, Hi >::swap ( ) const
inlineconstexpr

Swap integration order for nested integrals (Fubini's theorem)

For a double integral ∫∫ f(x,y) dx dy, swapping gives ∫∫ f(x,y) dy dx Only available when the integrand is itself an Integral

Example: auto I = integral(integral(x*y).over<0>(0,1)).over<1>(0,1); auto J = I.swap<0, 1>(); // Swap x and y integration order // I.evaluate() ≈ J.evaluate()

Definition at line 340 of file integral.hpp.

References limes::expr::Integral< E, Dim, Lo, Hi >::integrand, limes::expr::Integral< E, Dim, Lo, Hi >::lower, limes::expr::Integral< E, Dim, Lo, Hi >::tolerance, and limes::expr::Integral< E, Dim, Lo, Hi >::upper.

◆ to_string()

template<typename E , std::size_t Dim, typename Lo , typename Hi >
std::string limes::expr::Integral< E, Dim, Lo, Hi >::to_string ( ) const
inline

◆ transform()

template<typename E , std::size_t Dim, typename Lo , typename Hi >
template<typename Phi , typename Jacobian >
constexpr auto limes::expr::Integral< E, Dim, Lo, Hi >::transform ( Phi  phi,
Jacobian  jacobian,
value_type  new_lower,
value_type  new_upper 
) const
inlineconstexpr

Apply a change of variables (substitution) to the integral

For ∫[a,b] f(x) dx, using x = φ(t) gives: ∫[c,d] f(φ(t)) |φ'(t)| dt

Example (removing sqrt singularity using x = t²): auto I = integral(1.0 / sqrt(x)).over<0>(0.0, 1.0); auto T = I.transform( [](double t) { return t*t; }, // φ: t → t² [](double t) { return 2*t; }, // φ': t → 2t 0.0, 1.0 // new bounds );

Definition at line 380 of file integral.hpp.

References limes::expr::Integral< E, Dim, Lo, Hi >::tolerance.

◆ with_tolerance()

template<typename E , std::size_t Dim, typename Lo , typename Hi >
constexpr auto limes::expr::Integral< E, Dim, Lo, Hi >::with_tolerance ( value_type  tol) const
inlineconstexpr

Member Data Documentation

◆ arity_v

template<typename E , std::size_t Dim, typename Lo , typename Hi >
constexpr std::size_t limes::expr::Integral< E, Dim, Lo, Hi >::arity_v = (E::arity_v > 0) ? (E::arity_v - 1) : 0
staticconstexpr

Definition at line 217 of file integral.hpp.

◆ dim_v

template<typename E , std::size_t Dim, typename Lo , typename Hi >
constexpr std::size_t limes::expr::Integral< E, Dim, Lo, Hi >::dim_v = Dim
staticconstexpr

Definition at line 216 of file integral.hpp.

◆ integrand

◆ lower

◆ tolerance

◆ upper


The documentation for this struct was generated from the following files: