R/161_reductions_dcp2cone_canonicalizers_exp_canon.R

Defines functions exp_canon

#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/reductions/dcp2cone/canonicalizers/exp_canon.R
#####

## CVXPY SOURCE: reductions/dcp2cone/canonicalizers/exp_canon.py
## exp(x) -> t where ExpCone(x, 1, t)


exp_canon <- function(expr, args, solver_context = NULL) {
  x <- cvxr_promote(args[[1L]], .shape(expr))
  bounds <- get_expr_bounds_if_supported(expr, solver_context)
  t <- Variable(shape = .shape(expr), bounds = bounds)
  ones <- Constant(matrix(1, nrow = .shape(expr)[1L], ncol = .shape(expr)[2L]))
  constraints <- list(ExpCone(x, ones, t))
  list(t, constraints)
}

method(dcp_canonicalize, Exp) <- exp_canon
method(has_dcp_canon, Exp) <- function(expr) TRUE

Try the CVXR package in your browser

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

CVXR documentation built on Aug. 24, 2026, 9:10 a.m.