This class represents a constant.

Coerce an R object or expression into the Constant class.

Constant(value)

# S4 method for Constant
show(object)

# S4 method for Constant
name(x)

# S4 method for Constant
constants(object)

# S4 method for Constant
value(object)

# S4 method for Constant
is_pos(object)

# S4 method for Constant

# S4 method for Constant
dim(x)

# S4 method for Constant
canonicalize(object)

# S4 method for Constant
is_nonneg(object)

# S4 method for Constant
is_nonpos(object)

# S4 method for Constant
is_imag(object)

# S4 method for Constant
is_complex(object)

# S4 method for Constant
is_symmetric(object)

# S4 method for Constant
is_hermitian(object)

# S4 method for Constant
is_psd(object)

# S4 method for Constant
is_nsd(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)

• name(Constant): The name of the constant.

• constants(Constant): Returns itself as a constant.

• value(Constant): The value of the constant.

• is_pos(Constant): A logical value indicating whether all elements of the constant are positive.

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

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

• canonicalize(Constant): The canonical form of the constant.

• is_nonneg(Constant): A logical value indicating whether all elements of the constant are non-negative.

• is_nonpos(Constant): A logical value indicating whether all elements of the constant are non-positive.

• is_imag(Constant): A logical value indicating whether the constant is imaginary.

• is_complex(Constant): A logical value indicating whether the constant is complex-valued.

• is_symmetric(Constant): A logical value indicating whether the constant is symmetric.

• is_hermitian(Constant): A logical value indicating whether the constant is a Hermitian matrix.

• is_psd(Constant): A logical value indicating whether the constant is a positive semidefinite matrix.

• is_nsd(Constant): A logical value indicating whether the constant is a negative semidefinite matrix.

## Slots

value

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

sparse

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

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

x <- Constant(5)
y <- Constant(diag(3))
get_data(y)
#> list()
value(y)
#>      [,1] [,2] [,3]
#> [1,]    1    0    0
#> [2,]    0    1    0
#> [3,]    0    0    1
is_nonneg(y)
#> [1] TRUE
size(y)
#> [1] 9
as.Constant(y)
#> Constant(CONSTANT, NONNEGATIVE, (3,3))