R/058_atoms_elementwise_log.R

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

## CVXPY SOURCE: atoms/elementwise/log.py
## Log -- elementwise natural logarithm log(x)


Log <- new_class("Log", parent = Elementwise, package = "CVXR",
  constructor = function(x, id = NULL) {
    if (is.null(id)) id <- next_expr_id()
    x <- as_expr(x)
    shape <- x@shape
    obj <- new_object(S7_object(),
      id    = as.integer(id),
      .cache = new.env(parent = emptyenv()),
      args  = list(x),
      shape = shape
    )
    validate_arguments(obj)
    obj
  }
)

# -- sign: unknown ------------------------------------------------
method(sign_from_args, Log) <- function(x) {
  list(is_nonneg = FALSE, is_nonpos = FALSE)
}

# -- curvature: concave -------------------------------------------
method(is_atom_convex, Log) <- function(x) FALSE
method(is_atom_concave, Log) <- function(x) TRUE

# -- monotonicity: increasing -------------------------------------
method(is_incr, Log) <- function(x, idx, ...) TRUE
method(is_decr, Log) <- function(x, idx, ...) FALSE

# -- log-log: concave (CVXPY log.py lines 53-61) -----------------
method(is_atom_log_log_convex, Log) <- function(x) FALSE
method(is_atom_log_log_concave, Log) <- function(x) TRUE

# -- domain: arg >= 0 ---------------------------------------------
method(atom_domain, Log) <- function(x) {
  list(x@args[[1L]] >= 0)
}

# -- numeric ------------------------------------------------------
method(numeric_value, Log) <- function(x, values, ...) {
  log(values[[1L]])
}

# -- graph_implementation: stub -----------------------------------
method(graph_implementation, Log) <- function(x, arg_objs, shape, data = NULL, ...) {
  cli_abort("graph_implementation for {.cls Log} not yet implemented.")
}

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.