Академический Документы
Профессиональный Документы
Культура Документы
Version 0.9.0 of the Rcpp package is now on CRAN and its mirrors. This
release marks another step in the development of the package, and a few key
points are highlighted below. More details are in the NEWS and ChangeLog
files included in the package.
- a rich API covering all core R data types including vectors, matrices,
functions, environments, ... (with the exeception of factors
which are less useful in C++)
- support for the legacy 'classic' Rcpp is now provided by the RcppClassic
package which is being released concurrently with Rcpp 0.9.0
Several key features were added during the 0.8.* cycles and are described below.
which deploys the sugar 'ifelse' function modeled after the corresponding R
function. Another simple example is
where use the sugar function 'sapply' to sweep a simple C++ function which
operates elementwise across the supplied vector.
Rcpp modules are inspired by Boost.Python and make exposing C++ functions or
classes to R even easier. A first illustration is provided by this simple
C++ code snippet
RCPP_MODULE(yada){
using namespace Rcpp ;
function( "hello", &hello ) ;
}
Rcpp modules are also described in more detail in their own vignette.
===== Reference Classes =====
The RcppArmadillo package permits use of the advanced C++ library 'Armadillo,
a C++ linear algebra library aiming towards a good balance between speed and
ease of use, providing integer, floating point and complex matrices and
vectors with lapack / blas support via R. Armadillo uses templates for a
delayed evaluation approach is employed (during compile time) to combine
several operations into one and reduce (or eliminate) the need for
temporaries. Armadillo is useful if C++ has been decided as the language of
choice, rather than another language like Matlab or Octave, and aims to be
as expressive as the former. Via Rcpp and RcppArmadillo, R users now have
easy access to this functionality. Examples are provided in the RcppArmadillo
package.
The RcppGSL package permits easy use of the GNU Scientific Library (GSL), a
collection of numerical routines for scientifc computing. It is particularly
useful for C and C++ programs as it provides a standard C interface to a wide
range of mathematical routines such as special functions, permutations,
combinations, fast fourier transforms, eigensystems, random numbers,
quadrature, random distributions, quasi-random sequences, Monte Carlo
integration, N-tuples, differential equations, simulated annealing, numerical
differentiation, interpolation, series acceleration, Chebyshev
approximations, root-finding, discrete Hankel transforms physical constants,
basis splines and wavelets. There are over 1000 functions in total with an
extensive test suite. The RcppGSL package provides an easy-to-use interface
between GSL data structures and R using concepts from Rcpp. The RcppGSL
package also contains a vignette with more documentation.
Packages still using code interfacing the initial 'classic' Rcpp API are
encouraged to migrate to the new API. Should a code transition not be
possible, backwards compatibility is provided by the RcppClassic package
released alongside Rcpp 0.9.0. By including RcppClassic.h and building
against the RcppClassic package and library, vintage code can remain
operational using the classic API. The short vignette in the RcppClassic
package has more details.
The package contains a total of eight vignettes the first of which provides a
short and succinct introduction to the Rcpp package along with several
motivating examples.