prod¶
- prod(x: array, /, *, axis: int | Tuple[int, ...] | None = None, dtype: dtype | None = None, keepdims: bool = False) array¶
Calculates the product of input array
xelements.Special Cases
Let
Nequal the number of elements over which to compute the product.If
Nis0, the product is1(i.e., the empty product).
For floating-point operands,
If
x_iisNaN, the product isNaN(i.e.,NaNvalues propagate).
- Parameters:
x (array) – input array. Should have a numeric data type.
axis (Optional[Union[int, Tuple[int, ...]]]) – axis or axes along which products must be computed. By default, the product must be computed over the entire array. If a tuple of integers, products must be computed over multiple axes. Default:
None.dtype (Optional[dtype]) –
data type of the returned array. If
None,if the default data type corresponding to the data type “kind” (integer or floating-point) of
xhas a smaller range of values than the data type ofx(e.g.,xhas data typeint64and the default data type isint32, orxhas data typeuint64and the default data type isint64), the returned array must have the same data type asx.if
xhas a floating-point data type, the returned array must have the default floating-point data type.if
xhas a signed integer data type (e.g.,int16), the returned array must have the default integer data type.if
xhas an unsigned integer data type (e.g.,uint16), the returned array must have an unsigned integer data type having the same number of bits as the default integer data type (e.g., if the default integer data type isint32, the returned array must have auint32data type).
If the data type (either specified or resolved) differs from the data type of
x, the input array should be cast to the specified data type before computing the product. Default:None.Note
This keyword argument is intended to help prevent data type overflows.
keepdims (bool) – if
True, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see Broadcasting). Otherwise, ifFalse, the reduced axes (dimensions) must not be included in the result. Default:False.
- Returns:
out (array) – if the product was computed over the entire array, a zero-dimensional array containing the product; otherwise, a non-zero-dimensional array containing the products. The returned array must have a data type as described by the
dtypeparameter above.