R/157_reductions_dcp2cone_canonicalizers_log_canon.R

Defines functions log_canon

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

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


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

method(dcp_canonicalize, Log) <- log_canon
method(has_dcp_canon, Log) <- 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 March 6, 2026, 9:10 a.m.