R/189_reductions_complex2real_canonicalizers_psd_canon.R

Defines functions c2r_psd_canon

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

## CVXPY SOURCE: reductions/complex2real/canonicalizers/psd_canon.py
## PSD constraint: [[Re, -Im], [Im, Re]] >> 0

c2r_psd_canon <- function(expr, real_args, imag_args, real2imag) {
  if (is.null(imag_args[[1L]])) {
    mat <- real_args[[1L]]
  } else {
    if (is.null(real_args[[1L]])) {
      real_args[[1L]] <- Constant(matrix(0, imag_args[[1L]]@shape[1L],
                                         imag_args[[1L]]@shape[2L]))
    }
    mat <- bmat(list(
      list(real_args[[1L]], -imag_args[[1L]]),
      list(imag_args[[1L]], real_args[[1L]])
    ))
  }
  list(list(expr_copy(expr, list(mat))), NULL)
}

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.