Learn R Programming

CVXR (version 0.99-7)

Constant-class: The Constant class.

Description

This class represents a constant.

Coerce an R object or expression into the '>Constant class.

Usage

Constant(value)

# S4 method for Constant as.character(x)

# S4 method for Constant constants(object)

# S4 method for Constant get_data(object)

# S4 method for Constant value(object)

# S4 method for Constant grad(object)

# S4 method for Constant size(object)

# S4 method for Constant is_positive(object)

# S4 method for Constant is_negative(object)

# S4 method for Constant canonicalize(object)

as.Constant(expr)

Arguments

value

A numeric element, vector, matrix, or data.frame. Vectors are automatically cast into a matrix column.

x, object

A '>Constant object.

expr

An '>Expression, numeric element, vector, matrix, or data.frame.

Value

A '>Constant representing the input as a constant.

Methods (by generic)

  • constants: Returns itself as a constant.

  • get_data: A list with the value of the constant.

  • value: The value of the constant.

  • grad: An empty list since the gradient of a constant is zero.

  • size: The c(row, col) dimensions of the constant.

  • is_positive: A logical value indicating whether all elemenets of the constant are non-negative.

  • is_negative: A logical value indicating whether all elemenets of the constant are non-positive.

  • canonicalize: The canonical form of the constant.

Slots

value

A numeric element, vector, matrix, or data.frame. Vectors are automatically cast into a matrix column.

is_1D_array

(Internal) A logical value indicating whether the value is a vector or 1-D matrix.

sparse

(Internal) A logical value indicating whether the value is a sparse matrix.

size

(Internal) A vector of containing the number of rows and columns.

is_pos

(Internal) A logical value indicating whether all elements are non-negative.

is_neg

(Internal) A logical value indicating whether all elements are non-positive.

Examples

Run this code
# NOT RUN {
x <- Constant(5)
y <- Constant(diag(3))
get_data(y)
value(y)
is_positive(y)
size(y)
as.Constant(y)
# }

Run the code above in your browser using DataLab