R Under development (unstable) (2026-02-10 r89394 ucrt) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > options(digits=12) > if(!require("BB"))stop("this test requires package BB.") Loading required package: BB > if(!require("setRNG"))stop("this test requires setRNG.") Loading required package: setRNG > > # Use a preset seed so test values are reproducable. > test.rng <- list(kind="Wichmann-Hill", normal.kind="Box-Muller", seed=c(979,1479,1542)) > old.seed <- setRNG(test.rng) > > ########## > cat("BB test chen.f ...\n") BB test chen.f ... > > chen.f <- function(x) { + v <- log(x) + exp(x) + f <- (v - sqrt(v^2 + 5e-04))/2 + sum (f * f) + } > > p0 <- rexp(50) > system.time(ans.spg <- spg(par=p0, fn=chen.f, lower=0))[1] iter: 0 f-value: 31.160868304 pgrad: 1735.79084823 iter: 10 f-value: 0.0003302739274 pgrad: 0.00619920677888 iter: 20 f-value: 6.04773591035e-06 pgrad: 1.43825105414e-05 user.self 0.03 > > z <- sum(ans.spg$par) > good <- 61.9720512703 > print(z, digits=16) [1] 61.97205126995098 > if(any(abs(good - z) > 1e-7)) stop("BB test chen.f a FAILED") > > > proc.time() user system elapsed 0.17 0.04 0.20