* using log directory ‘/data/localhost/ripley/R/packages/tests-vg/DPQ.Rcheck’ * using R Under development (unstable) (2026-12-01 r91013) * using platform: x86_64-pc-linux-gnu * R was compiled by gcc (GCC) 16.2.1 20261029 (Red Hat 16.2.1-3) GNU Fortran (GCC) 16.2.1 20261029 (Red Hat 16.2.1-3) * running under: Fedora Linux 44 (Server Edition) * using session charset: UTF-8 * current time: 2026-12-01 21:14:07 UTC * using options ‘--use-valgrind --no-stop-on-test-error’ * checking for file ‘DPQ/DESCRIPTION’ ... OK * this is package ‘DPQ’ version ‘0.6-2’ * package encoding: UTF-8 * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking whether package ‘DPQ’ can be installed ... [6s/11s] OK * used C compiler: ‘gcc (GCC) 16.2.1 20261029 (Red Hat 16.2.1-3)’ * used Fortran compiler: ‘GNU Fortran (GCC) 16.2.1 20261029 (Red Hat 16.2.1-3)’ * checking package directory ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking compiled code ... OK * checking usage of KIND in Fortran files ... OK * checking installed files from ‘inst/doc’ ... OK * checking files in ‘vignettes’ ... OK * checking examples ... [7m/10m] OK * checking tests ... Running ‘bd0-tst.R’ [385s/549s] Running ‘chisq-nonc-ex.R’ [6m/10m] Running ‘dgamma-tst.R’ [20s/31s] Running ‘dnbinom-tst.R’ [273s/415s] Running ‘dnchisq-tst.R’ [11s/17s] Running ‘dt-ex.R’ [190s/284s] Running ‘expm1x-tst.R’ [56s/83s] Running ‘hyper-dist-ex.R’ [7m/10m] Running ‘log4p1p-exp.R’ [60s/94s] Running ‘pnbeta-tst.R’ [11s/19s] Running ‘pnt-prec.R’ [99s/155s] Running ‘pow-tst.R’ [82s/177s] Running ‘ppois-ex.R’ [31s/72s] Running ‘pqnorm_extreme.R’ [109s/266s] Running ‘qPoisBinom-ex.R’ [20s/45s] Running ‘qbeta-dist.R’ [95s/167s] Running ‘qbeta-tst.R’ [11s/20s] Running ‘qgamma-ex.R’ [237s/382s] Running ‘stirlerr-tst.R’ [117s/186s] Running ‘t-nonc-tst.R’ [280s/435s] Running ‘wienergerm-pchisq-tst.R’ [10s/17s] Running ‘wienergerm_nchisq.R’ [74s/122s] [49m/79m] ERROR Running the tests in ‘tests/stirlerr-tst.R’ failed. Complete output: > #### Testing stirlerr() > #### =================== {previous 2nd part of this, now -->>> ./bd0-tst.R <<<--- > require(DPQ) Loading required package: DPQ > for(pkg in c("Rmpfr", "DPQmpfr")) + if(!requireNamespace(pkg)) { + cat("no CRAN package", sQuote(pkg), " ---> no tests here.\n") + q("no") + } Loading required namespace: Rmpfr Loading required namespace: DPQmpfr > require("Rmpfr") Loading required package: Rmpfr Loading required package: gmp Attaching package: 'gmp' The following objects are masked from 'package:base': %*%, apply, crossprod, matrix, tcrossprod C code of R package 'Rmpfr': GMP using 64 bits per limb Attaching package: 'Rmpfr' The following object is masked from 'package:gmp': outer The following object is masked from 'package:DPQ': log1mexp The following objects are masked from 'package:stats': dbinom, dchisq, dgamma, dnbinom, dnorm, dpois, dt, pgamma, pnorm The following objects are masked from 'package:base': cbind, pmax, pmin, rbind > > source(system.file(package="DPQ", "test-tools.R", mustWork=TRUE)) > ## => showProc.time(), ... list_() , loadList() , readRDS_() , save2RDS(), matplotB() > ##_ options(conflicts.policy = list(depends.ok=TRUE, error=FALSE, warn=FALSE)) > require(sfsmisc) # masking 'list_' *and* gmp's factorize(), is.whole() Loading required package: sfsmisc Attaching package: 'sfsmisc' The following object is masked _by_ '.GlobalEnv': list_ The following objects are masked from 'package:gmp': factorize, formatN, is.whole > ##_ options(conflicts.policy = NULL) > > ## plot1cuts() , etc: ---> ../inst/extraR/relErr-plots.R <<<<<<< > ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > source(system.file(package="DPQ", "extraR", "relErr-plots.R", mustWork=TRUE)) > > do.pdf <- TRUE # (manually) > do.pdf <- !dev.interactive(orNone = TRUE) > do.pdf [1] TRUE > if(do.pdf) { + pdf.options(width = 9, height = 6.5) # for all pdf plots {9/6.5 = 1.38 ; 4/3 < 1.38 < sqrt(2) [A4] + pdf("stirlerr-tst.pdf") + } > > showProc.time() Time (user system elapsed): 1.39 0.007 2.5 > (doExtras <- DPQ:::doExtras()) [1] FALSE > (noLdbl <- (.Machine$sizeof.longdouble <= 8)) ## TRUE when --disable-long-double or 'M1mac' .. [1] FALSE > (M.mac <- grepl("aarch64-apple", R.version$platform)) # Mac with M1, M2, ... proc [1] FALSE > > abs19 <- function(r) pmax(abs(r), 1e-19) # cut |err| to positive {for log-plots} > > options(width = 100, nwarnings = 1e5, warnPartialMatchArgs = FALSE) > > > > ##=== Really, dpois_raw() and dbinom_raw() *both* use stirlerr(x) for "all" 'x > 0' > ## ~~~~~~~~~~~ ~~~~~~~~~~~~ =========== ===== ! > > ## below, 6 "it's okay, but *far* from perfect:" ===> need more terms in stirlerr() [ > ## April 20: MM added more terms up to S10; 2024-01: up to S12 ..helps a little only > x <- lseq(1/16, 6, length=2048) > system.time(stM <- DPQmpfr::stirlerrM(Rmpfr::mpfr(x,2048))) # 1.7 sec elapsed user system elapsed 66.492 0.153 99.934 > plot(x, stirlerr(x, use.halves=FALSE) - stM, type="l", log="x", main="absolute Error") > plot(x, stirlerr(x, use.halves=FALSE) / stM - 1, type="l", log="x", main="relative Error") > plot(x, abs(stirlerr(x, use.halves=FALSE) / stM - 1), type="l", log="xy",main="|relative Error|") > drawEps.h(-(52:50)) > ## lgammacor() does *NOT* help, as it is *designed* for x >= 10 ... (but is interesting there) > ## > ## ==> Need another chebyshev() or rational-approx. for x in [.1, 7] or so !! > > ##=============> see also ../Misc/stirlerr-trms.R <=============== > ## ~~~~~~~~~~~~~~~~~~~~~~~ > > cutoffs <- c(15,35,80,500) # cut points, n=*, in the stirlerr() "algorithm" > ## > n <- c(seq(1,15, by=1/4),seq(16, 25, by=1/2), 26:30, seq(32,50, by=2), seq(55,1000, by=5), + 20*c(51:99), 50*(40:80), 150*(27:48), 500*(15:20)) > st.n <- stirlerr(n, "R3")# rather use.halves=TRUE; but here , use.halves=FALSE > plot(st.n ~ n, log="xy", type="b") ## looks good now (straight line descending {in log-log !} > nM <- mpfr(n, 2048) > st.nM <- stirlerr(nM, use.halves=FALSE) ## << on purpose > all.equal(asNumeric(st.nM), st.n)# TRUE [1] TRUE > all.equal(st.nM, as(st.n,"mpfr"))# .. difference: 3.381400e-14 was 1.05884.........e-15 [1] "Mean relative difference: 3.317339e-14" > all.equal(roundMpfr(st.nM, 64), as(st.n,"mpfr"), tolerance=1e-16)# (ditto) [1] "Mean relative difference: 3.317339e-14" > > > ## --- Look at the direct formula -- why is it not good for n ~= 5 ? > ## > ## Preliminary Conclusions : > ## 1. there is *some* cancellation even for small n (how much?) > ## 2. lgamma1p(n) does really not help much compared to lgamma(n+1) --- but a tiny bit in some cases > > ### 1. Investigating lgamma1p(n) vs lgamma(n+1) for n < 1 ============================================= > > ##' @title Relative Error of lgamma(n+1) vs lgamma1p() vs MM's stirlerrD2(): > ##' @param n numeric, typically n << 1 > ##' @param precBits > ##' @return relative error WRT mpfr(n, precBits) > ##' @author Martin Maechler > relE.lgam1 <- function(n, precBits = if(doExtras) 1024 else 320) { + M_LN2PI <- 1.837877066409345483 # ~ log(2*Const("pi",60)); very slightly more accurate than log(2*pi) + st <- lgamma(n +1) - (n +0.5)*log(n) + n - M_LN2PI/2 + st. <- lgamma1p(n) - (n +0.5)*log(n) + n - M_LN2PI/2 # "lgamma1p" + st2 <- lgamma(n) + n*(1-(l.n <- log(n))) + (l.n - M_LN2PI)/2 # "MM2" + st0 <- -(l.n + M_LN2PI)/2 # "n0" + nM <- mpfr(n, precBits) + stM <- lgamma(nM+1) - (nM+0.5)*log(nM) + nM - log(2*Const("pi", precBits))/2 + ## stM <- roundMpfr(stM, 128) + cbind("R3" = asNumeric(relErrV(stM, st)) + , "lgamma1p"= asNumeric(relErrV(stM, st.)) + , "MM2" = asNumeric(relErrV(stM, st2)) + , "n0" = asNumeric(relErrV(stM, st0)) + ) + } > > n <- 2^-seq.int(1022, 1, by = -(if(doExtras) 1/4 else 9/4)) > relEx <- relE.lgam1(n) > showProc.time() Time (user system elapsed): 87.803 0.181 134.351 > > ## Is *equivalent* to 'new' stirlerr_simpl(n version = *) [not for though, see 'relEmat']: > (simpVer <- eval(formals(stirlerr_simpl)$version)) [1] "R3" "lgamma1p" "MM2" "n0" > if(is.null(simpVer)) { warning("got wrong old version of package 'DPQ':") + print(packageDescription("DPQ")) + stop("invalid outdated version package 'DPQ'") + } > stir.allS <- function(n) sapply(simpVer, function(v) stirlerr_simpl(n, version=v)) > stirS <- stir.allS(n) # matrix > nM <- mpfr(n, 256) # "high" precision = 256 should suffice! > stirM <- stirlerr(nM) > releS <- asNumeric(relErrV(stirM, stirS)) > all.equal(relEx, releS, tolerance = 0) # see TRUE on Linux [1] "Mean relative difference: 4.20563e-15" > stopifnot(all.equal(relEx, releS, tolerance = if(noLdbl) 2e-15 else 1e-15)) Error: relEx and releS are not equal: Mean relative difference: 4.20563e-15 Execution halted ==57605== ==57605== HEAP SUMMARY: ==57605== in use at exit: 104,912,245 bytes in 32,986 blocks ==57605== total heap usage: 1,610,674 allocs, 1,577,688 frees, 432,451,526 bytes allocated ==57605== ==57605== LEAK SUMMARY: ==57605== definitely lost: 0 bytes in 0 blocks ==57605== indirectly lost: 0 bytes in 0 blocks ==57605== possibly lost: 0 bytes in 0 blocks ==57605== still reachable: 104,912,245 bytes in 32,986 blocks ==57605== suppressed: 0 bytes in 0 blocks ==57605== Reachable blocks (those to which a pointer was found) are not shown. ==57605== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==57605== ==57605== For lists of detected and suppressed errors, rerun with: -s ==57605== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) * checking package vignettes ... OK * checking re-building of vignette outputs ... [24s/40s] OK * DONE Status: 1 ERROR See ‘/data/localhost/ripley/R/packages/tests-vg/DPQ.Rcheck/00check.log’ for details. Command exited with non-zero status 1 Time 1:30:39, 3388.16 + 23.84