A previous post showed how to compute eigenvalues using the Armadillo library via RcppArmadillo. Here, we do the same using Eigen and the RcppEigen package. #include <RcppEigen.h> // ] using Eigen::Map; ...

A previous post showed how to compute eigenvalues using the Armadillo library via RcppArmadillo. Here, we do the same using Eigen and the RcppEigen package. #include <RcppEigen.h> // ] using Eigen::Map; ...

Yesterday’s post started to explore the nice additions which the new C++11 standard is bringing to the language. One particularly interesting feature are lambda functions which resemble the anonymous functions R programmers have enjoyed all along...

The recent release of the C++11 standard has brought a lot of attention to the new language features. Rcpp, as a CRAN package, follows CRAN policy in not (yet!!) supporting the standard for its purported non-portable status. Even as of the current g++ ...

This is a quick example of how you might use Rcpp to send and receive R ‘strings’ to and from R. We’ll demonstrate this with a few operations. Sort a String with R Note that we can do this in R in a fairly fast way: my_strings <-...

The Writing R Extensions manual, which provides the gold standard of documentation as far as extending R goes, suggests to use Rprintf and REprintf for output (from C/C++ code) as these are matched to the usual output and error streams maintained by R ...

Since the 0.10.* release series, Rcpp contains a new sugar function clamp which can be used to limit vectors to both a minimum and maximim value. This recent StackOverflow question permitted clamp to shine. We retake some of the answers, including the ...

First, let us consider a running sum function in pure R. To get started, I looked at the source code of the TTR package to see the algorithm used in runSum. The runSum function uses a Fortran routine to compute the running/rolling sum of a vector. The ...

Sine the 0.10.2 release, Rcpp contains an internal class Timer which can be used for fine-grained benchmarking. Romain motivated Timer in a post to the mailing * list where Timer is used to measure the different components of the costs of random number...

At its very essence, Rcpp permits easy access to native R objects at the C++ level. R objects can be simple vectors, list or matrices; compound data structures created from these; objects of S3, S4 or Reference Class vintage; or language objects a...

Today a (slightly confused) question on StackOverflow wondered how to access R’s facilities for eigenvalues calculations from C code. For this, we need to step back and consider how this is done. In fact, R farms the calculation out to the BLAS....