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. > # test results in these files are indicated for > # Windows WP Professional v5.1 SP2 > # Linux32 Ubuntu 7.10 desktop 32 bit kernel 2.6.22-14-generic on Intel Pentium > # Linux64 Gentoo 64 bit kernel 2.6.17-gentoo-r8 on AMD 64 X2 > > 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 brown.f ...\n") BB test brown.f ... > > brown.f <- function(x) { + p <- x + n <- length(p) + odd <- seq(1,n,by=2) + even <- seq(2,n,by=2) + sum((p[odd]^2)^(p[even]^2 + 1) + (p[even]^2)^(p[odd]^2 + 1)) + } > > #p0 <- rnorm(500,sd=2) # this set fails in optim, so > p0 <- rnorm(50,sd=2) > system.time(ans.spg <- spg(par=p0, fn=brown.f, control=list(maxit=2500)))[1] iter: 0 f-value: 3.15394862062e+22 pgrad: 6.49725878636e+23 iter: 10 f-value: 259058613.368 pgrad: 1195397396.68 iter: 20 f-value: 325936.123185 pgrad: 1252880.9224 iter: 30 f-value: 2140.1416147 pgrad: 1396.58363423 iter: 40 f-value: 93.0014118948 pgrad: 6.45816697897 user.self 0.15 > > z <- sum(ans.spg $par) > #good <- -3.336592920523865e-05 > good <- -2.5e-06 # windows > #on Windows -3.337359033283664e-05 > #on Linux64 -3.383384527412175e-05 > #on Linux32 -3.336592920523865e-05 > print(z, digits=16) [1] -2.044502465647949e-06 > if(any(abs(good - z) > 1e-5)) stop("BB test brown.f a FAILED") > > > proc.time() user system elapsed 0.34 0.01 0.34