R/084_atoms_ptp.R

Defines functions ptp

Documented in ptp

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

## CVXPY SOURCE: atoms/ptp.py
## Ptp -- peak-to-peak (range): max(x) - min(x)

#' Peak-to-peak (range): max(x) - min(x)
#'
#' @description
#' Computes the range of values along an axis: `max(x) - min(x)`.
#' The result is always nonnegative.
#'
#' @param x An Expression or numeric value.
#' @param axis NULL (all), 0 (columns), or 1 (rows).
#' @param keepdims Logical; keep reduced dimension?
#' @returns An Expression representing max(x) - min(x).
#' @export
ptp <- function(x, axis = NULL, keepdims = FALSE) {
  x <- as_expr(x)
  max_entries(x, axis = axis, keepdims = keepdims) -
    min_entries(x, axis = axis, keepdims = keepdims)
}

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.