Linking R's math libraries in C++
I’ve been a regular user of R and I really like the simplicity with which one can sample data points from a particular distribution, fit statistical models etc.
Recently I had to write some code in C++ which would compute the
density under a beta function given the shape parameters(alpha
and beta). To do this in R, I would use the dbeta function which
would take in x, alpha, beta as inputs and compute the density at
point x. I wanted similar usage in C++. It appears that most of the R
math functions have an underlying C library which was pulled out by
Julia developers and then pulled into a git repository
by someone here.
This was essentially what I needed, the code seems to be under the GPL. I forked the repo and wrote a simple CMakeLists.txt which would compile the static library using CMake. This is here.