cumsum_axis: Cumulative Sum

cumsum_axisR Documentation

Cumulative Sum

Description

The cumulative sum, \sum_{i=1}^k x_i for k=1,\ldots,n. When calling cumsum, matrices are automatically flattened into column-major order before the sum is taken.

Usage

cumsum_axis(expr, axis = 2)

## S4 method for signature 'Expression'
cumsum(x)

Arguments

axis

(Optional) The dimension across which to apply the function: 1 indicates rows, and 2 indicates columns. The default is 2.

x, expr

An Expression, vector, or matrix.

Examples

val <- cbind(c(1,2), c(3,4))
value(cumsum(Constant(val)))
value(cumsum_axis(Constant(val)))

x <- Variable(2,2)
prob <- Problem(Minimize(cumsum(x)[4]), list(x == val))
result <- solve(prob)
result$value
result$getValue(cumsum(x))

CVXR documentation built on June 27, 2024, 5:11 p.m.