R/080_atoms_sum_smallest.R

Defines functions sum_smallest

Documented in sum_smallest

#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/atoms/sum_smallest.R
#####

## CVXPY SOURCE: atoms/sum_smallest.py
## SumSmallest -- sum of k smallest entries

#' Sum of k smallest entries
#'
#' @param x An Expression
#' @param k Number of smallest entries to sum
#' @returns An Expression equal to -SumLargest(-x, k)
#' @export
sum_smallest <- function(x, k) {
  -SumLargest(-as_expr(x), k)
}

Try the CVXR package in your browser

Any scripts or data that you put into this service are public.

CVXR documentation built on March 6, 2026, 9:10 a.m.