Nothing
#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/reductions/complex2real/canonicalizers/abs_canon.R
#####
## CVXPY SOURCE: reductions/complex2real/canonicalizers/abs_canon.py
## |z| = pnorm(vstack(vec(Re), vec(Im)), p=2, axis=0), reshaped back
c2r_abs_canon <- function(expr, real_args, imag_args, real2imag) {
if (is.null(real_args[[1L]])) {
## Purely imaginary
output <- Abs(imag_args[[1L]])
} else if (is.null(imag_args[[1L]])) {
## Purely real
output <- Abs(real_args[[1L]])
} else {
## Complex: |z| = sqrt(Re^2 + Im^2) via pnorm column-wise
## CVXPY: flatten() -> shape (n,), vstack -> (2, n), pnorm(axis=0) -> (n,)
## R: vec -> (n, 1), so reshape to (1, n) rows first, VStack -> (2, n)
n <- prod(real_args[[1L]]@shape)
real_flat <- vec(real_args[[1L]])
imag_flat <- vec(imag_args[[1L]])
real_row <- reshape_expr(real_flat, c(1L, n))
imag_row <- reshape_expr(imag_flat, c(1L, n))
norms <- Pnorm(VStack(real_row, imag_row), p = 2, axis = 2L)
output <- reshape_expr(norms, real_args[[1L]]@shape)
}
list(output, NULL)
}
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.