Rcpp and RcppParallel Examples
07 Apr 2015To install Systematic Investor Toolbox (SIT) please visit About page.
Following are few examples of using Rcpp and RcppParallel. I found following resources very helpful:
- Rcpp Gallery
- RcppParallel help site
- RcppParallel source code
- RcppParallel introduction
- RcppParallel at Rcpp gallery
To get started on Windows you would need to install Rtools
Please save above code in the Rcpp_RcppParallel_examples.cpp
file or download Rcpp_RcppParallel_examples.cpp.
cp_test_vector(100) [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [24] 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 [47] 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 [70] 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 [93] 92 93 94 95 96 97 98 99
c_test_multi_array(matrix(runif(20), nr = 5), 3) , , 1
[,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA NA NA NA [3,] NA NA NA NA [4,] NA NA NA NA
, , 2
[,1] [,2] [,3] [,4] [1,] NA NA NA NA [2,] NA NA NA NA [3,] NA NA NA NA [4,] NA NA NA NA
, , 3
[,1] [,2] [,3] [,4] [1,] 0 0 0 0 [2,] 0 0 0 0 [3,] 0 0 0 0 [4,] 0 0 0 0
, , 4
[,1] [,2] [,3] [,4] [1,] 1 1 1 1 [2,] 1 1 1 1 [3,] 1 1 1 1 [4,] 1 1 1 1
, , 5
[,1] [,2] [,3] [,4] [1,] 2 2 2 2 [2,] 2 2 2 2 [3,] 2 2 2 2 [4,] 2 2 2 2
c_test_list(3) [[1]] [1] 0 0 0 0 0 0
[[2]] [1] 0 0 0 0 0 0
[[3]] [1] 0 0 0 0 0 0
c_test_list1(3) [[1]] [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 [3,] 0 0 0 0 0 0 [4,] 0 0 0 0 0 0 [5,] 0 0 0 0 0 0 [6,] 0 0 0 0 0 0
[[2]] [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 [3,] 0 0 0 0 0 0 [4,] 0 0 0 0 0 0 [5,] 0 0 0 0 0 0 [6,] 0 0 0 0 0 0
[[3]] [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 [3,] 0 0 0 0 0 0 [4,] 0 0 0 0 0 0 [5,] 0 0 0 0 0 0 [6,] 0 0 0 0 0 0
To be continued…
(this report was produced on: 2015-04-19)