R/029_atoms_affine_conj.R

Defines functions conj_expr

Documented in conj_expr

#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/atoms/affine/conj.R
#####

## CVXPY SOURCE: atoms/affine/conj.py
## Conj_ -- elementwise complex conjugate


Conj_ <- new_class("Conj_", parent = AffAtom, package = "CVXR",
  constructor = function(expr, id = NULL) {
    if (is.null(id)) id <- next_expr_id()
    expr <- as_expr(expr)
    shape <- expr@shape

    new_object(S7_object(),
      id    = as.integer(id),
      .cache = new.env(parent = emptyenv()),
      args  = list(expr),
      shape = shape
    )
  }
)

# -- numeric_value: R's native Conj() --------------------------------
## CVXPY SOURCE: conj.py lines 32-35

method(numeric_value, Conj_) <- function(x, values, ...) {
  Conj(values[[1L]])
}

# -- shape_from_args --------------------------------------------------
## CVXPY SOURCE: conj.py lines 37-39

method(shape_from_args, Conj_) <- function(x) {
  x@args[[1L]]@shape
}

# -- Monotonicity: conjugation is NOT monotone ------------------------
## CVXPY SOURCE: conj.py lines 41-49

method(is_incr, Conj_) <- function(x, idx, ...) FALSE
method(is_decr, Conj_) <- function(x, idx, ...) FALSE

# -- Matrix properties: delegate to argument --------------------------
## CVXPY SOURCE: conj.py lines 51-60

method(is_symmetric, Conj_) <- function(x) is_symmetric(x@args[[1L]])
method(is_hermitian, Conj_) <- function(x) is_hermitian(x@args[[1L]])

# -- graph_implementation: identity (no-op for real arguments) --------
## CVXPY SOURCE: conj.py lines 62-82
## Complex2Real handles the actual conjugation; for real args this is a no-op.

method(graph_implementation, Conj_) <- function(x, arg_objs, shape, data = NULL, ...) {
  list(arg_objs[[1L]], list())
}

#' Elementwise Complex Conjugate
#'
#' Returns the complex conjugate of an expression. For real expressions
#' this is a no-op. R's native \code{Conj()} dispatches here for CVXR
#' expressions via the Complex S3 group handler.
#'
#' @param expr A CVXR Expression.
#' @returns A \code{Conj_} atom.
#' @keywords internal
conj_expr <- function(expr) Conj_(expr)

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.