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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 10 11:18:28 CEST 2010


Author: romain
Date: 2010-08-10 11:18:28 +0200 (Tue, 10 Aug 2010)
New Revision: 1975

Added:
   pkg/Rcpp/inst/include/Rcpp/stats/nbinom.h
   pkg/Rcpp/inst/include/Rcpp/stats/nbinom_mu.h
Modified:
   pkg/Rcpp/TODO
   pkg/Rcpp/inst/include/Rcpp/stats/stats.h
   scripts/stats.R
Log:
dpq (nbinom|nbinom_mu)

Modified: pkg/Rcpp/TODO
===================================================================
--- pkg/Rcpp/TODO	2010-08-10 09:13:10 UTC (rev 1974)
+++ pkg/Rcpp/TODO	2010-08-10 09:18:28 UTC (rev 1975)
@@ -66,7 +66,6 @@
     o   Compound operators: ++,--,+=, -=, ...
     
     o	other statistical distribution functions : 
-    	nbinom, nbinom_mu
     	
     	multinom : this makes a matrix, not a vector
     	

Added: pkg/Rcpp/inst/include/Rcpp/stats/nbinom.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/nbinom.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/stats/nbinom.h	2010-08-10 09:18:28 UTC (rev 1975)
@@ -0,0 +1,118 @@
+
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// auto generated file (from script/stats.R) 
+//
+// nbinom.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__nbinom_h
+#define Rcpp__stats__nbinom_h
+
+namespace Rcpp {
+namespace stats {
+namespace impl {
+
+	template <bool NA, typename T>
+	class DNbinom : public Rcpp::VectorBase< REALSXP, NA, DNbinom<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		DNbinom( const VEC_TYPE& vec_, int size_, double prob_ , bool log_ = false ) : 
+			vec(vec_), size(size_), prob(prob_) , log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::dnbinom( vec[i], size, prob , log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		int size; double prob; 
+		int log;
+	
+	};
+
+	template <bool NA, typename T>
+	class PNbinom : public Rcpp::VectorBase< REALSXP, NA, PNbinom<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		PNbinom( const VEC_TYPE& vec_, int size_, double prob_ ,
+			   bool lower_tail = true, bool log_ = false ) : 
+			vec(vec_), size(size_), prob(prob_) , lower(lower_tail), log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::pnbinom( vec[i], size, prob, lower, log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		int size; double prob; 
+		int lower, log;
+	
+	};
+
+	template <bool NA, typename T>
+	class QNbinom : public Rcpp::VectorBase< REALSXP, NA, QNbinom<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		QNbinom( const VEC_TYPE& vec_, int size_, double prob_ ,
+			   bool lower_tail = true, bool log_ = false ) : 
+			vec(vec_), size(size_), prob(prob_), lower(lower_tail), log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::qnbinom( vec[i], size, prob, lower, log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		int size; double prob; 
+		int lower, log;
+	
+	};
+	
+} // impl
+
+template <bool NA, typename T>
+inline impl::DNbinom<NA,T> dnbinom( const Rcpp::VectorBase<REALSXP,NA,T>& x, int size_, double prob_, bool log = false ) {
+	return impl::DNbinom<NA,T>( x, size_, prob_, log ); 
+}
+
+template <bool NA, typename T>
+inline impl::PNbinom<NA,T> pnbinom( const Rcpp::VectorBase<REALSXP,NA,T>& x, int size_, double prob_, bool lower = true, bool log = false ) {
+	return impl::PNbinom<NA,T>( x, size_, prob_, lower, log ); 
+}
+
+template <bool NA, typename T>
+inline impl::QNbinom<NA,T> qnbinom( const Rcpp::VectorBase<REALSXP,NA,T>& x, int size_, double prob_, bool lower = true, bool log = false ) {
+	return impl::QNbinom<NA,T>( x, size_, prob_, lower, log ); 
+}
+	
+}
+}
+
+#endif
+

Added: pkg/Rcpp/inst/include/Rcpp/stats/nbinom_mu.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/nbinom_mu.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/stats/nbinom_mu.h	2010-08-10 09:18:28 UTC (rev 1975)
@@ -0,0 +1,118 @@
+
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// auto generated file (from script/stats.R) 
+//
+// nbinom_mu.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__nbinom_mu_h
+#define Rcpp__stats__nbinom_mu_h
+
+namespace Rcpp {
+namespace stats {
+namespace impl {
+
+	template <bool NA, typename T>
+	class DNbinom_mu : public Rcpp::VectorBase< REALSXP, NA, DNbinom_mu<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		DNbinom_mu( const VEC_TYPE& vec_, int size_, double mu_ , bool log_ = false ) : 
+			vec(vec_), size(size_), mu(mu_) , log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::dnbinom_mu( vec[i], size, mu , log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		int size; double mu; 
+		int log;
+	
+	};
+
+	template <bool NA, typename T>
+	class PNbinom_mu : public Rcpp::VectorBase< REALSXP, NA, PNbinom_mu<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		PNbinom_mu( const VEC_TYPE& vec_, int size_, double mu_ ,
+			   bool lower_tail = true, bool log_ = false ) : 
+			vec(vec_), size(size_), mu(mu_) , lower(lower_tail), log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::pnbinom_mu( vec[i], size, mu, lower, log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		int size; double mu; 
+		int lower, log;
+	
+	};
+
+	template <bool NA, typename T>
+	class QNbinom_mu : public Rcpp::VectorBase< REALSXP, NA, QNbinom_mu<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		QNbinom_mu( const VEC_TYPE& vec_, int size_, double mu_ ,
+			   bool lower_tail = true, bool log_ = false ) : 
+			vec(vec_), size(size_), mu(mu_), lower(lower_tail), log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::qnbinom_mu( vec[i], size, mu, lower, log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		int size; double mu; 
+		int lower, log;
+	
+	};
+	
+} // impl
+
+template <bool NA, typename T>
+inline impl::DNbinom_mu<NA,T> dnbinom_mu( const Rcpp::VectorBase<REALSXP,NA,T>& x, int size_, double mu_, bool log = false ) {
+	return impl::DNbinom_mu<NA,T>( x, size_, mu_, log ); 
+}
+
+template <bool NA, typename T>
+inline impl::PNbinom_mu<NA,T> pnbinom_mu( const Rcpp::VectorBase<REALSXP,NA,T>& x, int size_, double mu_, bool lower = true, bool log = false ) {
+	return impl::PNbinom_mu<NA,T>( x, size_, mu_, lower, log ); 
+}
+
+template <bool NA, typename T>
+inline impl::QNbinom_mu<NA,T> qnbinom_mu( const Rcpp::VectorBase<REALSXP,NA,T>& x, int size_, double mu_, bool lower = true, bool log = false ) {
+	return impl::QNbinom_mu<NA,T>( x, size_, mu_, lower, log ); 
+}
+	
+}
+}
+
+#endif
+

Modified: pkg/Rcpp/inst/include/Rcpp/stats/stats.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/stats.h	2010-08-10 09:13:10 UTC (rev 1974)
+++ pkg/Rcpp/inst/include/Rcpp/stats/stats.h	2010-08-10 09:18:28 UTC (rev 1975)
@@ -43,6 +43,8 @@
 #include <Rcpp/stats/nchisq.h>
 #include <Rcpp/stats/nbeta.h>
 #include <Rcpp/stats/nf.h>
+#include <Rcpp/stats/nbinom.h>
+#include <Rcpp/stats/nbinom_mu.h>
 
 #include <Rcpp/stats/binom.h>
 #include <Rcpp/stats/pois.h>

Modified: scripts/stats.R
===================================================================
--- scripts/stats.R	2010-08-10 09:13:10 UTC (rev 1974)
+++ scripts/stats.R	2010-08-10 09:18:28 UTC (rev 1975)
@@ -191,9 +191,64 @@
 # 		"location" = list( type = "double", default = "0.0" ), 
 # 		"scale" = list( type = "double", default = "1.0" )
 #  	)  )
+# 
+# cook( "f", params = list(
+# 	"df1" = list( type = "double" ), 
+# 	"df2" = list( type = "double" )
+#  	)  )
+#
 
-cook( "f", params = list(
-		"df1" = list( type = "double" ), 
-		"df2" = list( type = "double" )
- 	)  )
+# # manual editing needed so that the dexp, qexp, etc ...
+# # are parameterized by shape instead of rate
+# cook( "exp", params = list( 
+# 	"rate" = list( type = "double", default = "1.0" )
+# ) )
+# 
 
+# cook( "cauchy", params = list( 
+# 	"location" = list( type = "double", default = "0.0" ), 
+# 	"scale" = list( type = "double", default = "1.0" )
+# ) )
+
+# cook( "geom", params = list( 
+# 	prob = list( type = "double" ) 
+# 	) )
+
+# cook( "hyper", params = list( 
+# 	mm = list( type = "double" ), 
+# 	nn = list( type = "double" ),
+# 	kk = list( type = "double" )
+# 	) )
+
+# cook( "nt", params = list(
+# 	"df" = list( type = "double" ), 
+# 	"ncp" = list( type = "double" )
+# ) )
+
+# cook( "nchisq", params = list(
+# 	"df" = list( type = "double" ), 
+# 	"ncp" = list( type = "double" )
+# ) )
+ 
+# cook( "nbeta", params = list( 
+# 	"shape1" = list( type = "double" ), 
+# 	"shape2" = list( type = "double" ), 
+# 	"ncp" = list( type = "double" ) 
+# ) )
+
+# cook( "nf", params = list(
+# 	"df1" = list( type = "double" ), 
+# 	"df2" = list( type = "double" ), 
+# 	"ncp" = list( type = "double" )
+#  	)  )
+
+# cook( "nbinom", params = list(
+# 	"size" = list( type = "int" ),
+# 	"prob" = list( type = "double" )
+#  	)  )
+# 
+# cook( "nbinom_mu", params = list(
+# 	"size" = list( type = "int" ),
+# 	"mu"   = list( type = "double" )
+#  	)  )
+



More information about the Rcpp-commits mailing list