wmpy.integration.cache.CacheWrapper¶
- class CacheWrapper(integrator)[source]¶
Bases:
objectThis class implements a cache wrapper around an Integrator.
The returned type of the integration calls is the same of the enclosed integrator.
- integrator¶
the enclosed integrator instance
- cache¶
a dictionary mapping _compute_key(Polytope, Polynomial) into results
Methods
Computes a convex integral.
Computes a batch of integrals.
- integrate(polytope, polynomial)[source]¶
Computes a convex integral.
If the result is not yet available in the cache, the enclosed integrator is called (and the result is added to the cache).
- Parameters:
polytope (
Polytope) – convex integration bounds (a Polytope)polynomial (
Polynomial) – integrand (a Polynomial)
- Return type:
- Returns:
The result of the integration as a non-negative scalar value.
- integrate_batch(convex_integrals)[source]¶
Computes a batch of integrals.
- Parameters:
convex_integrals (
Collection[tuple[Polytope,Polynomial]]) – a collection of bounds/integrand pairs- Return type:
ndarray- Returns:
The result of the batch of integrations as a numpy array.