Nothing
#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/reductions/dcp2cone/canonicalizers/matrix_frac_canon.R
#####
## CVXPY SOURCE: reductions/dcp2cone/canonicalizers/matrix_frac_canon.py
## matrix_frac(X, P) -> trace(T) subject to PSD([[P, X], [X^T, T]]), symmetry check
matrix_frac_canon <- function(expr, args, solver_context = NULL) {
X <- args[[1L]]
P <- args[[2L]]
## CVXPY: handle 1D X by reshaping to column vector
## In R X is always 2D, but may be (n,1) naturally -- no special handling needed
n <- X@shape[1L]
m <- X@shape[2L]
T_var <- Variable(c(m, m), symmetric = TRUE)
## Schur complement: [[P, X], [X^T, T]] >> 0
## ensures T - X^T P^{-1} X >> 0
M <- bmat(list(list(P, X), list(t(X), T_var)))
constraints <- list(PSD(M))
## Enforce symmetry on P if not already known symmetric
if (!is_symmetric(P)) {
ut <- upper_tri(P)
lt <- upper_tri(t(P))
constraints <- c(constraints, list(ut == lt))
}
list(matrix_trace(T_var), constraints)
}
method(dcp_canonicalize, MatrixFrac) <- matrix_frac_canon
method(has_dcp_canon, MatrixFrac) <- function(expr) TRUE
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.