Skip to content

Commit

Permalink
Merge pull request #32 from LTLA/master
Browse files Browse the repository at this point in the history
Minor fixes for compilation, corrected looping across rows.
  • Loading branch information
eddelbuettel committed Oct 9, 2018
2 parents 04ff189 + ab7a7cf commit 0e907b3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions vignettes/rcppannoy.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The pre-processor statements in your source files should look like:
#endif

// define R's REprintf as the 'local' error print method for Annoy
#include "Rcpp.h"
#define __ERROR_PRINTER_OVERRIDE__ REprintf

#include "annoylib.h"
Expand Down Expand Up @@ -75,10 +76,10 @@ Note the copy from the double-precision matrix into a `float` vector before call

```cpp
MyAnnoyIndex obj(ndims);
std::vector<ANNOYTYPE> tmp(ndims);
std::vector<ANNOYTYPE> tmp(ndims); // from <vector>
for (int i=0; i<nsamples; ++i) {
auto curcol=mat.column(i); // C++11 auto for brevity.
std::copy(curcol.begin(), curcol.end(), tmp.begin());
Rcpp::NumericMatrix::Row currow=mat.row(i);
std::copy(currow.begin(), currow.end(), tmp.begin()); // from <algorithm>
obj.add_item(i, tmp.data());
}
obj.build(50);
Expand Down Expand Up @@ -110,7 +111,7 @@ To do this, we write:
```cpp
std::vector<int> neighbor_index;
std::vector<double> neighbor_dist;
std::vector<ANNOYTYPE> neighbor_dist;
obj.get_nns_by_item(c, K + 1, -1, &neighbor_index, &neighbor_dist);
```

Expand Down

0 comments on commit 0e907b3

Please sign in to comment.