File: TalbotKatz.R

package info (click to toggle)
quadprog 1.5-3-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 228 kB
  • ctags: 118
  • sloc: fortran: 682; ansic: 46; makefile: 1
file content (21 lines) | stat: -rw-r--r-- 428 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
##
## https://stat.ethz.ch/pipermail/r-help/2007-September/141324.html
##

library(quadprog)

for(n in 1:10){

  Dmat <- diag(2*n)
  dvec <- rep(0, 2*n)
  
  Amat <- cbind(rep(c(1,-1), n),
                rep(1, 2*n),
                kronecker(diag(n), diag(c(-1,1))))
  bvec <- c(1, 1, rep(c(-1,0), n))
  
  meq <- 2

  cat("\n\nFor problem of size", n,":\n")
  print(lapply(solve.QP(Dmat, dvec, Amat, bvec, meq), zapsmall))
}