Nothing
#####
## 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 (FALSE) new_object(S7_object()) ## S7 static-check guard
if (is.null(id)) id <- next_expr_id()
x <- as_expr(x)
shape <- .shape(x)
obj <- .fast_new(Log, S7_object(),
id = as.integer(id),
.cache = new.env(parent = emptyenv()),
args = list(x),
shape = shape
)
validate_arguments(obj)
obj
}
)
# -- bounds: log defined on x > 0 (#3080) -------------------------
## CVXPY SOURCE: elementwise/log.py:58-61.
method(bounds_from_args, Log) <- function(x) {
b <- get_bounds(.args(x)[[1L]])
log_bounds(b[[1L]], b[[2L]])
}
# -- 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
## CVXPY elementwise/log.py: log is smooth.
method(is_atom_smooth, 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(.args(x)[[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.")
}
# -- .grad: per-atom subgradient ----------------------------------
## CVXPY SOURCE: atoms/elementwise/log.py:73-93 (log._grad).
## d/dx log(x) = 1/x; domain x > 0. Returns list(NULL) on boundary or below.
method(.grad, Log) <- function(x, values, ...) {
v <- values[[1L]]
if (min(v) <= 0) return(list(NULL))
rows <- as.integer(prod(.arg_shape(x)))
cols <- as.integer(prod(.shape(x)))
list(.elemwise_grad_to_diag(1 / v, rows, cols))
}
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.