This class represents the vector p-norm.
Pnorm(x, p = 2, axis = NA_real_, max_denom = 1024)# S4 method for Pnorm
validate_args(object)
# S4 method for Pnorm
name(object)
# S4 method for Pnorm
to_numeric(object, values)
# S4 method for Pnorm
sign_from_args(object)
# S4 method for Pnorm
is_atom_convex(object)
# S4 method for Pnorm
is_atom_concave(object)
# S4 method for Pnorm
is_incr(object, idx)
# S4 method for Pnorm
is_decr(object, idx)
# S4 method for Pnorm
is_pwl(object)
# S4 method for Pnorm
get_data(object)
# S4 method for Pnorm
graph_implementation(object, arg_objs, size,
data = NA_real_)
A number greater than or equal to 1, or equal to positive infinity.
(Optional) The dimension across which to apply the function: 1
indicates rows, 2
indicates columns, and NA
indicates rows and columns. The default is NA
.
The maximum denominator considered in forming a rational approximation for \(p\).
A list of arguments to the atom.
An index into the atom.
A list of linear expressions for each argument.
A vector with two elements representing the size of the resulting expression.
A list of additional data required by the atom.
validate_args
: Check that the arguments are valid.
name
: The name and arguments of the atom.
to_numeric
: The p-norm of x
.
sign_from_args
: The atom is positive.
is_atom_convex
: The atom is convex if \(p \geq 1\).
is_atom_concave
: The atom is concave if \(p < 1\).
is_incr
: The atom is weakly increasing if \(p < 1\) or \(p \geq 1\) and x
is positive.
is_decr
: The atom is weakly decreasing if \(p \geq 1\) and x
is negative.
is_pwl
: The atom is piecewise linear only if x
is piecewise linear, and either \(p = 1\) or \(p = \infty\).
get_data
: Returns list(p, axis)
.
graph_implementation
: The graph implementation of the atom.
p
A number greater than or equal to 1, or equal to positive infinity.
max_denom
The maximum denominator considered in forming a rational approximation for \(p\).
axis
(Optional) The dimension across which to apply the function: 1
indicates rows, 2
indicates columns, and NA
indicates rows and columns. The default is NA
.
.approx_error
(Internal) The absolute difference between \(p\) and its rational approximation.
If given a matrix variable, Pnorm
will treat it as a vector and compute the p-norm of the concatenated columns.
For \(p \geq 1\), the p-norm is given by $$\|x\|_p = \left(\sum_{i=1}^n |x_i|^p\right)^{1/p}$$ with domain \(x \in \mathbf{R}^n\). For \(p < 1, p\neq 0\), the p-norm is given by $$\|x\|_p = \left(\sum_{i=1}^n x_i^p\right)^{1/p}$$ with domain \(x \in \mathbf{R}^n_+\).
Note that the "p-norm" is actually a norm only when \(p \geq 1\) or \(p = +\infty\). For these cases, it is convex.
The expression is undefined when \(p = 0\).
Otherwise, when \(p < 1\), the expression is concave, but not a true norm.