[Rcpp-devel] min, max, range
Romain Francois
romain at r-enthusiasts.com
Thu Nov 15 19:24:16 CET 2012
And now for something completely different: min, max (which for some
reason where not already there):
require(Rcpp)
require(microbenchmark)
sourceCpp( code = '
#include <Rcpp.h>
using namespace Rcpp ;
// [[Rcpp::export]]
NumericVector range_( NumericVector x){
return range(x) ;
}
' )
> xx <- rnorm( 1e6 )
> print( microbenchmark(
+ range(xx),
+ range_(xx)
+ ) )
Unit: milliseconds
expr min lq median uq max
1 range_(xx) 4.741552 4.803686 4.847602 4.883612 5.073721
2 range(xx) 9.009232 9.130179 10.720429 11.661888 40.070511
Romain
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
R Graph Gallery: http://gallery.r-enthusiasts.com
`- http://bit.ly/SweN1Z : SuperStorm Sandy
blog: http://romainfrancois.blog.free.fr
|- http://bit.ly/RE6sYH : OOP with Rcpp modules
`- http://bit.ly/Thw7IK : Rcpp modules more flexible
More information about the Rcpp-devel
mailing list