Nothing
#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/atoms/norm_nuc.R
#####
## CVXPY SOURCE: atoms/norm_nuc.py
## NormNuc -- nuclear norm (sum of singular values)
NormNuc <- new_class("NormNuc", 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 -----------------------------------------------------
## Must be 2D (same as sigma_max)
method(validate_arguments, NormNuc) <- function(x) {
A <- x@args[[1L]]
if (length(A@shape) != 2L) {
cli_abort("The argument to {.fn norm_nuc} must be a 2-d matrix.")
}
invisible(NULL)
}
# -- shape --------------------------------------------------------
## CVXPY: norm_nuc.py lines 54-57 -- returns tuple()
method(shape_from_args, NormNuc) <- function(x) c(1L, 1L)
# -- sign ---------------------------------------------------------
## CVXPY: norm_nuc.py lines 59-62 -- always nonneg
method(sign_from_args, NormNuc) <- function(x) {
list(is_nonneg = TRUE, is_nonpos = FALSE)
}
# -- curvature ----------------------------------------------------
## CVXPY: norm_nuc.py lines 64-72 -- convex, not concave
method(is_atom_convex, NormNuc) <- function(x) TRUE
method(is_atom_concave, NormNuc) <- function(x) FALSE
# -- monotonicity -------------------------------------------------
## CVXPY: norm_nuc.py lines 74-82 -- not monotone
method(is_incr, NormNuc) <- function(x, idx, ...) FALSE
method(is_decr, NormNuc) <- function(x, idx, ...) FALSE
# -- numeric ------------------------------------------------------
## CVXPY: norm_nuc.py lines 33-36 -- sum of singular values
method(numeric_value, NormNuc) <- function(x, values, ...) {
A <- values[[1L]]
matrix(sum(svd(A, nu = 0L, nv = 0L)$d), 1L, 1L)
}
# -- get_data -----------------------------------------------------
method(get_data, NormNuc) <- function(x) list()
# -- graph_implementation -----------------------------------------
method(graph_implementation, NormNuc) <- function(x, arg_objs, shape, data = NULL, ...) {
cli_abort("graph_implementation for {.cls NormNuc} not available; use Dcp2Cone canonicalization.")
}
# ==================================================================
# Convenience function
# ==================================================================
#' Nuclear norm (sum of singular values)
#' @param A A matrix expression
#' @returns An expression representing the nuclear norm of A
#' @export
norm_nuc <- function(A) {
NormNuc(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.