Nothing
#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/reductions/dgp2dcp/canonicalizers/mulexpression_canon.R
#####
## CVXPY SOURCE: reductions/dgp2dcp/canonicalizers/mulexpression_canon.py
## DGP canonicalizer for MulExpression (matmul): log_sum_exp of inner products
.dgp_mulexpression_canon <- function(expr, args) {
lhs <- args[[1L]]
rhs <- args[[2L]]
promoted <- mul_shapes_promote(lhs@shape, rhs@shape)
lhs_shape <- promoted[[1L]]
rhs_shape <- promoted[[2L]]
lhs <- reshape_expr(lhs, lhs_shape)
rhs <- reshape_expr(rhs, rhs_shape)
rows <- list()
for (i in seq_len(lhs_shape[1L])) {
row <- list()
for (j in seq_len(rhs_shape[2L])) {
elems <- lapply(seq_len(lhs_shape[2L]), function(k) {
lhs[i, k] + rhs[k, j]
})
arr <- do.call(hstack, elems)
row <- c(row, list(log_sum_exp(arr)))
}
rows <- c(rows, list(row))
}
mat <- bmat(rows)
if (!identical(mat@shape, expr@shape)) {
mat <- reshape_expr(mat, expr@shape)
}
list(mat, 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.