[Rcpp-commits] r2018 - pkg/Rcpp/inst/include/Rcpp/stats/random

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Aug 15 14:04:38 CEST 2010


Author: romain
Date: 2010-08-15 14:04:38 +0200 (Sun, 15 Aug 2010)
New Revision: 2018

Modified:
   pkg/Rcpp/inst/include/Rcpp/stats/random/runif.h
Log:
compile time handling of default for runif

Modified: pkg/Rcpp/inst/include/Rcpp/stats/random/runif.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/random/runif.h	2010-08-15 12:01:29 UTC (rev 2017)
+++ pkg/Rcpp/inst/include/Rcpp/stats/random/runif.h	2010-08-15 12:04:38 UTC (rev 2018)
@@ -45,12 +45,22 @@
 
 } // stats
 
-inline NumericVector runif( int n, double min = 0.0, double max = 1.0 ){
+inline NumericVector runif( int n, double min, double max ){
 	if (!R_FINITE(min) || !R_FINITE(max) || max < min) return NumericVector( n, R_NaN ) ;
 	if( min == max ) return NumericVector( n, min ) ;
 	return NumericVector( n, stats::UnifGenerator( min, max ) ) ;
 }
 
+inline NumericVector runif( int n, double min /*, double max = 1.0 */ ){
+	if (!R_FINITE(min) || 1.0 < min) return NumericVector( n, R_NaN ) ;
+	if( min == 1.0 ) return NumericVector( n, 1.0 ) ;
+	return NumericVector( n, stats::UnifGenerator( min, 1.0 ) ) ;
+}
+
+inline NumericVector runif( int n /*, double min = 0.0, double max = 1.0 */ ){
+	return NumericVector( n, unif_rand ) ;
+}
+
 } // Rcpp
 
 #endif



More information about the Rcpp-commits mailing list