← all packages

quadprog

native: 3 functions analysed · 3 typed · 0 untypeable · 0 timed out · 3 entry points (3 typed) · R: 2 definitions, 0 typed strict, 0 gradual, prelude debt 0 · fuzzing: 0 definitions, 0 unsound, 0 accept calls outside their domain · tyr dc7f1a7 · Rsem 7bcb45f · NativeSem 770a1eb · rstt 2b2696f unpinned

Native functions

C functions reachable from an entry point
3 / 3 (100.0%)
typed
3 / 3 (100.0%)

Native → R

entry points
3 / 3 (100.0%)
defined in src/
3 / 3 (100.0%)
typed
3 / 3 (100.0%)
bound in R
3 / 3 (100.0%)

R definitions

named top-level definitions
2 / 2 (100.0%)
not blocked by an unbound native symbol
2 / 2 (100.0%)
typed, gradual
0 / 2 (0.0%)
typed, strict
0 / 2 (0.0%)
side
mode
5 / 5

Native functions 3

aind_ typed entry .Fortran

[INT, INT, INT, INT, LGL] --> c_void
timing: 0.006 s
(definition not located in src/)

qpgen1_ typed entry .Fortran

[DBL, DBL, INT, INT, DBL, DBL, DBL, DBL, INT, DBL, INT, INT, INT, INT, INT, INT, DBL, INT] --> c_void
timing: 0.022 s
(definition not located in src/)

qpgen2_ typed entry .Fortran

[DBL, DBL, INT, INT, DBL, DBL, DBL, DBL, DBL, INT, INT, INT, INT, INT, INT, DBL, INT] --> c_void
timing: 0.020 s
(definition not located in src/)

R definitions 2

R/quadprog.R

solve.QP.compact untypeable

untypeable application of base::> (line 38)
error detail
argument: @(0.<> | 'meq, INT1<> | null)
failing call: base::>(new.env(), NULL)
timing: 1.47 s
source
solve.QP.compact <- function(Dmat, dvec, Amat, Aind, bvec, meq=0,
                             factorized=FALSE){  
  n     <- nrow(Dmat)
  q     <- ncol(Amat)
  anrow <- nrow(Amat)
  if( missing(bvec) )
    bvec <- rep(0,q)

  if( n != ncol(Dmat) )
    stop("Dmat is not symmetric!")
  if( n != length(dvec) )
    stop("Dmat and dvec are incompatible!")
  if( (anrow+1 != nrow(Aind)) || (q != ncol(Aind)) || (q != length(bvec)) )
    stop("Amat, Aind and bvec are incompatible!")
  Aindok <- .Fortran(.QP_aind,
                     as.integer(Aind), as.integer(anrow+1),
                     as.integer(q), as.integer(n),
                     ok=TRUE)$ok
  if( !Aindok )
    stop("Aind contains illegal indexes!")
  if( (meq > q) || (meq < 0 ) )
    stop("Value of meq is invalid!")

  iact  <- rep(0,q)
  nact  <- 0
  r     <- min(n,q)
  sol   <- rep(0,n)
  lagr  <- rep(0,q)
  crval <- 0
  work  <- rep(0,2*n+r*(r+5)/2+2*q+1)
  iter  <- rep(0,2)

  res1 <- .Fortran(.QP_qpgen1,
                   as.double(Dmat), dvec=as.double(dvec),
                   as.integer(n), as.integer(n),
                   sol=as.double(sol), lagr=as.double(lagr),
                   crval=as.double(crval),
                   as.double(Amat), as.integer(Aind), as.double(bvec),
                   as.integer(anrow), as.integer(q), as.integer(meq),
                   iact=as.integer(iact), nact=as.integer(nact),
                   iter=as.integer(iter), 
                   work=as.double(work), ierr=as.integer(factorized))

  if( res1$ierr == 1)
    stop("constraints are inconsistent, no solution!")
  else if( res1$ierr == 2)
    stop("matrix D in quadratic function is not positive definite!")
    
  list(solution=res1$sol,
       value=res1$crval,
       unconstrained.solution=res1$dvec,
       iterations=res1$iter,
       Lagrangian = res1$lagr,
       iact=res1$iact[1:res1$nact])   
}
R/quadprog.R:18

solve.QP untypeable

untypeable application of base::> (line 105)
error detail
argument: @(0.<> | 'meq, INT1<> | null)
failing call: base::>(new.env(), NULL)
timing: 0.653 s
source
solve.QP <- function(Dmat, dvec, Amat, bvec, meq=0, factorized=FALSE){  

  n     <- nrow(Dmat)
  q     <- ncol(Amat)
  if( missing(bvec) )
    bvec <- rep(0,q)

  if( n != ncol(Dmat) )
    stop("Dmat is not symmetric!")
  if( n != length(dvec) )
    stop("Dmat and dvec are incompatible!")
  if( n != nrow(Amat) )
    stop("Amat and dvec are incompatible!")
  if( q != length(bvec) )
    stop("Amat and bvec are incompatible!")
  if( (meq > q) || (meq < 0 ) )
    stop("Value of meq is invalid!")
  
  iact  <- rep(0,q)
  nact  <- 0
  r     <- min(n,q)
  sol   <- rep(0,n)
  lagr  <- rep(0,q)
  crval <- 0
  work  <- rep(0,2*n+r*(r+5)/2+2*q+1)
  iter  <- rep(0,2)

  res1 <- .Fortran(.QP_qpgen2,
                   as.double(Dmat), dvec=as.double(dvec),
                   as.integer(n), as.integer(n),
                   sol=as.double(sol), lagr=as.double(lagr),
                   crval=as.double(crval),
                   as.double(Amat), as.double(bvec), as.integer(n),
                   as.integer(q), as.integer(meq),
                   iact=as.integer(iact), nact=as.integer(nact),
                   iter=as.integer(iter), work=as.double(work),
                   ierr=as.integer(factorized))

  if( res1$ierr == 1)
    stop("constraints are inconsistent, no solution!")
  else if( res1$ierr == 2)
    stop("matrix D in quadratic function is not positive definite!")

  list(solution=res1$sol,
       value=res1$crval,
       unconstrained.solution=res1$dvec,
       iterations=res1$iter,
       Lagrangian = res1$lagr,
       iact=res1$iact[1:res1$nact])   
}
R/quadprog.R:90