flashquad.integrator¶
FlashQuad — numerical integrator with pluggable array backends.
Module Contents¶
Classes¶
Numerical integrator bound to a specific array backend, dtype, and device. |
API¶
- class flashquad.integrator.FlashQuad(backend: str, dtype: Any = None, device=None)¶
Numerical integrator bound to a specific array backend, dtype, and device.
Parameters
backend : str Array backend name. One of
'numpy','torch','cupy','jax'. dtype : optional Floating-point dtype that must be compatible with the chosen backend. For'torch'pass atorch.dtype(e.g.torch.float64); for numpy-compatible backends pass a numpy dtype (e.g.numpy.float64). Defaults to the backend’sfloat64. device : optional Compute device. For'torch', pass a string ('cuda','cpu','cuda:0', …) or atorch.device. WhenNone(the default) the torch backend auto-selects CUDA if available. Ignored for other backends.Initialization
- __repr__()¶
- trapz(func, intervals, num_points, *, params=None, boundary=None)¶
Integrate using the composite trapezoidal rule.
Args: func: Integrand. Called as
func(*mesh_coords)orfunc(*mesh_coords, params_expanded)when params is given. intervals: Integration bounds per dimension, e.g.[[0, 1], [0, 1]]. num_points: Grid points per dimension, e.g.[101, 101]. params: Parameter array shaped(batch, num_params). Each row is one set of parameters for batched evaluation. boundary: Optional mask function applied to the integrand.
- simpson(func, intervals, num_points, *, params=None, boundary=None)¶
Integrate using composite Simpson’s 1/3 rule.
Args: See :meth:
trapz. Each entry in num_points must be odd.
- booles(func, intervals, num_points, *, params=None, boundary=None)¶
Integrate using composite Boole’s rule.
Args: See :meth:
trapz.(num_points[i] - 1)must be divisible by 4.
- gauss(func, intervals, num_points, *, params=None, boundary=None)¶
Integrate using Gauss-Legendre quadrature.
Args: See :meth:
trapz.
- mc(func, intervals, num_points, *, params=None, boundary=None)¶
Integrate using Monte Carlo sampling.
Args: func: Integrand function. intervals: Integration bounds per dimension. num_points: Total number of random samples (single integer). params: Parameter array shaped
(batch, num_params). boundary: Optional mask function.