cumprod#
- class brainunit.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 (saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex) – Input array.axis (
int|None) – Axis along which the cumulative product is computed. By default the input is flattened.dtype (
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:
saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex
Examples
>>> import saiunit as u >>> q = u.math.array([1.0, 2.0, 3.0]) * u.meter >>> u.math.cumprod(q)