Created
March 19, 2018 03:55
-
-
Save kbroman/aedc8d8313f5f471e7089c3d0205f45e to your computer and use it in GitHub Desktop.
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; | |
// [[Rcpp::export]] | |
NumericVector sim_crossovers_orig(const double L) | |
{ | |
int n_xo; | |
n_xo = R::rpois(L/100.0); | |
NumericVector tmp = runif(n_xo, 0.0, L); | |
return tmp.sort(); | |
} | |
// [[Rcpp::export]] | |
NumericVector sim_crossovers_new(const double L) | |
{ | |
int n_xo; | |
n_xo = R::rpois(L/100.0); | |
NumericVector tmp(0); | |
if(n_xo > 0) tmp = runif(n_xo, 0.0, L); | |
return tmp.sort(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code to explore a change in Rcpp from version 0.12.15 to 0.12.16.
With Rcpp ver 0.12.15, these two things give the same results.
But with Rcpp ver 0.12.16, the former gives a ton of 0-length vectors, while the latter works fine, though it gives somewhat different results from ver 0.12.15. (The tables being printed should be 10,000 draws from a Poisson distribution with mean 1.)