R/086_atoms_inv_prod.R

Defines functions inv_prod

Documented in inv_prod

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

## CVXPY SOURCE: atoms/inv_prod.py
## InvProd -- reciprocal of product of entries

#' Reciprocal of product of entries
#'
#' @description
#' Computes the reciprocal of the product of entries.
#' Equivalent to `geo_mean(x)^(-n)` where n is the number of entries.
#'
#' @param x An Expression or numeric value (must have positive entries).
#' @param approx Logical; if TRUE (default), use SOC approximation.
#' @returns A convex Expression representing the reciprocal product.
#' @export
inv_prod <- function(x, approx = TRUE) {
  x <- as_expr(x)
  n <- expr_size(x)
  power(geo_mean(x, approx = approx), -as.integer(n), approx = approx)
}

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.