Skip to contents

Log cumulative sum exponential for mlx arrays

Usage

mlx_logcumsumexp(x, axis = NULL, reverse = FALSE, inclusive = TRUE)

Arguments

x

An mlx array, or an R array/matrix/vector that will be converted via as_mlx().

axis

Optional axis (single integer) to operate over.

reverse

Logical flag for reverse accumulation.

inclusive

Logical flag controlling inclusivity.

Value

An mlx array.

Examples

x <- as_mlx(1:4)
as.vector(mlx_logcumsumexp(x))
#> [1] 1.000000 2.313262 3.407606 4.440190
m <- as_mlx(matrix(1:6, 2, 3))
as.matrix(mlx_logcumsumexp(m, axis = 2))
#>      [,1]     [,2]     [,3]
#> [1,]    1 3.126928 5.142931
#> [2,]    2 4.126928 6.142931