# [R] Quadratic programming with semi-definite matrix

Andreas Jensen bentrevisor at gmail.com
Sat Dec 4 23:01:20 CET 2010

```Hello.

I'm trying to solve a quadratic programming problem of the form min
||Hx - y||^2 s.t. x >= 0 and x <= t using solve.QP in the quadprog
package but I'm having problems with Dmat not being positive definite,
which is kinda okay since I expect it to be numerically semi-definite
in most cases. As far as I'm aware the problem arises because the
Goldfarb and Idnani method first solves the unconstrained problem
requiring a positive definite matrix. Are there any (fast) packages
that allows me to do QP with (large) semidefinite matrices?

Example:
t <- 100
y <- signalConvNoisy[1,]
D <- crossprod(H,H)
d <- crossprod(H,y)
A <- cbind(rep(-1, nrow(H)), diag(ncol(H)))
b0 <- c(t, rep(0, ncol(H)))
sol <- solve.QP(Dmat=D, dvec = d, Amat = A, bvec = b0)\$solution
Error in solve.QP(Dmat = D, dvec = d, Amat = A, bvec = b0) :
matrix D in quadratic function is not positive definite!