R/238_reductions_dnlp2smooth_canonicalizers_kl_div_canon.R

Defines functions .smooth_kl_div_canon

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

## CVXPY SOURCE: reductions/dnlp2smooth/canonicalizers/kl_div_canon.py
## kl_div(x, y) = rel_entr(x, y) - x + y; reuse the rel_entr canonicalizer.

.smooth_kl_div_canon <- function(expr, args) {
  .rel_entr <- RelEntr(args[[1L]], args[[2L]])
  rc <- .smooth_rel_entr_canon(.rel_entr, .args(.rel_entr))
  list(rc[[1L]] - args[[1L]] + args[[2L]], rc[[2L]])
}

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.