Skip to content

Commit 40896ee

Browse files
committed
Progress upload
1 parent e2d52e8 commit 40896ee

File tree

3 files changed

+32
-41
lines changed

3 files changed

+32
-41
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ vignettes/*.pdf
3131
# Temporary files created by R markdown
3232
*.utf8.md
3333
*.knit.md
34+
.Rproj.user

README.Rmd

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,27 @@ microbenchmark(
128128

129129
Okay, let's try to adapt [RcppMLPACK's example code](https://github.com/thirdwing/RcppMLPACK/wiki/Example#k-means-example) for [k-means](http://www.mlpack.org/docs/mlpack-2.0.3/doxygen.php?doc=kmtutorial.html#kmeans_kmtut) to a RcppMLPACK-less context :)
130130

131-
```{Rcpp kmeans_source, eval = FALSE}
131+
```{r, eval = FALSE}
132+
Rcpp::sourceCpp(code = "// This is just to see some stuff...
133+
// [[Rcpp::plugins(cpp11)]]
134+
// [[Rcpp::depends(RcppArmadillo)]]
135+
#include <RcppArmadillo.h>
136+
using namespace Rcpp;
137+
// [[Rcpp::export]]
138+
", dryRun = TRUE)
139+
```
140+
141+
```{r env_vars}
142+
Sys.setenv(
143+
"CXX" = "clang++",
144+
"CXX1XSTD" = "-std=c++0x -stdlib=libc++",
145+
# "CXX1XSTD" = "-std=c++11 -stdlib=libc++",
146+
"CPPFLAGS" = "$(CPPFLAGS) -I/usr/local/include/",
147+
"SHLIB_CXX1XLDFLAGS" = '$(SHLIB_CXX1XLDFLAGS) -L/usr/local/lib'
148+
)
149+
```
150+
151+
```{Rcpp kmeans_source}
132152
// [[Rcpp::plugins(cpp11)]]
133153
// [[Rcpp::depends(RcppArmadillo)]]
134154
@@ -146,22 +166,6 @@ arma::Row<size_t> kMeans(const arma::mat& data, const int& clusters) {
146166
}
147167
```
148168

149-
I get the following:
150-
151-
```
152-
Building shared library for Rcpp code chunk...
153-
154-
Quitting from lines 132-147 (README.Rmd)
155-
Error in dyn.load("/Users/mpopov/Desktop/Learning Rcpp/README_cache/markdown_github/kmeans_source_sourceCpp/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_450b02624e/sourceCpp_2.so") :
156-
unable to load shared object '/Users/mpopov/Desktop/Learning Rcpp/README_cache/markdown_github/kmeans_source_sourceCpp/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_450b02624e/sourceCpp_2.so':
157-
dlopen(/Users/mpopov/Desktop/Learning Rcpp/README_cache/markdown_github/kmeans_source_sourceCpp/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_450b02624e/sourceCpp_2.so, 6): Symbol not found: __ZN6mlpack3Log4InfoE
158-
Referenced from: /Users/mpopov/Desktop/Learning Rcpp/README_cache/markdown_github/kmeans_source_sourceCpp/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_450b02624e/sourceCpp_2.so
159-
Expected in: flat namespace
160-
in /Users/mpopov/Desktop/Learning Rcpp/README_cache/markdown_github/kmeans_source_sourceCpp/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_450b02624e/sourceCpp_2.so
161-
Calls: <Anonymous> ... <Anonymous> -> source -> withVisible -> eval -> eval -> dyn.load
162-
Execution halted
163-
```
164-
165169
```{r kmeans_example, eval = FALSE}
166170
data(trees, package = "datasets")
167171
microbenchmark(

README.md

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ microbenchmark(
101101
) %>% summary(unit = "ms") %>% knitr::kable(format = "markdown")
102102
```
103103

104-
| expr | min| lq| mean| median| uq| max| neval|
105-
|:-------|-------:|-------:|-------:|-------:|-------:|-------:|------:|
106-
| native | 0.0025| 0.0027| 0.0041| 0.0031| 0.0043| 0.0285| 100|
107-
| loop | 0.8592| 0.9358| 1.1537| 1.0114| 1.1266| 2.5243| 100|
108-
| Rcpp | 0.0043| 0.0049| 0.0097| 0.0066| 0.0119| 0.0922| 100|
104+
| expr | min| lq| mean| median| uq| max| neval|
105+
|:-------|-------:|-------:|-------:|-------:|-------:|--------:|------:|
106+
| native | 0.0054| 0.0067| 0.0101| 0.0094| 0.0111| 0.0316| 100|
107+
| loop | 2.5596| 2.8170| 3.8305| 2.9332| 4.3961| 10.4269| 100|
108+
| Rcpp | 0.0088| 0.0107| 0.0405| 0.0226| 0.0267| 1.4890| 100|
109109

110110
Using Libraries
111111
---------------
@@ -139,11 +139,11 @@ microbenchmark(
139139
) %>% summary(unit = "ms") %>% knitr::kable(format = "markdown")
140140
```
141141

142-
| expr | min| lq| mean| median| uq| max| neval|
143-
|:--------|-------:|-------:|-------:|-------:|-------:|------:|------:|
144-
| lm | 0.8363| 0.8800| 1.0891| 0.9287| 1.2126| 3.148| 100|
145-
| fastLm | 0.0909| 0.1088| 0.1464| 0.1213| 0.1480| 1.566| 100|
146-
| RcppArm | 0.1153| 0.1295| 0.1736| 0.1453| 0.1708| 1.411| 100|
142+
| expr | min| lq| mean| median| uq| max| neval|
143+
|:--------|-------:|------:|-------:|-------:|-------:|-------:|------:|
144+
| lm | 3.0011| 3.233| 4.1407| 3.4576| 4.0617| 16.171| 100|
145+
| fastLm | 0.3204| 0.339| 0.4078| 0.3821| 0.4043| 3.136| 100|
146+
| RcppArm | 0.3982| 0.421| 0.7686| 0.4602| 0.5000| 14.761| 100|
147147

148148
Okay, let's try to adapt [RcppMLPACK's example code](https://github.com/thirdwing/RcppMLPACK/wiki/Example#k-means-example) for [k-means](http://www.mlpack.org/docs/mlpack-2.0.3/doxygen.php?doc=kmtutorial.html#kmeans_kmtut) to a RcppMLPACK-less context :)
149149

@@ -165,20 +165,6 @@ arma::Row<size_t> kMeans(const arma::mat& data, const int& clusters) {
165165
}
166166
```
167167
168-
I get the following:
169-
170-
Building shared library for Rcpp code chunk...
171-
172-
Quitting from lines 132-147 (README.Rmd)
173-
Error in dyn.load("/Users/mpopov/Desktop/Learning Rcpp/README_cache/markdown_github/kmeans_source_sourceCpp/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_450b02624e/sourceCpp_2.so") :
174-
unable to load shared object '/Users/mpopov/Desktop/Learning Rcpp/README_cache/markdown_github/kmeans_source_sourceCpp/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_450b02624e/sourceCpp_2.so':
175-
dlopen(/Users/mpopov/Desktop/Learning Rcpp/README_cache/markdown_github/kmeans_source_sourceCpp/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_450b02624e/sourceCpp_2.so, 6): Symbol not found: __ZN6mlpack3Log4InfoE
176-
Referenced from: /Users/mpopov/Desktop/Learning Rcpp/README_cache/markdown_github/kmeans_source_sourceCpp/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_450b02624e/sourceCpp_2.so
177-
Expected in: flat namespace
178-
in /Users/mpopov/Desktop/Learning Rcpp/README_cache/markdown_github/kmeans_source_sourceCpp/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_450b02624e/sourceCpp_2.so
179-
Calls: <Anonymous> ... <Anonymous> -> source -> withVisible -> eval -> eval -> dyn.load
180-
Execution halted
181-
182168
``` r
183169
data(trees, package = "datasets")
184170
microbenchmark(

0 commit comments

Comments
 (0)