Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

p_norm

P-Norm


Description

The vector p-norm. If given a matrix variable, p_norm will treat it as a vector and compute the p-norm of the concatenated columns.

Usage

p_norm(x, p = 2, axis = NA_real_, keepdims = FALSE, max_denom = 1024)

Arguments

x

An Expression, vector, or matrix.

p

A number greater than or equal to 1, or equal to positive infinity.

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.

keepdims

(Optional) Should dimensions be maintained when applying the atom along an axis? If FALSE, result will be collapsed into an n x 1 column vector. The default is FALSE.

max_denom

(Optional) The maximum denominator considered in forming a rational approximation for p. The default is 1024.

Details

For p ≥q 1, the p-norm is given by

\|x\|_p = ≤ft(∑_{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 = ≤ft(∑_{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 ≥q 1 or p = +∞. 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.

Value

An Expression representing the p-norm of the input.

Examples

x <- Variable(3)
prob <- Problem(Minimize(p_norm(x,2)))
result <- solve(prob)
result$value
result$getValue(x)

prob <- Problem(Minimize(p_norm(x,Inf)))
result <- solve(prob)
result$value
result$getValue(x)

## Not run: 
  a <- c(1.0, 2, 3)
  prob <- Problem(Minimize(p_norm(x,1.6)), list(t(x) %*% a >= 1))
  result <- solve(prob)
  result$value
  result$getValue(x)

  prob <- Problem(Minimize(sum(abs(x - a))), list(p_norm(x,-1) >= 0))
  result <- solve(prob)
  result$value
  result$getValue(x)

## End(Not run)

CVXR

Disciplined Convex Optimization

v1.0-10
Apache License 2.0 | file LICENSE
Authors
Anqi Fu [aut, cre], Balasubramanian Narasimhan [aut], David W Kang [aut], Steven Diamond [aut], John Miller [aut], Stephen Boyd [ctb], Paul Kunsberg Rosenfield [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.