Cumulative product of array elements along a single axis.
Output position j along axis equals the product of input positions 1:j.
A boolean input is accumulated with a logical AND, so the result is a
running AND. nv_cumprod() multiplies zeroes and ones instead.
Arguments
- x
(
arrayish)
One input. Can be any data type. An R value materializes at its default data type.- axis
(
integer(1))
Axis along which to accumulate. Negative values count from the end, i.e.-1refers to the last axis.
Value
(arrayish)
Has the input's shape and data type.
StableHLO
Lowers to hlo_reduce_window(), specified under
reduce_window.
The reducer is hlo_multiply().
Examples
# the accumulation keeps the input's data type
x <- nv_matrix(1:6, nrow = 2)
prim_cumprod(x, axis = 1L)
#> AnvlArray
#> 1 3 5
#> 2 12 30
#> [ CPUi32{2,3} ]