Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Created February 24, 2023 06:21
Show Gist options
  • Save abikoushi/9b5fa94dda405241ac69e3ee26d43c0c to your computer and use it in GitHub Desktop.
Save abikoushi/9b5fa94dda405241ac69e3ee26d43c0c to your computer and use it in GitHub Desktop.
An exaple of calling R function in RcppArmadillo
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
// [[Rcpp::export]]
arma::vec rpg_call(const arma::vec & h, const arma::vec & z){
Environment pkg = Environment::namespace_env("BayesLogit");
Function f = pkg["rpg"];
NumericVector out = f(Rcpp::Named("num", h.n_elem),
Rcpp::Named("h",h),
Rcpp::Named("z",z));
return as<arma::vec>(out);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment