Created
September 1, 2017 05:04
-
-
Save slwu89/f90f5109eb72c76f058062547a8b9250 to your computer and use it in GitHub Desktop.
C in Rcpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Rcpp.h> | |
using namespace Rcpp; | |
// C code with Rcpp; basic example | |
// [[Rcpp::export]] | |
extern "C" SEXP rngScopeCppScalar() { | |
NumericVector x(4); | |
RNGScope rngScope; | |
x[0] = R::runif(0,1); | |
x[1] = R::rnorm(0,1); | |
x[2] = R::rt(5); | |
x[3] = R::rbeta(1,1); | |
return wrap(x); | |
} | |
// [[Rcpp::export]] | |
RcppExport SEXP helloB2() { | |
Rcpp::StringVector result(1); | |
result[0] = "Hello World!"; | |
return(result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment