-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chung@molgen.mpg.de
committed
Jan 19, 2016
1 parent
821cca8
commit 9fe7c4d
Showing
6 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This file was generated by Rcpp::compileAttributes | ||
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
init_rng <- function(seed = 0L) { | ||
.Call('decon_init_rng', PACKAGE = 'decon', seed) | ||
} | ||
|
||
rmn <- function(N, p) { | ||
.Call('decon_rmn', PACKAGE = 'decon', N, p) | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
GSL_CFLAGS=`${R_HOME}/bin/Rscript -e "RcppGSL:::CFlags()"` | ||
GSL_LIBS=`${R_HOME}/bin/Rscript -e "RcppGSL:::LdFlags()"` | ||
sed -e "s|@GSL_LIBS@|${GSL_LIBS}|" -e "s|@GSL_CFLAGS@|${GSL_CFLAGS}|" src/Makevars.in > src/Makevars |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PKG_LIBS = `$(R_HOME)/bin/Rscript -e "RcppGSL:::LdFlags()"` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// This file was generated by Rcpp::compileAttributes | ||
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
#include <RcppGSL.h> | ||
#include <Rcpp.h> | ||
|
||
using namespace Rcpp; | ||
|
||
// init_rng | ||
long init_rng(long seed); | ||
RcppExport SEXP decon_init_rng(SEXP seedSEXP) { | ||
BEGIN_RCPP | ||
Rcpp::RObject __result; | ||
Rcpp::RNGScope __rngScope; | ||
Rcpp::traits::input_parameter< long >::type seed(seedSEXP); | ||
__result = Rcpp::wrap(init_rng(seed)); | ||
return __result; | ||
END_RCPP | ||
} | ||
// rmn | ||
Rcpp::IntegerVector rmn(unsigned int N, Rcpp::NumericVector p); | ||
RcppExport SEXP decon_rmn(SEXP NSEXP, SEXP pSEXP) { | ||
BEGIN_RCPP | ||
Rcpp::RObject __result; | ||
Rcpp::RNGScope __rngScope; | ||
Rcpp::traits::input_parameter< unsigned int >::type N(NSEXP); | ||
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type p(pSEXP); | ||
__result = Rcpp::wrap(rmn(N, p)); | ||
return __result; | ||
END_RCPP | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// [[Rcpp::depends(RcppGSL)]] | ||
|
||
#include <RcppGSL.h> | ||
#include <gsl/gsl_rng.h> | ||
#include <gsl/gsl_randist.h> | ||
#include <unistd.h> // getpid | ||
|
||
gsl_rng* r; | ||
|
||
long init_rng(long seed = 0){ | ||
r = gsl_rng_alloc (gsl_rng_mt19937); | ||
if (seed == 0){ | ||
seed = rand()/(((double)RAND_MAX + 1)/10000000) * getpid(); | ||
} | ||
gsl_rng_set (r, seed); | ||
return seed; | ||
} | ||
|
||
Rcpp::IntegerVector rmultinom(unsigned int N, Rcpp::NumericVector p){ | ||
size_t K = p.size(); | ||
Rcpp::IntegerVector res(K); | ||
gsl_ran_multinomial(r, K, N, p.begin(), (unsigned int *) res.begin()); | ||
return res; | ||
} | ||
|
||
|
||
|