Skip to content

Instantly share code, notes, and snippets.

@DavisVaughan
Created September 24, 2017 22:31
Show Gist options
  • Save DavisVaughan/6597eac027303443bd69809b74646372 to your computer and use it in GitHub Desktop.
Save DavisVaughan/6597eac027303443bd69809b74646372 to your computer and use it in GitHub Desktop.
// [[Rcpp::depends(xtensor)]]
#include <numeric>
#include "xtensor/xmath.hpp"
#include "xtensor-r/rarray.hpp"
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::plugins(cpp14)]]
// [[Rcpp::export]]
double sum_of_sines(xt::rarray<double>& m)
{
auto sines = xt::sin(m);
return std::accumulate(sines.cbegin(), sines.cend(), 0.0);
}
// You can include R code blocks in C++ files processed with sourceCpp
// (useful for testing and development). The R code will be automatically
// run after the compilation.
//
/*** R
sum_of_sines(42)
*/
@alexpghayes
Copy link

Ugh I think it's a windows/C++ thing blergh

image

@DavisVaughan
Copy link
Author

DavisVaughan commented Sep 24, 2017

@alexpghayes

I think this is heavily related to your closed issue here. I am absolutely no expert but maybe they need to use PKG_CPPFLAGS instead of PKG_CXXFLAGS in this file. I only say that because that seems to be what Rcpp does here?

It just looks like it's either not finding your C++14 or it was called incorrectly or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment