blosc2.prod#

blosc2.prod(ndarr: NDArray | NDField | C2Array | LazyExpr, axis: int | tuple[int] | None = None, dtype: dtype | str = None, keepdims: bool = False, **kwargs: Any) ndarray | NDArray | int | float | complex | bool#

Return the product of array elements over a given axis.

The parameters are documented in the sum.

Returns:

product_along_axis – The product of the elements along the axis.

Return type:

np.ndarray or NDArray or scalar

References

np.prod

Examples

>>> import numpy as np
>>> import blosc2
>>> # Create an instance of NDArray with some data
>>> array = np.array([[11, 22, 33], [4, 15, 36]])
>>> nd_array = blosc2.asarray(array)
>>> # Compute the product of all elements in the array
>>> prod_all = blosc2.prod(nd_array)
>>> print("Product of all elements in the array:", prod_all)
Product of all elements in the array: 17249760
>>> # Compute the product along axis 1 (rows)
>>> prod_axis1 = blosc2.prod(nd_array, axis=1)
>>> print("Product along axis 1:", prod_axis1)
Product along axis 1: [7986 2160]