Adaptive Multivariate Integration over Hypercubes

R wrappers around the cubature C library of Steven G. Johnson for adaptive multivariate integration over hypercubes and the Cuba C library of Thomas Hahn for deterministic and Monte Carlo integration. Scalar and vector interfaces for cubature and Cuba routines are provided; the vector interfaces are highly recommended as demonstrated in the package vignette.

Travis-CI BuildStatus CRAN_Status_Badge CoverageStatus

Cubature is an R package for adaptive multivariate integration over hypercubes using deterministic and Monte Carlo methods. The package provides wrappers around two C libraries:

Both scalar and vectorized interfaces are available for all routines. R users will gain a lot by using the vectorization as demonstrated in the included vignette.


Version 2.0 is dedicated to the memory of Kiên Kiêu, one of the original authors of R2Cuba. I (BN) never knew him, but this package derives from his work on R2Cuba.


cubature 2.0.3

  • Fixed up stack overrun in Cuba-4.2/src/divonne/Split.c (lines 119--128 utilizing a flag for first time through loop
  • More cleanup of Makevars

cubature 2.0.2

  • Fixed up uninitialized count for hcubature (Thanks, Ehsan Masoudi)
  • Tentative fix of infinite value for minfluct in Cuba-4.2/src/suave/Integrate.c in lines 197--205. (Thanks, Prof. Brian Ripley)
  • Miscellaneous fixes for compilation on various platforms.
    • Cleaned up Makevars and to remove some unused flags. Tentative fix for solaris in Makevars and Cuba-4.2/src/common/stddecl.c.
    • Removed printing of statefile in all the src/*/Integrate.c routines to avoid segfault on solaris.
    • Added ret_code for return value in call to getloadavg in Cuba-4.2/src/common/Fork.c. Also added an #ifdef SOLARIS for including appropriate header under solaris.
    • Fixed up call to MASTER variadic macro by including dummy argument 0 in Cuba-4.2/src/common/Fork.c, line 146.
    • Replaced multi-statement macro with a do { } while(0) hack.
    • Reworked code around Cuba-4.2/src/divonne/Rule.c checks for key values (lines 593 to 600).
    • Fixed up call to WORKER variadic macro by including dummy argument 0 in Cuba-4.2/src/common/Parallel.c, line 393.
    • Moved #ifdef FRAMECOPY outside in Cuba-4.2/src/common/Parallel.c to avoid embedding directives in macro args, lines 70-80.

cubature 2.0

  • Major update. Integrates Cuba 4.2 library
  • Allows for finite or infinite limits of integration (courtesy of Simon Gaure)
  • Deprecates doChecking argument. Now it does nothing and will be removed in future versions.

cubature 1.4-1

  • Fixed up scale argument to tests to conform to pass checks.
  • Removed any reference to orphaned package R2Cuba and updated vignette with information on imminent 2.0 release.

cubature 1.4

  • Fixed up the C call so that it is re-entrant (brought to my attention by Pierre de Villemereuil). This should be considered a bug fix!

  • Corrected private notes

cubature 1.3-13

cubature 1.3-12

  • Minor typographical and documentation fixes

cubature 1.3-11

  • Merged Manuel Koller's registration for C code and vignette fix for NA.
  • Moved cubature header and exp_cubature headers to inst/include for linking to other packages

cubature 1.3-10

  • Renamed to
  • Removed references to ab-initio website that caused some hassle due to misconfigured site.

cubature 1.3-9

cubature 1.3-8

cubature 1.3-7

  • Registered .Call stuff and removed microbenchmark suggestion in favor of benchr.

cubature 1.3-4

  • Generated smaller pcubature header (clencurt.h) using M = 16 and put back C cubature source in tree.

cubature 1.3-3

  • Moved the cubature-1.0.2 C library to github to avoid hitting the CRAN size limit.

cubature 1.3-2

  • Added vignette showing huge gains due to vectorization

cubature 1.3-1

  • Added pcubature
  • Added vector versions

cubature 1.3-0

  • Moved to SGJ cubature-1.0.2 version.
  • adaptIntegrate and hcubature are aliases
  • hcubature function gains a norm argument that is set to a sensible default so as not to affect depending packages

cubature 1.2-0

  • Moved to Rcpp framework
  • Added tests in preparation for SGJ cubature-1.0.2 version

cubature 1.1-3

  • Roxygenized in preparation for upgrade to newer version of cubature library on abinitio website

cubature 1.1-2

  • Registered native cubature functions adapt_integrate and adapt_integrate_v so that they are directly callable from C (courtesy of Simen Gaure)

cubature 1.1-2

  • Fixed typo in doc for function adaptIntegrate; default value for doChecking was incorrectly stated as TRUE

cubature 1.1-1

  • Added doChecking argument (default FALSE) to save some computation time in evaluating integrand (9% speedup).

cubature 1.1

  • Synced up to SGJ cubature routines dated 2010-10-18 on his website
  • Bugfix: potential memory leak fixed up in heap routine (my oversight!)
  • Routine adaptIntegrate gains ... argument (request of Baptiste Auguie)
  • Corrected radius constant in testFn2 to match cubature output exactly

cubature 1.0

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("cubature") by Balasubramanian Narasimhan, 5 months ago

Report a bug at

Browse source code at

Authors: Balasubramanian Narasimhan [aut, cre] , Manuel Koller [ctb] , Steven G. Johnson [aut] , Thomas Hahn [aut] , Annie Bouvier [aut] , Kiên Kiêu [aut] , Simen Gaure [ctb]

Documentation:   PDF Manual  

Task views: Numerical Mathematics

GPL-3 license

Imports Rcpp

Suggests testthat, knitr, mvtnorm, benchr, rmarkdown

Linking to Rcpp

System requirements: GNU make

Imported by ALTopt, BNSP, DRAYL, GAS, GB2, GPCMlasso, ICAOD, MCMCglmm, MIRES, MMDCopula, MWright, NetSci, NonNorMvtDist, OBASpatial, ODS, Power2Stage, PowerTOST, ProFit, QGglmm, RABR, SurvDisc, TCIU, UPCM, WLinfer, apTreeshape, bivquant, calibrator, clusteredinterference, coga, dbmss, dvmisc, ei, equivalenceTest, fMultivar, highfrequency, inctools, np, planar, pooling, skedastic, statsr, tailDepFun, tseriesEntropy, vines.

Depended on by GRCdata, PCMRS, SphericalCubature, cold, hyper2, optimStrat, symmoments, yuima.

Suggested by FixedPoint, calculus, chebpol, distr6, docopulae, fastR2, genscore, icensBKL, lacunaritycovariance, lfe, mlr3proba, polyCub.

Linked to by robustlmm.

See at CRAN