Skip to content

Instantly share code, notes, and snippets.

@BerriJ
Created January 13, 2023 15:06
Show Gist options
  • Save BerriJ/45aa5e34ca273acd3d2e99bcaebabf19 to your computer and use it in GitHub Desktop.
Save BerriJ/45aa5e34ca273acd3d2e99bcaebabf19 to your computer and use it in GitHub Desktop.
Expose R function splines::splineDesign to Rcpp
#include <RcppArmadillo.h>
// Expose splines::splineDesign to Rcpp
mat splineDesign_rcpp(const vec &x, const vec &knots, const int &deg)
{
Rcpp::Environment pkg = Rcpp::Environment::namespace_env("splines");
Rcpp::Function f = pkg["splineDesign"];
mat y = Rcpp::as<arma::mat>(f(knots, x, deg + 1, 0, true));
return y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment