Nothing
#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/atoms/sigma_max.R
#####
## CVXPY SOURCE: atoms/sigma_max.py
## SigmaMax -- maximum singular value of a matrix
SigmaMax <- new_class("SigmaMax", parent = Atom, package = "CVXR",
constructor = function(A, id = NULL) {
if (is.null(id)) id <- next_expr_id()
A <- as_expr(A)
## Shape is always scalar
shape <- c(1L, 1L)
obj <- new_object(S7_object(),
id = as.integer(id),
.cache = new.env(parent = emptyenv()),
args = list(A),
shape = shape
)
validate_arguments(obj)
obj
}
)
# -- validate -----------------------------------------------------
## CVXPY: sigma_max.py lines 33-38 -- must be 2D
method(validate_arguments, SigmaMax) <- function(x) {
A <- x@args[[1L]]
if (length(A@shape) != 2L) {
cli_abort("The argument to {.fn sigma_max} must be a 2-d matrix.")
}
invisible(NULL)
}
# -- shape --------------------------------------------------------
## CVXPY: sigma_max.py lines 64-67 -- returns tuple()
method(shape_from_args, SigmaMax) <- function(x) c(1L, 1L)
# -- sign ---------------------------------------------------------
## CVXPY: sigma_max.py lines 69-73 -- always nonneg
method(sign_from_args, SigmaMax) <- function(x) {
list(is_nonneg = TRUE, is_nonpos = FALSE)
}
# -- curvature ----------------------------------------------------
## CVXPY: sigma_max.py lines 75-83 -- convex, not concave
method(is_atom_convex, SigmaMax) <- function(x) TRUE
method(is_atom_concave, SigmaMax) <- function(x) FALSE
# -- monotonicity -------------------------------------------------
## CVXPY: sigma_max.py lines 85-93 -- not monotone
method(is_incr, SigmaMax) <- function(x, idx, ...) FALSE
method(is_decr, SigmaMax) <- function(x, idx, ...) FALSE
# -- numeric ------------------------------------------------------
## CVXPY: sigma_max.py lines 41-44 -- norm(A, 2) = max singular value
method(numeric_value, SigmaMax) <- function(x, values, ...) {
A <- values[[1L]]
matrix(max(svd(A, nu = 0L, nv = 0L)$d), 1L, 1L)
}
# -- get_data -----------------------------------------------------
method(get_data, SigmaMax) <- function(x) list()
# -- graph_implementation -----------------------------------------
method(graph_implementation, SigmaMax) <- function(x, arg_objs, shape, data = NULL, ...) {
cli_abort("graph_implementation for {.cls SigmaMax} not available; use Dcp2Cone canonicalization.")
}
# ==================================================================
# Convenience function
# ==================================================================
#' Maximum singular value
#' @param A A matrix expression
#' @returns An expression representing the maximum singular value of A
#' @export
sigma_max <- function(A) {
SigmaMax(A)
}
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.