Running 'brdban.R' [0s]
  Comparing 'brdban.Rout' to 'brdban.Rout.save' ... OK
  Running 'brdbanded.R' [0s]
  Comparing 'brdbanded.Rout' to 'brdbanded.Rout.save' ... OK
  Running 'brdtri.R' [0s]
  Comparing 'brdtri.Rout' to 'brdtri.Rout.save' ... OK
  Running 'brdtrijac.R' [0s]
  Comparing 'brdtrijac.Rout' to 'brdtrijac.Rout.save' ... OK
  Running 'chquad.R' [0s]
  Comparing 'chquad.Rout' to 'chquad.Rout.save' ... OK
  Running 'control-try.R' [169s]
  Running 'dslnex.R' [153s]
  Running 'dslnexCN.R' [168s]
  Running 'dslnexHook.R' [0s]
  Comparing 'dslnexHook.Rout' to 'dslnexHook.Rout.save' ... OK
  Running 'dslnexauto.R' [0s]
  Comparing 'dslnexauto.Rout' to 'dslnexauto.Rout.save' ... OK
  Running 'dslnexjacout.R' [0s]
  Comparing 'dslnexjacout.Rout' to 'dslnexjacout.Rout.save' ... OK
  Running 'dslnexscaled.R' [0s]
  Comparing 'dslnexscaled.Rout' to 'dslnexscaled.Rout.save' ... OK
  Running 'singular1.R' [0s]
  Comparing 'singular1.Rout' to 'singular1.Rout.save' ... OK
  Running 'singular2.R' [0s]
  Comparing 'singular2.Rout' to 'singular2.Rout.save' ... OK
  Running 'singular3.R' [0s]
  Comparing 'singular3.Rout' to 'singular3.Rout.save' ... OK
  Running 'trig.R' [150s]
  Running 'tscalargrad.R' [0s]
  Comparing 'tscalargrad.Rout' to 'tscalargrad.Rout.save' ... OK
  Running 'xcutlip1p2.R' [157s]
  Running 'xnames.R' [0s]
  Comparing 'xnames.Rout' to 'xnames.Rout.save' ... OK
  Running 'xsearchzeros.R' [0s]
  Comparing 'xsearchzeros.Rout' to 'xsearchzeros.Rout.save' ... OK
  Running 'xtestnslv.R' [152s]
Running the tests in 'tests/control-try.R' failed.
Complete output:
  > 
  > library(nleqslv)
  > 
  > # Dennis Schnabel example 6.5.1 page 149
  > f <- function(x) {
  +     y <- numeric(2)
  +     y[1] <- x[1]^2 + x[2]^2 - 2
  +     y[2] <- exp(x[1]-1) + x[2]^3 - 2
  +     y
  + }
  > 
  > # check error handling in control argument
  > try(nleqslv(f,control=list(1e-3)))
  Error in nleqslv(f, control = list(0.001)) : 
    'control' argument must be a named list
  > try(nleqslv(f,control=list(f=1e-3)))
  Error in nleqslv(f, control = list(f = 0.001)) : 
    unknown names in control: 'f'
  > try(nleqslv(f,control=list(f=1e-7,b=1e-3)))
  Error in nleqslv(f, control = list(f = 1e-07, b = 0.001)) : 
    unknown names in control: 'f', 'b'
  > 
  > proc.time()
     user  system elapsed 
     0.17    0.04    0.20 
Running the tests in 'tests/dslnex.R' failed.
Complete output:
  > 
  > library("nleqslv")
  > 
  > # Dennis & Schnabel,1996,"Numerical methods for unconstrained optimization and nonlinear equations", SIAM
  > # example 6.5.1 page 149
  > 
  > dslnex <- function(x) {
  +     y <- numeric(2)
  +     y[1] <- x[1]^2 + x[2]^2 - 2
  +     y[2] <- exp(x[1]-1) + x[2]^3 - 2
  +     y
  + }
  > 
  > jacdsln <- function(x) {
  +     n <- length(x)
  +     Df <- matrix(numeric(n*n),n,n)
  +     Df[1,1] <- 2*x[1]
  +     Df[1,2] <- 2*x[2]
  +     Df[2,1] <- exp(x[1]-1)
  +     Df[2,2] <- 3*x[2]^2
  + 
  +     Df
  + }
  > 
  > xstart <- c(2,0.5)
  > fstart <- dslnex(xstart)
  > xstart
  [1] 2.0 0.5
  > fstart
  [1] 2.2500000 0.8432818
  > 
  > # a solution is c(1,1)
  > 
  > do.print.xf <- FALSE
  > 
  > print.result <- function(z) {
  +     if( do.print.xf ) {
  +         print(z$x)
  +         print(z$fvec)
  +     }
  +     print(z$message)
  +     print(all(abs(z$fvec)<=1e-8))
  + }
  > 
  > # Broyden numerical Jacobian
  > for( z in c("cline", "qline", "gline") ) {  # cubic, quadratic, geometric linesearch
  +     znlq <- nleqslv(xstart, dslnex, global=z,control=list(btol=.01))
  +     print.result(znlq)
  + }
  [1] "Function criterion near zero"
  [1] TRUE
  [1] "Function criterion near zero"
  [1] TRUE
  [1] "Function criterion near zero"
  [1] TRUE
  > 
  > # Broyden numerical Jacobian
  > for( z in c("dbldog","pwldog") ) {  # double dogleg, Powell (single) dogleg
  +     for( delta in c(-1.0, -2.0) ) { # Cauchy step , Newton step
  +         znlq <- nleqslv(xstart, dslnex, global=z, control=list(btol=.01,delta=delta))
  +         print.result(znlq)
  +     }
  + }
  [1] "Function criterion near zero"
  [1] TRUE
  [1] "Function criterion near zero"
  [1] TRUE
  [1] "Function criterion near zero"
  [1] TRUE
  [1] "Function criterion near zero"
  [1] TRUE
  > 
  > # Broyden analytical jacobian
  > for( z in c("dbldog","pwldog") ) {  # double dogleg, Powell (single) dogleg
  +     for( delta in c(-1.0, -2.0) ) { # Cauchy step , Newton step
  +         znlq <- nleqslv(xstart, dslnex, jacdsln, global=z, control=list(btol=.01,delta=delta))
  +         print.result(znlq)
  +     }
  + }
  [1] "Function criterion near zero"
  [1] TRUE
  [1] "Function criterion near zero"
  [1] TRUE
  [1] "Function criterion near zero"
  [1] TRUE
  [1] "Function criterion near zero"
  [1] TRUE
  > 
  > # Newton analytical jacobian
  > for( z in c("dbldog","pwldog") ) {  # double dogleg, Powell (single) dogleg
  +     for( delta in c(-1.0, -2.0) ) { # Cauchy step , Newton step
  +         znlq <- nleqslv(xstart, dslnex, jacdsln, method="Newton", global=z, control=list(btol=.01,delta=delta))
  +         print.result(znlq)
  +     }
  + }
  [1] "Function criterion near zero"
  [1] TRUE
  [1] "Function criterion near zero"
  [1] TRUE
  [1] "Function criterion near zero"
  [1] TRUE
  [1] "Function criterion near zero"
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.21    0.07    0.28 
Running the tests in 'tests/dslnexCN.R' failed.
Complete output:
  > 
  > library("nleqslv")
  > 
  > # Dennis & Schnabel,1996,"Numerical methods for unconstrained optimization and nonlinear equations", SIAM
  > # example 6.5.1 page 149
  > 
  > dslnex <- function(x) {
  +     y <- numeric(2)
  +     y[1] <- x[1]^2 + x[2]^2 - 2
  +     y[2] <- exp(x[1]-1) + x[2]^3 - 2
  +     y
  + }
  > 
  > 
  > xstart <- c(2,0.5)
  > fstart <- dslnex(xstart)
  > xstart
  [1] 2.0 0.5
  > fstart
  [1] 2.2500000 0.8432818
  > 
  > do.print.xf <- TRUE
  > 
  > print.result <- function(z) {
  +     if( do.print.xf ) {
  +         print(z$x)
  +         print(z$fvec)
  +     }
  +     print(z$message)
  +     print(all(abs(z$fvec)<=1e-8))
  + }
  > 
  > sink("dslnexCN-num.txt")
  > for( z in c("dbldog","pwldog") ) {  # double dogleg, Powell (single) dogleg
  +     for( delta in c(-1.0, -2.0) ) { # Cauchy step , Newton step
  +         znlq <- nleqslv(xstart, dslnex, global=z, control=list(btol=.01,delta=delta, trace=1))
  +         print.result(znlq)
  +     }
  + }
  > sink()
  > 
  > sink("dslnexCN-char.txt")
  > for( z in c("dbldog","pwldog") ) {  # double dogleg, Powell (single) dogleg
  +     for( delta in c("cauchy", "newton") ) { # Cauchy step , Newton step
  +         znlq <- nleqslv(xstart, dslnex, global=z, control=list(btol=.01,delta=delta,trace=1))
  +         print.result(znlq)
  +     }
  + }
  > sink()
  > 
  > z1 <- readLines(con="dslnexCN-num.txt")
  > z2 <- readLines(con="dslnexCN-char.txt")
  > 
  > all.equal(z1,z2)
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.21    0.09    0.29 
Running the tests in 'tests/trig.R' failed.
Complete output:
  > 
  > library("nleqslv")
  > 
  > # Trigonometric function
  > trig <- function(x) {
  + 	n <- length(x)
  + 	y <- cos(x)
  + 	s <- sum(y)
  + 	y <- n - s + c(1:n) * (1-y) - sin(x)
  + 
  + 	y
  + }
  > 
  > trigjac <- function(x) {
  + 	n <- length(x)
  + 	J <- matrix(numeric(n*n),n,n)
  + 
  + 	for (p in 1:n) {
  + 		J[,p]  <- sin(x[p])
  + 		J[p,p] <- (p+1) * sin(x[p]) - cos(x[p])
  + 	}
  + 
  + 	J
  + }
  > 
  > do.print.xf <- FALSE
  > 
  > print.result <- function(z) {
  +     if( do.print.xf ) {
  +         print(z$x)
  +         print(z$fvec)
  +     }
  +     print(z$message)
  +     print(all(abs(z$fvec)<=1e-8))
  + }
  > 
  > n <- 10
  > xstart <- rep(1,n)/n
  > fstart <- trig(xstart)
  > 
  > znlm <- nleqslv(xstart, trig, global="dbldog", control=list(trace=0))
  > print.result(znlm)
  [1] "Function criterion near zero"
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.15    0.07    0.21 
Running the tests in 'tests/xcutlip1p2.R' failed.
Complete output:
  > # Steady-State solution for reaction rate equations
  > # Shacham homotopy method (discrete changing of one or more parameters)
  > # M. Shacham: Numerical Solution of Constrained Non-linear algebriac equations
  > # International Journal for Numerical Methods in Engineering, 1986, pp.1455--1481.
  > 
  > # solution should always be > 0
  > 
  > library(nleqslv)
  > 
  > RNGkind(kind="Wichmann-Hill")
  > set.seed(123)
  > 
  > # Problem 2, page 1463/1464
  > 
  > cutlip <- function(x) {
  +     # paper has wrong order of parameters
  +     # use the Fortran program to get the correct values
  + 
  +     # parameter set 2
  +     k1 <-  17.721
  +     k2 <-  3.483
  +     k3 <-  505.051
  +     kr1<-  0.118
  +     kr2<-  0.033
  + 
  +     r <- numeric(6)
  + 
  +     r[1] = 1 - x[1] - k1*x[1]*x[6] + kr1 * x[4]
  +     r[2] = 1 - x[2] - k2*x[2]*x[6] + kr2 * x[5]
  +     r[3] = -x[3] + 2*k3*x[4]*x[5]
  +     r[4] = k1*x[1]*x[6] - kr1*x[4] - k3*x[4]*x[5]
  +     r[5] = 1.5*(k2*x[2]*x[6] - kr2*x[5]) - k3*x[4]*x[5]
  +     r[6] = 1 - x[4] - x[5] - x[6]
  + 
  +     r
  + }
  > 
  > 
  > Nrep <- 50
  > xstart <- matrix(0,nrow=Nrep, ncol=6)
  > xstart[,1] <- runif(Nrep,min=0,max=2)
  > xstart[,2] <- runif(Nrep,min=0,max=1)
  > xstart[,3] <- runif(Nrep,min=0,max=2)
  > xstart[,4] <- runif(Nrep,min=0,max=1)
  > xstart[,5] <- runif(Nrep,min=0,max=1)
  > xstart[,6] <- runif(Nrep,min=0,max=1)
  > 
  > ans <- searchZeros(xstart,cutlip, method="Broyden",global="dbldog")
  > nrow(ans$x)==4
  [1] TRUE
  > all(ans$xfnorm <= 1e-10)
  [1] TRUE
  > 
  > zans <- searchZeros(ans$xstart,cutlip, method="Broyden",global="dbldog")
  > length(zans$idxcvg)==4
  [1] TRUE
  > all(ans$xfnorm == zans$xfnorm)
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.20    0.09    0.28 
Running the tests in 'tests/xtestnslv.R' failed.
Complete output:
  > 
  > library(nleqslv)
  > 
  > # function to replace small number with OK or if not with NZ
  > # this is to avoid differences in the Fnorm column between machines/cpu/os/compilers
  > 
  > # the test is for checking that testnslv (still) works as expected
  > 
  > fixsmall <- function(x) {
  +     z <- ifelse(x < .Machine$double.eps^(2/3), "OK","NZ")
  +     z <- ifelse(is.na(z), "NA", z)
  +     z
  + }
  > 
  > dslnex <- function(x) {
  +     y <- numeric(2)
  +     y[1] <- x[1]^2 + x[2]^2 - 2
  +     y[2] <- exp(x[1]-1) + x[2]^3 - 2
  +     y
  + }
  > xstart <- c(0.5,0.5)
  > fstart <- dslnex(xstart)
  > z <- testnslv(xstart,dslnex)
  > zfn <- z$out[,"Fnorm"]
  > z$out[,"Fnorm"] <- fixsmall(zfn)
  > z
  Call:
  testnslv(x = xstart, fn = dslnex)
  
  Results:
      Method Global termcd Fcnt Jcnt Iter Message Fnorm
  1   Newton  cline      1    7    6    6   Fcrit    OK
  2   Newton  qline      1    7    6    6   Fcrit    OK
  3   Newton  gline      1    9    5    5   Fcrit    OK
  4   Newton pwldog      1    7    6    6   Fcrit    OK
  5   Newton dbldog      1    7    6    6   Fcrit    OK
  6   Newton   hook      1    7    6    6   Fcrit    OK
  7   Newton   none      1    8    8    8   Fcrit    OK
  8  Broyden  cline      1   12    1    9   Fcrit    OK
  9  Broyden  qline      1   12    1    9   Fcrit    OK
  10 Broyden  gline      1   14    1   10   Fcrit    OK
  11 Broyden pwldog      1   12    1   10   Fcrit    OK
  12 Broyden dbldog      1   12    1   10   Fcrit    OK
  13 Broyden   hook      1   12    1   10   Fcrit    OK
  14 Broyden   none      1   13    1   13   Fcrit    OK
  > 
  > # this will encounter an error
  > xstart <- c(2.0,0.5)
  > fstart <- dslnex(xstart)
  > z <- testnslv(xstart,dslnex)
  Error (method=Newton global=none): non-finite value(s) detected in jacobian (row=2,col=1)
  > zfn <- z$out[,"Fnorm"]
  > z$out[,"Fnorm"] <- fixsmall(zfn)
  > z
  Call:
  testnslv(x = xstart, fn = dslnex)
  
  Results:
      Method Global termcd Fcnt Jcnt Iter Message Fnorm
  1   Newton  cline      1   11    7    7   Fcrit    OK
  2   Newton  qline      1   10    7    7   Fcrit    OK
  3   Newton  gline      1   17    7    7   Fcrit    OK
  4   Newton pwldog      1    6    5    5   Fcrit    OK
  5   Newton dbldog      1    6    5    5   Fcrit    OK
  6   Newton   hook      1   11    7    7   Fcrit    OK
  7   Newton   none     NA   NA   NA   NA   ERROR    NA
  8  Broyden  cline      1   17    1   11   Fcrit    OK
  9  Broyden  qline      1   18    1   13   Fcrit    OK
  10 Broyden  gline      1   25    1   11   Fcrit    OK
  11 Broyden pwldog      1   12    1   10   Fcrit    OK
  12 Broyden dbldog      1   12    1   10   Fcrit    OK
  13 Broyden   hook      1   16    1   12   Fcrit    OK
  14 Broyden   none      4   20    1   20 Maxiter    NZ
  > 
  > proc.time()
     user  system elapsed 
     0.25    0.09    0.28