[Rcpp-commits] r2016 - pkg/Rcpp/inst/include/Rcpp/stats/random
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Aug 15 13:59:09 CEST 2010
Author: romain
Date: 2010-08-15 13:59:09 +0200 (Sun, 15 Aug 2010)
New Revision: 2016
Modified:
pkg/Rcpp/inst/include/Rcpp/stats/random/rlnorm.h
pkg/Rcpp/inst/include/Rcpp/stats/random/rlogis.h
pkg/Rcpp/inst/include/Rcpp/stats/random/rnchisq.h
Log:
compile time handling of default for rnchisq
Modified: pkg/Rcpp/inst/include/Rcpp/stats/random/rlnorm.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/random/rlnorm.h 2010-08-15 11:55:44 UTC (rev 2015)
+++ pkg/Rcpp/inst/include/Rcpp/stats/random/rlnorm.h 2010-08-15 11:59:09 UTC (rev 2016)
@@ -41,6 +41,7 @@
} ;
} // stats
+// TODO: move the default arguments to compile-time dispatch
inline NumericVector rlnorm( int n, double meanlog = 0.0, double sdlog = 1.0 ){
if (ISNAN(meanlog) || !R_FINITE(sdlog) || sdlog < 0.){
// TODO: R also throws a warning in that case, should we ?
Modified: pkg/Rcpp/inst/include/Rcpp/stats/random/rlogis.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/random/rlogis.h 2010-08-15 11:55:44 UTC (rev 2015)
+++ pkg/Rcpp/inst/include/Rcpp/stats/random/rlogis.h 2010-08-15 11:59:09 UTC (rev 2016)
@@ -42,6 +42,7 @@
} ;
} // stats
+// TODO: move the default arguments to compile-time dispatch
inline NumericVector rlogis( int n, double location, double scale ){
if (ISNAN(location) || !R_FINITE(scale))
return NumericVector( n, R_NaN ) ;
Modified: pkg/Rcpp/inst/include/Rcpp/stats/random/rnchisq.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/random/rnchisq.h 2010-08-15 11:55:44 UTC (rev 2015)
+++ pkg/Rcpp/inst/include/Rcpp/stats/random/rnchisq.h 2010-08-15 11:59:09 UTC (rev 2016)
@@ -49,7 +49,7 @@
} ;
} // stats
-inline NumericVector rnchisq( int n, double df, double lambda = 1.0 ){
+inline NumericVector rnchisq( int n, double df, double lambda ){
if (!R_FINITE(df) || !R_FINITE(lambda) || df < 0. || lambda < 0.)
return NumericVector(n, R_NaN) ;
if( lambda == 0.0 ){
@@ -59,6 +59,12 @@
return NumericVector( n, stats::NChisqGenerator( df, lambda ) ) ;
}
+inline NumericVector rnchisq( int n, double df /*, double lambda = 0.0 */ ){
+ if (!R_FINITE(df) || df < 0. )
+ return NumericVector(n, R_NaN) ;
+ return NumericVector( n, stats::ChisqGenerator( df ) ) ;
+}
+
} // Rcpp
#endif
More information about the Rcpp-commits
mailing list