[Rcpp-commits] r1953 - pkg/Rcpp pkg/Rcpp/inst pkg/Rcpp/inst/include/Rcpp/stats scripts

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Aug 9 09:16:41 CEST 2010


Author: romain
Date: 2010-08-09 09:16:41 +0200 (Mon, 09 Aug 2010)
New Revision: 1953

Added:
   pkg/Rcpp/inst/include/Rcpp/stats/weibull.h
Modified:
   pkg/Rcpp/NEWS
   pkg/Rcpp/TODO
   pkg/Rcpp/inst/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/stats/stats.h
   scripts/stats.R
Log:
(dpq)weibull (no tests yet)

Modified: pkg/Rcpp/NEWS
===================================================================
--- pkg/Rcpp/NEWS	2010-08-09 06:23:37 UTC (rev 1952)
+++ pkg/Rcpp/NEWS	2010-08-09 07:16:41 UTC (rev 1953)
@@ -1,6 +1,6 @@
 0.8.6   (future)
 
-	o	new sugar functions (dpq)(unif|norm|gamma|chisq|lnorm|pois|binom|t|beta)
+	o	new sugar functions (dpq)(unif|norm|gamma|chisq|lnorm|weibull|pois|binom|t|beta)
 
 	o	new vignette Rcpp-quickref : quick reference guide of Rcpp API
 

Modified: pkg/Rcpp/TODO
===================================================================
--- pkg/Rcpp/TODO	2010-08-09 06:23:37 UTC (rev 1952)
+++ pkg/Rcpp/TODO	2010-08-09 07:16:41 UTC (rev 1953)
@@ -66,7 +66,7 @@
     o   Compound operators: ++,--,+=, -=, ...
     
     o	other statistical distribution functions : nchisq, f, 
-    	multinom, cauchy, exp, geom, hyper, nbinom, nbinom_mu, weibull,
+    	multinom, cauchy, exp, geom, hyper, nbinom, nbinom_mu,
     	logis, nbeta, nf, nt, tukey, wilcox, signrank
     
     o	sum : deal with missing values

Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-08-09 06:23:37 UTC (rev 1952)
+++ pkg/Rcpp/inst/ChangeLog	2010-08-09 07:16:41 UTC (rev 1953)
@@ -1,6 +1,7 @@
 2010-08-09  Romain Francois <romain at r-enthusiasts.com>
 
-	* inst/include/Rcpp/stats/lnorm.h: Added d-p-q lnorm
+	* inst/include/Rcpp/stats/lnorm.h: Added d-p-q (lnorm|weibull), generated
+	by the script
 
 2010-08-06  Douglas Bates  <bates at stat.wisc.edu>
 

Modified: pkg/Rcpp/inst/include/Rcpp/stats/stats.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/stats.h	2010-08-09 06:23:37 UTC (rev 1952)
+++ pkg/Rcpp/inst/include/Rcpp/stats/stats.h	2010-08-09 07:16:41 UTC (rev 1953)
@@ -29,6 +29,7 @@
 #include <Rcpp/stats/beta.h>
 #include <Rcpp/stats/t.h>
 #include <Rcpp/stats/lnorm.h>
+#include <Rcpp/stats/weibull.h>
 
 #include <Rcpp/stats/binom.h>
 #include <Rcpp/stats/pois.h>

Added: pkg/Rcpp/inst/include/Rcpp/stats/weibull.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/weibull.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/stats/weibull.h	2010-08-09 07:16:41 UTC (rev 1953)
@@ -0,0 +1,118 @@
+
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// auto generated file (from script/stats.R) 
+//
+// weibull.h: Rcpp R/C++ interface class library -- 
+//
+// Copyright (C) 2010 Douglas Bates, Dirk Eddelbuettel and Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef Rcpp__stats__weibull_h
+#define Rcpp__stats__weibull_h
+
+namespace Rcpp {
+namespace stats {
+namespace impl {
+
+	template <bool NA, typename T>
+	class DWeibull : public Rcpp::VectorBase< REALSXP, NA, DWeibull<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		DWeibull( const VEC_TYPE& vec_, double shape_, double scale_ = 1.0 , bool log_ = false ) : 
+			vec(vec_), shape(shape_), scale(scale_) , log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::dweibull( vec[i], shape, scale , log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		double shape; double scale; 
+		int log;
+	
+	};
+
+	template <bool NA, typename T>
+	class PWeibull : public Rcpp::VectorBase< REALSXP, NA, PWeibull<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		PWeibull( const VEC_TYPE& vec_, double shape_, double scale_ = 1.0 ,
+			   bool lower_tail = true, bool log_ = false ) : 
+			vec(vec_), shape(shape_), scale(scale_) , lower(lower_tail), log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::pweibull( vec[i], shape, scale, lower, log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		double shape; double scale; 
+		int lower, log;
+	
+	};
+
+	template <bool NA, typename T>
+	class QWeibull : public Rcpp::VectorBase< REALSXP, NA, QWeibull<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		QWeibull( const VEC_TYPE& vec_, double shape_, double scale_ = 1.0 ,
+			   bool lower_tail = true, bool log_ = false ) : 
+			vec(vec_), shape(shape_), scale(scale_), lower(lower_tail), log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::qweibull( vec[i], shape, scale, lower, log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		double shape; double scale; 
+		int lower, log;
+	
+	};
+	
+} // impl
+
+template <bool NA, typename T>
+inline impl::DWeibull<NA,T> dweibull( const Rcpp::VectorBase<REALSXP,NA,T>& x, double shape_, double scale_ = 1.0, bool log = false ) {
+	return impl::DWeibull<NA,T>( x, shape_, scale_, log ); 
+}
+
+template <bool NA, typename T>
+inline impl::PWeibull<NA,T> pweibull( const Rcpp::VectorBase<REALSXP,NA,T>& x, double shape_, double scale_ = 1.0, bool lower = true, bool log = false ) {
+	return impl::PWeibull<NA,T>( x, shape_, scale_, lower, log ); 
+}
+
+template <bool NA, typename T>
+inline impl::QWeibull<NA,T> qweibull( const Rcpp::VectorBase<REALSXP,NA,T>& x, double shape_, double scale_ = 1.0, bool lower = true, bool log = false ) {
+	return impl::QWeibull<NA,T>( x, shape_, scale_, lower, log ); 
+}
+	
+}
+}
+
+#endif
+

Modified: scripts/stats.R
===================================================================
--- scripts/stats.R	2010-08-09 06:23:37 UTC (rev 1952)
+++ scripts/stats.R	2010-08-09 07:16:41 UTC (rev 1953)
@@ -176,9 +176,14 @@
 # cook( "chisq", params = list( 
 # 	"df" = list( type = "double" ) 
 # 	) )
+#
+#cook( "lnorm", params = list( 
+#	"meanlog" = list( type = "double", default = "0.0" ), 
+#	"sdlog" = list( type = "double", default = "1.0" )
+#	) )
 
-cook( "lnorm", params = list( 
-	"meanlog" = list( type = "double", default = "0.0" ), 
-	"sdlog" = list( type = "double", default = "1.0" )
-	) )
-	
+cook( "weibull", params = list( 
+		"shape" = list( type = "double" ), 
+		"scale" = list( type = "double", default = "1.0" )
+ 	)  )
+



More information about the Rcpp-commits mailing list