Learn R Programming

CVXR (version 1.0-14)

quad_form: Quadratic Form

Description

The quadratic form, \(x^TPx\).

Usage

quad_form(x, P)

Value

An Expression representing the quadratic form evaluated at the input.

Arguments

x

An Expression or vector.

P

An Expression or matrix.

Examples

Run this code
x <- Variable(2)
P <- rbind(c(4,0), c(0,9))
prob <- Problem(Minimize(quad_form(x,P)), list(x >= 1))
result <- solve(prob)
result$value
result$getValue(x)

A <- Variable(2,2)
c <- c(1,2)
prob <- Problem(Minimize(quad_form(c,A)), list(A >= 1))
result <- solve(prob)
result$value
result$getValue(A)

Run the code above in your browser using DataLab