FastAD is a header-only C++ template library for automatic differentiation supporting both forward and reverse mode. It utilizes the latest features in C++17 and expression templates for efficient computation. See the FastAD repo for more.
This package brings this header-only library to R so that other R
user can access it simply by adding
LinkingTo: RcppFastAD
.
Three examples, taken from FastAS, are included. We can look at the
black_scholes()
one here:
> library(RcppFastAD)
> black_scholes()
value delta vega rho theta56.5136 0.773818 9.05493 2.03321 275.730
call 51.4109 -0.226182 9.05493 -6.17753 274.481
put >
This evaluates a put and a call struck at 100 with spot at 105, and some default values (all taken from an example included with Boost). The values can be set in the call too. Returned all the value along the first partial derivatives relative to spot, volatility, short rate and time to maturity—which are all calculated using automatic differentiation.
(FastAD has a focus on speed leading to some design choices that make taking second derivatives harder. So no ‘gamma’ here.)
The package is complete and contains a mature version of FastAD.
Any problems, bug reports, or features requests for the package can be submitted and handled most conveniently as Github issues in the repository.
Before submitting pull requests, it is frequently preferable to first discuss need and scope in such an issue ticket. See the file Contributing.md (in the Rcpp repo) for a brief discussion.
For the R package, Dirk Eddelbuettel.
For everything pertaining to FastAD: James Yang.