mccube._formulae
Defines cubature formulae for integrating functions over the regions (measure spaces)
defined as AbstractRegions.
builtin_cubature_registry
module-attribute
¤
builtin_cubature_registry: set[type[AbstractCubature]] = all_subclasses(AbstractCubature)
A searchable registry of all cubature formulae, in the current scope, that are
subclasses of mccube.AbstractCubature.
AbstractCubature
¤
Bases: Module, Generic[_Region]
Abstract base class for cubature formulae.
A concrete implementation of this class allows one to construct the points
and weights of a pre-defined cubature formula
over some specified integration region (measure space).
Example
Attributes:
-
region(_Region) –an
AbstractRegion(measure space) of a specified dimension. -
degree(int) –the degree \(m\) of polynomials, defined over the
region, for which the cubature formulae is an exact integrator (with respect to the measure \(\mu\)). -
sparse(bool) –indicates if the cubature points have a sparsity structure.
weights
abstractmethod
cached
property
¤
weights: CubatureWeightsTree
A PyTree of Cubature weights \(\lambda_j \in \mathbb{R}_+\) for the measure \(\mu\).
points
abstractmethod
cached
property
¤
points: CubaturePointsTree
A PyTree of Cubature points \(x_j \in \Omega\) for the measure \(\mu\).
stacked_weights
cached
property
¤
stacked_weights: CubatureWeights
weights stacked into a single vector.
stacked_points
cached
property
¤
stacked_points: CubaturePoints
points stacked into a single matrix.
__call__
¤
__call__(integrand: Callable[[CubaturePoints], RealScalarLike]) -> tuple[RealScalarLike, CubatureWeights]
Approximately integrate some function \(f\) over the integration region.
Computes the cubature formula \(Q[f] = \sum_{j=1}^{k} \lambda_j f(x_j)\).
Parameters:
-
integrand(Callable[[CubaturePoints], RealScalarLike]) –the jax transformable function to integrate.
Returns:
-
tuple[RealScalarLike, CubatureWeights]–Approximated integral and stacked weighted evaluations of \(f\) at each vector \(x_j\).
Source code in mccube/_formulae.py
AbstractGaussianCubature
¤
Bases: AbstractCubature[GaussianRegion]
Abstract base class for cubature formula that are valid for the
GaussianRegion.
The Gaussian region is assumed to have the "probabilist's" Hermite measure.
Warning
Here it is assumed that the Gaussian measure is the normalized "probabilist's"
Hermite weight (to be consistent with [@victoir2004]). However, other authors,
such as [@stroud1971], assume the measure is the "physicist's" Hermite
measure. Cubature formulae defined with respect to the later measure must be
appropriately rescaled to be compatible with the measure assumed here.
Reference: [@victoir2004]
Hadamard
¤
Bases: AbstractGaussianCubature
Degree 3 Gaussian cubature from [@victoir2004].
Reference: [@victoir2004]
point_count
cached
property
¤
Cubature point count \(k = 2^{\lceil{\log_2 d}\rceil + 1}\).
StroudSecrest63_31
¤
Bases: AbstractGaussianCubature
Degree 3 Gaussian cubature from [@stroudSecrest1963], listing \(E_n^{r^2}\) 3-1
(pg315) in [@stroud1971].
Reference: [@stroudSecrest1963]
@article{stroudSecrest1963,
title = {Approximate Integration Formulas for Certain Spherically
Symmetric Regions},
author = {Stroud, A. H. and Secrest, Don},
year = {1963},
journal = {Mathematics of Computation},
number = {82},
pages = {105--135},
publisher = {American Mathematical Society},
volume = {17},
issn = {00255718, 10886842},
url = {http://www.jstor.org/stable/2003633}
}
Reference: [@stroud1971]
StroudSecrest63_32
¤
Bases: AbstractGaussianCubature
Degree 3 Gaussian cubature from [@stroudSecrest1963], listing \(E_n^{r^2}\) 3-2
(pg316) in [@stroud1971].
This formula is identical to the mccube.Hadamard formula for dimensions less
than four. For all other dimensions, mccube.Hadamard is strictly more
efficient.
Reference: [@stroudSecrest1963]
@article{stroudSecrest1963,
title = {Approximate Integration Formulas for Certain Spherically
Symmetric Regions},
author = {Stroud, A. H. and Secrest, Don},
year = {1963},
journal = {Mathematics of Computation},
number = {82},
pages = {105--135},
publisher = {American Mathematical Society},
volume = {17},
issn = {00255718, 10886842},
url = {http://www.jstor.org/stable/2003633}
}
Reference: [@stroud1971]
StroudSecrest63_52
¤
Bases: AbstractGaussianCubature
Degree 5 Gaussian cubature from [@stroudSecrest1963], listing \(E_n^{r^2}\) 5-2
(pg317) in [@stroud1971].
Reference: [@stroudSecrest1963]
@article{stroudSecrest1963,
title = {Approximate Integration Formulas for Certain Spherically
Symmetric Regions},
author = {Stroud, A. H. and Secrest, Don},
year = {1963},
journal = {Mathematics of Computation},
number = {82},
pages = {105--135},
publisher = {American Mathematical Society},
volume = {17},
issn = {00255718, 10886842},
url = {http://www.jstor.org/stable/2003633}
}
Reference: [@stroud1971]
StroudSecrest63_53
¤
Bases: AbstractGaussianCubature
Degree 5 Gaussian cubature from [@stroudSecrest1963], listing \(E_n^{r^2}\) 5-3
(pg317) in [@stroud1971]. Valid for regions with dimension d > 2.
Reference: [@stroudSecrest1963]
@article{stroudSecrest1963,
title = {Approximate Integration Formulas for Certain Spherically
Symmetric Regions},
author = {Stroud, A. H. and Secrest, Don},
year = {1963},
journal = {Mathematics of Computation},
number = {82},
pages = {105--135},
publisher = {American Mathematical Society},
volume = {17},
issn = {00255718, 10886842},
url = {http://www.jstor.org/stable/2003633}
}
Reference: [@stroud1971]
evaluate_cubature
¤
evaluate_cubature(weights: CubatureWeightsTree, points: CubaturePointsTree, integrand: Callable[[CubaturePoints], RealScalarLike]) -> tuple[RealScalarLike, CubatureWeights]
Evaluate a cubature formula for a given integrand \(f\).
Parameters:
-
weights(CubatureWeightsTree) –cubature formula weights \(\lambda_j\).
-
points(CubaturePointsTree) –cubature formula points \(x_j\).
-
integrand(Callable[[CubaturePoints], RealScalarLike]) –function \(f\) to integrate.
Returns:
-
tuple[RealScalarLike, CubatureWeights]–Computed integral and the weighted evaluation points \(\lambda_j f(x_j)\).
Source code in mccube/_formulae.py
search_cubature_registry
¤
search_cubature_registry(region: AbstractRegion, degree: int | None = None, sparse_only: bool = False, minimal_only: bool = False, searchable_formulae: Collection[type[AbstractCubature]] = builtin_cubature_registry) -> list[AbstractCubature]
Returns a list of cubature formulae of a specified degree for a given region.
Example
Parameters:
-
region(AbstractRegion) –the region for which the cubature formulae must be of degree \(m\).
-
degree(int | None, default:None) –the required degree \(m\) of cubature formulae. Ignored if none.
-
sparse_only(bool, default:False) –if to only select cubature formulae with sparse cubature points.
-
minimal_only(bool, default:False) –if to only return formulae with minimal point count.
-
searchable_formulae(Collection[type[AbstractCubature]], default:builtin_cubature_registry) –collection from which to search for suitable cubature formulae.