Running examples in 'optextras-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: gHgen
> ### Title: Generate gradient and Hessian for a function at given
> ###   parameters.
> ### Aliases: gHgen
> ### Keywords: nonlinear optimize
> 
> ### ** Examples
> 
> # genrose function code
> genrose.f<- function(x, gs=NULL){ # objective function
+ ## One generalization of the Rosenbrock banana valley function (n parameters)
+ 	n <- length(x)
+         if(is.null(gs)) { gs=100.0 }
+ 	fval<-1.0 + sum (gs*(x[1:(n-1)]^2 - x[2:n])^2 + (x[2:n] - 1)^2)
+         return(fval)
+ }
> 
> genrose.g <- function(x, gs=NULL){
+ # vectorized gradient for genrose.f
+ # Ravi Varadhan 2009-04-03
+ 	n <- length(x)
+         if(is.null(gs)) { gs=100.0 }
+ 	gg <- as.vector(rep(0, n))
+ 	tn <- 2:n
+ 	tn1 <- tn - 1
+ 	z1 <- x[tn] - x[tn1]^2
+ 	z2 <- 1 - x[tn]
+ 	gg[tn] <- 2 * (gs * z1 - z2)
+ 	gg[tn1] <- gg[tn1] - 4 * gs * x[tn1] * z1
+ 	return(gg)
+ }
> 
> genrose.h <- function(x, gs=NULL) { ## compute Hessian
+    if(is.null(gs)) { gs=100.0 }
+ 	n <- length(x)
+ 	hh<-matrix(rep(0, n*n),n,n)
+ 	for (i in 2:n) {
+ 		z1<-x[i]-x[i-1]*x[i-1]
+ #		z2<-1.0-x[i]
+                 hh[i,i]<-hh[i,i]+2.0*(gs+1.0)
+                 hh[i-1,i-1]<-hh[i-1,i-1]-4.0*gs*z1-4.0*gs*x[i-1]*(-2.0*x[i-1])
+                 hh[i,i-1]<-hh[i,i-1]-4.0*gs*x[i-1]
+                 hh[i-1,i]<-hh[i-1,i]-4.0*gs*x[i-1]
+ 	}
+         return(hh)
+ }
> 
> trad<-c(-1.2,1)
> ans100fgh<-  gHgen(trad, genrose.f, gr=genrose.g, hess=genrose.h,
+       control=list(ktrace=1)) 
Compute gradient approximation
[1] -211.2  -88.0
Compute Hessian approximation
is.null(hess) is FALSE -- trying hess()
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
optextras
 --- call from context --- 
gHgen(trad, genrose.f, gr = genrose.g, hess = genrose.h, control = list(ktrace = 1))
 --- call from argument --- 
if (class(Hn) == "try-error") {
    if (ctrl$stoponerror) 
        stop("Hessian evaluation with function hess() failed")
} else hessOK <- TRUE
 --- R stacktrace ---
where 1: gHgen(trad, genrose.f, gr = genrose.g, hess = genrose.h, control = list(ktrace = 1))

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
function (par, fn, gr = NULL, hess = NULL, control = list(ktrace = 0), 
    ...) 
{
    ctrl <- list(asymtol = 1e-07, ktrace = FALSE, stoponerror = FALSE)
    namc <- names(control)
    if (!all(namc %in% names(ctrl))) 
        stop("unknown names in control: ", namc[!(namc %in% names(ctrl))])
    ctrl[namc] <- control
    gradOK <- FALSE
    if (ctrl$ktrace) 
        cat("Compute gradient approximation\n")
    if (is.null(gr)) {
        gn <- try(grad(fn, par, ...), silent = TRUE)
    }
    else {
        gn <- try(gr(par, ...), silent = TRUE)
    }
    if (class(gn) != "try-error") 
        gradOK <- TRUE
    if (!gradOK && ctrl$stoponerror) 
        stop("Gradient computations failure!")
    if (ctrl$ktrace) 
        print(gn)
    if (ctrl$ktrace) 
        cat("Compute Hessian approximation\n")
    hessOK <- FALSE
    if (is.null(hess)) {
        if (is.null(gr)) {
            if (ctrl$ktrace > 0) 
                cat("is.null(gr) is TRUE use numDeriv hessian()\n")
            Hn <- try(hessian(fn, par, ...), silent = TRUE)
            if (class(Hn) == "try-error") {
                if (ctrl$stoponerror) 
                  stop("Unable to compute Hessian using numDeriv::hessian")
            }
            else hessOK <- TRUE
        }
        else {
            if (ctrl$ktrace > 0) 
                cat("is.null(gr) is FALSE use numDeriv jacobian()\n")
            Hn <- try(jacobian(gr, par, ...), silent = TRUE)
            if (class(Hn) == "try-error") {
                if (ctrl$stoponerror) 
                  stop("Unable to compute Hessian using numderiv::jacobian")
            }
            else hessOK <- TRUE
            if (ctrl$ktrace > 0) {
                cat("Hessian from jacobian:")
                print(Hn)
            }
            if (!isSymmetric(Hn)) {
                asym <- sum(abs(t(Hn) - Hn))/sum(abs(Hn))
                asw <- paste("Hn from jacobian is reported non-symmetric with asymmetry ratio ", 
                  asym, sep = "")
                if (ctrl$ktrace) 
                  cat(asw, "\n")
                warning(asw)
                cat("asym, ctrl$asymtol: ", asym, ctrl$asymtol, 
                  "\n")
                if (asym > ctrl$asymtol) {
                  if (ctrl$stoponerror) 
                    stop("Hessian too asymmetric")
                }
                else hessOK <- TRUE
                if (ctrl$ktrace) 
                  cat("Force Hessian symmetric\n")
                else warning("Hessian forced symmetric")
                Hn <- 0.5 * (t(Hn) + Hn)
            }
        }
    }
    else {
        if (ctrl$ktrace > 0) 
            cat("is.null(hess) is FALSE -- trying hess()\n")
        Hn <- try(hess(par, ...), silent = TRUE)
        if (class(Hn) == "try-error") {
            if (ctrl$stoponerror) 
                stop("Hessian evaluation with function hess() failed")
        }
        else hessOK <- TRUE
        if (!isSymmetric(Hn, tol = 0.01 * sqrt(.Machine$double.eps))) {
            asym <- sum(abs(t(Hn) - Hn))/sum(abs(Hn))
            asw <- paste("Hn from hess() is reported non-symmetric with asymmetry ratio ", 
                asym, sep = "")
            if (ctrl$ktrace) 
                cat(asw, "\n")
            warning(asw)
            if (asym > ctrl$asymtol) {
                if (ctrl$stoponerror) 
                  stop("Hessian too asymmetric")
            }
            else hessOK <- TRUE
            if (ctrl$ktrace) 
                cat("Force Hessian symmetric\n")
            else warning("Hessian forced symmetric")
            Hn <- 0.5 * (t(Hn) + Hn)
        }
    }
    if (ctrl$ktrace) 
        print(Hn)
    ansout <- list(gn, Hn, gradOK, hessOK, 0)
    names(ansout) <- c("gn", "Hn", "gradOK", "hessOK", "nbm")
    return(ansout)
}
<bytecode: 0x3a71d30>
<environment: namespace:optextras>
 --- function search by body ---
Function gHgen in namespace optextras has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1