fntl: Numerical Tools for Rcpp and Lambda Functions

article
programming
Published

July 16, 2024

Lambda functions were added to C++ in the C++11 specification. They are functions which can be defined on the fly in the course of a program, can make use of variables in the environment within their body, and be passed as arguments to other functions. Use of lambdas may be especially appealing for Rcpp programmers who are accustomed to working with function objects in R but occasionally need C++ when performance becomes a concern.

The objective of the R package fntl (Raim 2024a) is to facilitate programming in Rcpp with lambda functions by providing an API to routinely needed numerical tools such as integration, root-finding, and optimization. Such functions require one or more functions as a primary argument; these are supplied as lambdas to fntl. Where possible, the fntl API utilizes methods exposed from the R API so that the same numerical methods are used as in R. In cases where methods are not exposed from the R API, fntl implements methods that are intended to be comparable. A detailed guide to the fntl API is provided in the package vignette (Raim 2024b).

fntl package

References

Raim, Andrew M. 2024a. fntl: Numerical Tools for Rcpp and Lambda Functions. https://github.com/andrewraim/fntl.
———. 2024b. fntl: Numerical Tools for Rcpp and Lambda Functions.” Research Report Series: Computing #2024-01. Center for Statistical Research; Methodology, U.S. Census Bureau. https://www.census.gov/library/working-papers/2024/adrm/RRC2024-01.html.