Use vectorized integration for multiple domains or outputs
mainQuadpy is fully vectorized. You can integrate a function over multiple domains simultaneously by passing an array of domains to the scheme.integrate() method. Similarly, you can integrate functions that return vectorized outputs (e.g., a list or array of values).
# shape (3, 5, 2), i.e., (corners, num_triangles, xy_coords)
triangles = np.stack(
[
[[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]],
[[1.2, 0.6], [1.3, 0.7], [1.4, 0.8]],
[[26.0, 31.0], [24.0, 27.0], [33.0, 28]],
[[0.1, 0.3], [0.4, 0.4], [0.7, 0.1]],
[[8.6, 6.0], [9.4, 5.6], [7.5, 7.4]],
],
axis=-2,
)
# Example of a vectorized function
def f(x):
return [np.sin(x[0]), np.sin(x[1])]
# Integration call would use the 'triangles' array
# val = scheme.integrate(f, triangles)