SlideShare a Scribd company logo
Rcpp11
Romain François
romain@r-enthusiasts.com @romain_francois
Rcpp11
• Targets C++11
• Smaller code base (than Rcpp)
• Header only
Rcpp11 useR2014
#include <Rcpp.h>
!
// [[Rcpp::export]]
int foo(){
return 2 ;
}
Rcpp
Rcpp11
0 1 2 3 4
Less complexity -> faster compiles
!
Some examples
NumericVector constructors
// C++ uniform initialization
NumericVector x = {1.0, 2.0, 3.0} ;
!
// init with given size
NumericVector y( 2 ) ; // data is not initialized
NumericVector y( 2, 3.0 ) ; // initialize all to 3.0
!
// fuse several vectors (similar to c in R)
NumericVector z = fuse(x, y) ;
NumericVector z = fuse(x, y, 3.0) ;
create
NumericVector x = {1.0, 2.0, 3.0} ;
!
// old school NumericVector::create (Rcpp style).
NumericVector x = NumericVector::create(1.0, 2.0, 3.0) ;
NumericVector x = NumericVector::create(
_["a"] = 1.0, _["b"] = 2.0, _["c"] = 3.0
) ;
!
!// create as a free function. Rcpp11 style
NumericVector x = create(1.0, 2.0, 3.0) ;
NumericVector x = create(
_["a"] = 1.0, _["b"] = 2.0, _["c"] = 3.0
) ;
sugar
#include <Rcpp11>
!
// [[export]]
NumericVector foo( NumericVector x ){
return sqrt(exp(x)) + 1.0 ;
}
!
/*** R
foo( c(1,2,3) )
# [1] 2.648721 3.718282 5.481689
*/
sapply + lambda
sapply + lambda
#include <Rcpp11>
!
// [[export]]
NumericVector foo( NumericVector x ){
return sapply(x, [](double d){
return exp(d * 2) ;
});
}
x <- 1:3
sapply( x, function(d){
exp(d*2) ;
})
sapply + lambda + …
#include <Rcpp11>
!
// [[export]]
NumericVector foo( NumericVector x ){
auto fun = [](double d, double y, double z){
return exp(d * y) + z ;
} ;
return sapply(x, fun, 3.0, 4.6);
}
x <- 1:3
sapply( x, function(d, y, z){
exp(d*y) + z ;
}, 3.0, 4.6 )
Rcpp11 release cycle
• Available from CRAN:
!
• Evolves quickly. Get it from github
!
• Next Release: 3.1.1 (same time as R 3.1.1)
> install.packages( "Rcpp11" )
> install_github( "Rcpp11/Rcpp11" )
attributes companion package
• Standalone impl of Rcpp attributes
[[Rcpp::export]], sourceCpp, compileAttributes
!
• Only available from github:
> install_github( "Rcpp11/attributes" )
Use Rcpp11 in your package
• Write your .cpp files
#include <Rcpp11>
!
// [[export]]
void foo( … ) { … } // your code
SystemRequirements: C++11
LinkingTo: Rcpp11
library(attributes)
compileAttributes( "mypkg" )
• Express dep on C++11 and Rcpp11 headers
• Generate the boiler plate
Romain François
romain@r-enthusiasts.com @romain_francois
Questions ?

More Related Content

What's hot (20)

PDF
CL metaprogramming
dudarev
 
PDF
All I know about rsc.io/c2go
Moriyoshi Koizumi
 
PDF
Libtcc and gwan
DaeMyung Kang
 
DOC
VLSI Sequential Circuits II
Gouthaman V
 
PDF
Exploiting vectorization with ISPC
Roberto Agostino Vitillo
 
PDF
3 rd animation
divyalakshmi77
 
DOCX
timingExercise
Amrita Singh
 
PPT
FSE 2008
ericbodden
 
PDF
Go Concurrency
jgrahamc
 
PDF
Clojure+ClojureScript Webapps
Falko Riemenschneider
 
PDF
Modern c++ Memory Management
Alan Uthoff
 
PDF
Golang Channels
Joris Bonnefoy
 
PPTX
.NET Core Summer event 2019 in Brno, CZ - Async demystified -- Karel Zikmund
Karel Zikmund
 
PDF
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
OdessaJS Conf
 
PDF
Why my Go program is slow?
Inada Naoki
 
PDF
GoでKVSを書けるのか
Moriyoshi Koizumi
 
PDF
Faster Python, FOSDEM
Victor Stinner
 
PDF
C++ Programming - 2nd Study
Chris Ohk
 
PDF
C c++-meetup-1nov2017-autofdo
Kim Phillips
 
PDF
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
OdessaJS Conf
 
CL metaprogramming
dudarev
 
All I know about rsc.io/c2go
Moriyoshi Koizumi
 
Libtcc and gwan
DaeMyung Kang
 
VLSI Sequential Circuits II
Gouthaman V
 
Exploiting vectorization with ISPC
Roberto Agostino Vitillo
 
3 rd animation
divyalakshmi77
 
timingExercise
Amrita Singh
 
FSE 2008
ericbodden
 
Go Concurrency
jgrahamc
 
Clojure+ClojureScript Webapps
Falko Riemenschneider
 
Modern c++ Memory Management
Alan Uthoff
 
Golang Channels
Joris Bonnefoy
 
.NET Core Summer event 2019 in Brno, CZ - Async demystified -- Karel Zikmund
Karel Zikmund
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
OdessaJS Conf
 
Why my Go program is slow?
Inada Naoki
 
GoでKVSを書けるのか
Moriyoshi Koizumi
 
Faster Python, FOSDEM
Victor Stinner
 
C++ Programming - 2nd Study
Chris Ohk
 
C c++-meetup-1nov2017-autofdo
Kim Phillips
 
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
OdessaJS Conf
 

Similar to Rcpp11 useR2014 (20)

PDF
Rcpp11
Romain Francois
 
PDF
R and C++
Romain Francois
 
PDF
Extend R with Rcpp!!!
mickey24
 
PDF
R and cpp
Romain Francois
 
PDF
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
PyData
 
PDF
ClojureScript loves React, DomCode May 26 2015
Michiel Borkent
 
PPTX
Chp7_C++_Functions_Part1_Built-in functions.pptx
ssuser10ed71
 
PDF
Rcpp: Seemless R and C++
Romain Francois
 
PDF
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
GeeksLab Odessa
 
PDF
Boosting Developer Productivity with Clang
Samsung Open Source Group
 
PDF
Rcpp: Seemless R and C++
Romain Francois
 
PDF
Меняем javascript с помощью javascript
Pavel Volokitin
 
PDF
Refactoring to Macros with Clojure
Dmitry Buzdin
 
PPTX
How to add an optimization for C# to RyuJIT
Egor Bogatov
 
PPTX
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Data Con LA
 
PDF
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
ScyllaDB
 
PDF
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
Functional Thursday
 
PDF
SCIPY-SYMPY.pdf
FreddyGuzman19
 
PDF
JavaScript 2016 for C# Developers
Rick Beerendonk
 
PPT
Cpp tutorial
Vikas Sharma
 
R and C++
Romain Francois
 
Extend R with Rcpp!!!
mickey24
 
R and cpp
Romain Francois
 
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
PyData
 
ClojureScript loves React, DomCode May 26 2015
Michiel Borkent
 
Chp7_C++_Functions_Part1_Built-in functions.pptx
ssuser10ed71
 
Rcpp: Seemless R and C++
Romain Francois
 
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
GeeksLab Odessa
 
Boosting Developer Productivity with Clang
Samsung Open Source Group
 
Rcpp: Seemless R and C++
Romain Francois
 
Меняем javascript с помощью javascript
Pavel Volokitin
 
Refactoring to Macros with Clojure
Dmitry Buzdin
 
How to add an optimization for C# to RyuJIT
Egor Bogatov
 
Big Data Day LA 2016/ Hadoop/ Spark/ Kafka track - Iterative Spark Developmen...
Data Con LA
 
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
ScyllaDB
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
Functional Thursday
 
SCIPY-SYMPY.pdf
FreddyGuzman19
 
JavaScript 2016 for C# Developers
Rick Beerendonk
 
Cpp tutorial
Vikas Sharma
 
Ad

More from Romain Francois (14)

PDF
R/C++
Romain Francois
 
PDF
dplyr and torrents from cpasbien
Romain Francois
 
PDF
dplyr use case
Romain Francois
 
PDF
dplyr
Romain Francois
 
PDF
user2015 keynote talk
Romain Francois
 
PDF
SevillaR meetup: dplyr and magrittr
Romain Francois
 
PDF
Data manipulation with dplyr
Romain Francois
 
PDF
Rcpp attributes
Romain Francois
 
PDF
Rcpp is-ready
Romain Francois
 
PDF
Integrating R with C++: Rcpp, RInside and RProtoBuf
Romain Francois
 
PDF
Object Oriented Design(s) in R
Romain Francois
 
PDF
RProtoBuf: protocol buffers for R
Romain Francois
 
PDF
Rcpp: Seemless R and C++
Romain Francois
 
dplyr and torrents from cpasbien
Romain Francois
 
dplyr use case
Romain Francois
 
user2015 keynote talk
Romain Francois
 
SevillaR meetup: dplyr and magrittr
Romain Francois
 
Data manipulation with dplyr
Romain Francois
 
Rcpp attributes
Romain Francois
 
Rcpp is-ready
Romain Francois
 
Integrating R with C++: Rcpp, RInside and RProtoBuf
Romain Francois
 
Object Oriented Design(s) in R
Romain Francois
 
RProtoBuf: protocol buffers for R
Romain Francois
 
Rcpp: Seemless R and C++
Romain Francois
 
Ad

Recently uploaded (20)

PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Python basic programing language for automation
DanialHabibi2
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 

Rcpp11 useR2014

  • 2. Rcpp11 • Targets C++11 • Smaller code base (than Rcpp) • Header only
  • 4. #include <Rcpp.h> ! // [[Rcpp::export]] int foo(){ return 2 ; } Rcpp Rcpp11 0 1 2 3 4 Less complexity -> faster compiles
  • 6. NumericVector constructors // C++ uniform initialization NumericVector x = {1.0, 2.0, 3.0} ; ! // init with given size NumericVector y( 2 ) ; // data is not initialized NumericVector y( 2, 3.0 ) ; // initialize all to 3.0 ! // fuse several vectors (similar to c in R) NumericVector z = fuse(x, y) ; NumericVector z = fuse(x, y, 3.0) ;
  • 7. create NumericVector x = {1.0, 2.0, 3.0} ; ! // old school NumericVector::create (Rcpp style). NumericVector x = NumericVector::create(1.0, 2.0, 3.0) ; NumericVector x = NumericVector::create( _["a"] = 1.0, _["b"] = 2.0, _["c"] = 3.0 ) ; ! !// create as a free function. Rcpp11 style NumericVector x = create(1.0, 2.0, 3.0) ; NumericVector x = create( _["a"] = 1.0, _["b"] = 2.0, _["c"] = 3.0 ) ;
  • 8. sugar #include <Rcpp11> ! // [[export]] NumericVector foo( NumericVector x ){ return sqrt(exp(x)) + 1.0 ; } ! /*** R foo( c(1,2,3) ) # [1] 2.648721 3.718282 5.481689 */
  • 10. sapply + lambda #include <Rcpp11> ! // [[export]] NumericVector foo( NumericVector x ){ return sapply(x, [](double d){ return exp(d * 2) ; }); } x <- 1:3 sapply( x, function(d){ exp(d*2) ; })
  • 11. sapply + lambda + … #include <Rcpp11> ! // [[export]] NumericVector foo( NumericVector x ){ auto fun = [](double d, double y, double z){ return exp(d * y) + z ; } ; return sapply(x, fun, 3.0, 4.6); } x <- 1:3 sapply( x, function(d, y, z){ exp(d*y) + z ; }, 3.0, 4.6 )
  • 12. Rcpp11 release cycle • Available from CRAN: ! • Evolves quickly. Get it from github ! • Next Release: 3.1.1 (same time as R 3.1.1) > install.packages( "Rcpp11" ) > install_github( "Rcpp11/Rcpp11" )
  • 13. attributes companion package • Standalone impl of Rcpp attributes [[Rcpp::export]], sourceCpp, compileAttributes ! • Only available from github: > install_github( "Rcpp11/attributes" )
  • 14. Use Rcpp11 in your package • Write your .cpp files #include <Rcpp11> ! // [[export]] void foo( … ) { … } // your code SystemRequirements: C++11 LinkingTo: Rcpp11 library(attributes) compileAttributes( "mypkg" ) • Express dep on C++11 and Rcpp11 headers • Generate the boiler plate