numpoly.prod

numpoly.prod(a: numpoly.typing.PolyLike, axis: Union[None, int, Sequence[int]] = None, dtype: Union[numpy.dtype[Any], None, Type[Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], numpy._typing._dtype_like._DTypeDict, Tuple[Any, Any]] = None, out: Optional[numpoly.baseclass.ndpoly] = None, keepdims: bool = False, **kwargs: Any)numpoly.baseclass.ndpoly[source]

Return the product of array elements over a given axis.

Args:
aarray_like

Input data.

axisNone or int or tuple of ints, optional

Axis or axes along which a product is performed. The default, axis=None, will calculate the product of all the elements in the input array. If axis is negative it counts from the last to the first axis. If axis is a tuple of ints, a product is performed on all of the axes specified in the tuple instead of a single axis or all the axes as before.

dtypedtype, optional

The type of the returned array, as well as of the accumulator in which the elements are multiplied. The dtype of a is used by default unless a has an integer dtype of less precision than the default platform integer. In that case, if a is signed then the platform integer is used while if a is unsigned then an unsigned integer of the same precision as the platform integer is used.

outndarray, optional

Alternative output array in which to place the result. It must have the same shape as the expected output, but the type of the output values will be cast if necessary.

keepdimsbool, optional

If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

initialscalar, optional

The starting value for this product.

wherearray_like of bool, optional

Elements to include in the product.

Return:

An array shaped as a but with the specified axis removed. Returns a reference to out if specified.

Example:
>>> q0, q1 = numpoly.variable(2)
>>> poly = numpoly.polynomial([[[1, q0, q0**2],
...                             [q0+q1, q1, q1]]])
>>> numpoly.prod(poly)
polynomial(q0**3*q1**3+q0**4*q1**2)
>>> numpoly.prod(poly, keepdims=True)
polynomial([[[q0**3*q1**3+q0**4*q1**2]]])
>>> numpoly.prod(poly, axis=1)
polynomial([[q1+q0, q0*q1, q0**2*q1]])
>>> numpoly.prod(poly, axis=2, keepdims=True)
polynomial([[[q0**3],
             [q1**3+q0*q1**2]]])
>>> numpoly.prod(poly, axis=[1, 2])
polynomial([[[q0**3*q1**3+q0**4*q1**2]]])