Short introduction to Rcpp - University of Warwick · Short introduction to Rcpp. Rcpp and C++...

Post on 25-Jun-2020

14 views 0 download

Transcript of Short introduction to Rcpp - University of Warwick · Short introduction to Rcpp. Rcpp and C++...

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Short introduction to Rcpp

Sherman Ip

University of Warwick

2nd March 2017

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Table of Contents

1 Rcpp and C++

2 Simple example

3 Inputs

4 Inputs and outputs

5 Matrices

6 Lists

7 Some advice

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

1 Rcpp and C++

2 Simple example

3 Inputs

4 Inputs and outputs

5 Matrices

6 Lists

7 Some advice

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Rcpp

Rcpp is an R package which allows you to compile and runC++ code in R.

Eddelbuettel et al. (2011)

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

C++

Some key words:

Strongly typed

Memory allocation

Pointers

Memory leaks

Object oriented

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

C++

Some key words:

Strongly typed

Memory allocation

Pointers

Memory leaks

Object oriented

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

C++

Some key words:

Strongly typed

Memory allocation

Pointers

Memory leaks

Object oriented

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

C++

Some key words:

Strongly typed

Memory allocation

Pointers

Memory leaks

Object oriented

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

C++

Some key words:

Strongly typed

Memory allocation

Pointers

Memory leaks

Object oriented

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

C++

Some key words:

Strongly typed

Memory allocation

Pointers

Memory leaks

Object oriented

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

1 Rcpp and C++

2 Simple example

3 Inputs

4 Inputs and outputs

5 Matrices

6 Lists

7 Some advice

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Simple example

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Simple example

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Simple example

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

1 Rcpp and C++

2 Simple example

3 Inputs

4 Inputs and outputs

5 Matrices

6 Lists

7 Some advice

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Inputs

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Inputs

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

1 Rcpp and C++

2 Simple example

3 Inputs

4 Inputs and outputs

5 Matrices

6 Lists

7 Some advice

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Inputs and outputs

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Inputs and outputs

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

1 Rcpp and C++

2 Simple example

3 Inputs

4 Inputs and outputs

5 Matrices

6 Lists

7 Some advice

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Matrices

armadillo is a C++ library for matrix operations. Sandersonet al. (2016)

RcppArmadillo is an R package wich allows you to compileand run C++ code, which uses arma, in R. Eddelbuettel etal. (2014)

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Matrices

armadillo is a C++ library for matrix operations. Sandersonet al. (2016)

RcppArmadillo is an R package wich allows you to compileand run C++ code, which uses arma, in R. Eddelbuettel etal. (2014)

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Matrices

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Matrices

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

1 Rcpp and C++

2 Simple example

3 Inputs

4 Inputs and outputs

5 Matrices

6 Lists

7 Some advice

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Lists

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Lists

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

1 Rcpp and C++

2 Simple example

3 Inputs

4 Inputs and outputs

5 Matrices

6 Lists

7 Some advice

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Some advice

C+11 and armadillo libraries are very useful and welldocumented.

Spilt your programe into pure C++ code and code involvingRcpp.

Learn C++ first before Rcpp.

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Some advice

C+11 and armadillo libraries are very useful and welldocumented.

Spilt your programe into pure C++ code and code involvingRcpp.

Learn C++ first before Rcpp.

Sherman Ip University of Warwick

Short introduction to Rcpp

Rcpp and C++ Simple example Inputs Inputs and outputs Matrices Lists Some advice

Some advice

C+11 and armadillo libraries are very useful and welldocumented.

Spilt your programe into pure C++ code and code involvingRcpp.

Learn C++ first before Rcpp.

Sherman Ip University of Warwick

Short introduction to Rcpp