cumprod#
- class saiunit.math.cumprod(x, axis=None, dtype=None, **kwargs)#
Return the cumulative product of elements along a given axis.
Each position i in the output contains the product of elements from index 0 to i. When the input carries a unit, the unit is raised to the corresponding cumulative power.
- Parameters:
x (
Union[saiunit.Quantity,Array,ndarray,number,bool]) – Input array.axis (
Optional[int]) – Axis along which the cumulative product is computed. By default the input is flattened.dtype (
Union[str,type[Any],dtype,SupportsDType,None]) – Type of the returned array, as well as of the accumulator in which the elements are multiplied.
- Returns:
cumprod – A new array holding the cumulative product. If x carries a unit, the result is a Quantity.
- Return type:
Union[saiunit.Quantity,Array,ndarray,number,bool]
Examples
>>> import saiunit as u >>> q = u.math.array([1.0, 2.0, 3.0]) * u.meter >>> u.math.cumprod(q)