Rcpp 0.10.0

[This article was first published on Thinking inside the box , and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Rcpp release 0.10.0 is now on CRAN and being uploaded to Debian.

This is a new feature release, and we are very exciting about the changes, notably Rcpp attributes which make using C++ from R even easier than inline (see below as well as the new vignette for details and first examples), the extensions to Rcpp modules (see below) and more as for example new Rcpp sugar functions, a new error output device syncing to R, and a new namespace R> for the statistical functions from Rmath.h.

The complete NEWS entry for 0.10.0 is below; more details are in the ChangeLog file in the package and on the Rcpp Changelog page.

Changes in Rcpp version 0.10.0 (2012-11-13)

  • Support for C++11 style attributes (embedded in comments) to enable use of C++ within interactive sessions and to automatically generate module declarations for packages:

    • Rcpp::export attribute to export a C++ function to R

    • sourceCpp() function to source exported functions from a file

    • cppFunction() and evalCpp() functions for inline declarations and execution

    • compileAttribtes() function to generate Rcpp modules from exported functions within a package

    • Rcpp::depends attribute for specifying additional build dependencies for sourceCpp()

    • Rcpp::interfaces attribute to specify the external bindings compileAttributes() should generate (defaults to R-only but a C++ include file using R_GetCCallable can also be generated)

    • New vignette “Rcpp-attribute”

  • Rcpp modules feature set has been expanded:

    • Functions and methods can now return objects from classes that are exposed through modules. This uses the make_new_object template internally. This feature requires that some class traits are declared to indicate Rcpp’s wrap/as system that these classes are covered by modules. The macro RCPP_EXPOSED_CLASS and RCPP_EXPOSED_CLASS_NODECL can be used to declared these type traits.

    • Classes exposed through modules can also be used as parameters of exposed functions or methods.

    • Exposed classes can declare factories with “.factory”. A factory is a c++ function that returns a pointer to the target class. It is assumed that these objects are allocated with new on the factory. On the R side, factories are called just like other constructors, with the “new” function. This feature allows an alternative way to construct objects.

    • “converter” can be used to declare a way to convert an object of a type to another type. This gets translated to the appropriate “as” method on the R side.

    • Inheritance. A class can now declare that it inherits from another class with the .derives( “Parent” ) notation. As a result the exposed class gains methods and properties (fields) from its parent class.

  • New sugar functions:

    • which_min implements which.min. Traversing the sugar expression and returning the index of the first time the minimum value is found.

    • which_max idem

    • unique uses unordered_set to find unique values. In particular, the version for CharacterVector is found to be more efficient than R’s version

    • sort_unique calculates unique values and then sorts them.

  • Improvements to output facilities:

    • Implemented sync() so that flushing output streams works

    • Added Rcerr output stream (forwarding to REprintf)

  • Provide a namespace ‘R’ for the standalone Rmath library so that Rcpp users can access those functions too; also added unit tests

  • Development releases sets variable RunAllRcppTests to yes to run all tests (unless it was alredy set to ‘no’); CRAN releases do not and still require setting – which helps with the desired CRAN default of less testing at the CRAN server farm.

Thanks to CRANberries, you can also look at a diff to the previous release 0.9.15. As always, even fuller details are on the Rcpp Changelog page and the Rcpp page which also leads to the downloads, the browseable doxygen docs and zip files of doxygen output for the standard formats. A local directory has source and documentation too. Questions, comments etc should go to the rcpp-devel mailing list off the R-Forge page

Update: One link corrected.

To leave a comment for the author, please follow the link and comment on their blog: Thinking inside the box .

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)