R/200_reductions_dgp2dcp_canonicalizers_power_canon.R

Defines functions .dgp_power_canon

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

## CVXPY SOURCE: reductions/dgp2dcp/canonicalizers/power_canon.py
## DGP canonicalizer for Power/PowerApprox: x^p -> p * log(x)

.dgp_power_canon <- function(expr, args) {
  ## expr@p is a Constant or Expression; use value for numeric multiplication
  p_val <- if (S7_inherits(expr@p, Constant)) value(expr@p) else expr@p
  list(p_val * args[[1L]], list())
}

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.