Nothing
#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/reductions/dgp2dcp/canonicalizers/quad_form_canon.R
#####
## CVXPY SOURCE: reductions/dgp2dcp/canonicalizers/quad_form_canon.py
## DGP canonicalizer for QuadForm: x^T P x -> log_sum_exp(P[i,j] + x_i + x_j)
## In log-space: log(sum_ij P_ij * x_i * x_j) = log_sum_exp(log(P_ij) + log(x_i) + log(x_j))
## Args are already in log-space, so P[i,j] + x[i] + x[j].
.dgp_quad_form_canon <- function(expr, args) {
x <- args[[1L]]
P <- args[[2L]]
n <- P@shape[1L]
elems <- list()
for (i in seq_len(n)) {
for (j in seq_len(n)) {
elems <- c(elems, list(P[i, j] + x[i] + x[j]))
}
}
result <- log_sum_exp(do.call(hstack, elems))
list(result, list())
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.