[Rcpp-commits] r1955 - 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 13:09:31 CEST 2010


Author: romain
Date: 2010-08-09 13:09:31 +0200 (Mon, 09 Aug 2010)
New Revision: 1955

Added:
   pkg/Rcpp/inst/include/Rcpp/stats/f.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)f

Modified: pkg/Rcpp/NEWS
===================================================================
--- pkg/Rcpp/NEWS	2010-08-09 09:38:31 UTC (rev 1954)
+++ pkg/Rcpp/NEWS	2010-08-09 11:09:31 UTC (rev 1955)
@@ -1,6 +1,8 @@
 0.8.6   (future)
 
-	o	new sugar functions (dpq)(unif|norm|gamma|chisq|lnorm|weibull|logis|pois|binom|t|beta)
+	o	new sugar functions for statistical distributions (d-p-q functions) with
+		distributions : unif, norm, gamma, chisq, lnorm, weibull, logis, f, 
+		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 09:38:31 UTC (rev 1954)
+++ pkg/Rcpp/TODO	2010-08-09 11:09:31 UTC (rev 1955)
@@ -65,7 +65,7 @@
     
     o   Compound operators: ++,--,+=, -=, ...
     
-    o	other statistical distribution functions : nchisq, f, 
+    o	other statistical distribution functions : nchisq,
     	multinom, cauchy, exp, geom, hyper, nbinom, nbinom_mu,
     	nbeta, nf, nt, tukey, wilcox, signrank
     

Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-08-09 09:38:31 UTC (rev 1954)
+++ pkg/Rcpp/inst/ChangeLog	2010-08-09 11:09:31 UTC (rev 1955)
@@ -1,6 +1,6 @@
 2010-08-09  Romain Francois <romain at r-enthusiasts.com>
 
-	* inst/include/Rcpp/stats/lnorm.h: Added d-p-q (lnorm|weibull|logis)
+	* inst/include/Rcpp/stats/lnorm.h: Added d-p-q (lnorm|weibull|logis|f)
 	generated by the script
 
 2010-08-06  Douglas Bates  <bates at stat.wisc.edu>

Added: pkg/Rcpp/inst/include/Rcpp/stats/f.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/f.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/stats/f.h	2010-08-09 11:09:31 UTC (rev 1955)
@@ -0,0 +1,118 @@
+
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// auto generated file (from script/stats.R) 
+//
+// f.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__f_h
+#define Rcpp__stats__f_h
+
+namespace Rcpp {
+namespace stats {
+namespace impl {
+
+	template <bool NA, typename T>
+	class DF : public Rcpp::VectorBase< REALSXP, NA, DF<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		DF( const VEC_TYPE& vec_, double df1_, double df2_ , bool log_ = false ) : 
+			vec(vec_), df1(df1_), df2(df2_) , log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::df( vec[i], df1, df2 , log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		double df1; double df2; 
+		int log;
+	
+	};
+
+	template <bool NA, typename T>
+	class PF : public Rcpp::VectorBase< REALSXP, NA, PF<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		PF( const VEC_TYPE& vec_, double df1_, double df2_ ,
+			   bool lower_tail = true, bool log_ = false ) : 
+			vec(vec_), df1(df1_), df2(df2_) , lower(lower_tail), log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::pf( vec[i], df1, df2, lower, log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		double df1; double df2; 
+		int lower, log;
+	
+	};
+
+	template <bool NA, typename T>
+	class QF : public Rcpp::VectorBase< REALSXP, NA, QF<NA,T> >{
+	public:
+		typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+	
+		QF( const VEC_TYPE& vec_, double df1_, double df2_ ,
+			   bool lower_tail = true, bool log_ = false ) : 
+			vec(vec_), df1(df1_), df2(df2_), lower(lower_tail), log(log_) {}
+		
+		inline double operator[]( int i) const {
+			return ::qf( vec[i], df1, df2, lower, log );
+		}
+		
+		inline int size() const { return vec.size(); }
+		
+	private:
+		const VEC_TYPE& vec;
+		double df1; double df2; 
+		int lower, log;
+	
+	};
+	
+} // impl
+
+template <bool NA, typename T>
+inline impl::DF<NA,T> df( const Rcpp::VectorBase<REALSXP,NA,T>& x, double df1_, double df2_, bool log = false ) {
+	return impl::DF<NA,T>( x, df1_, df2_, log ); 
+}
+
+template <bool NA, typename T>
+inline impl::PF<NA,T> pf( const Rcpp::VectorBase<REALSXP,NA,T>& x, double df1_, double df2_, bool lower = true, bool log = false ) {
+	return impl::PF<NA,T>( x, df1_, df2_, lower, log ); 
+}
+
+template <bool NA, typename T>
+inline impl::QF<NA,T> qf( const Rcpp::VectorBase<REALSXP,NA,T>& x, double df1_, double df2_, bool lower = true, bool log = false ) {
+	return impl::QF<NA,T>( x, df1_, df2_, lower, log ); 
+}
+	
+}
+}
+
+#endif
+

Modified: pkg/Rcpp/inst/include/Rcpp/stats/stats.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/stats.h	2010-08-09 09:38:31 UTC (rev 1954)
+++ pkg/Rcpp/inst/include/Rcpp/stats/stats.h	2010-08-09 11:09:31 UTC (rev 1955)
@@ -31,6 +31,7 @@
 #include <Rcpp/stats/lnorm.h>
 #include <Rcpp/stats/weibull.h>
 #include <Rcpp/stats/logis.h>
+#include <Rcpp/stats/f.h>
 
 #include <Rcpp/stats/binom.h>
 #include <Rcpp/stats/pois.h>

Modified: scripts/stats.R
===================================================================
--- scripts/stats.R	2010-08-09 09:38:31 UTC (rev 1954)
+++ scripts/stats.R	2010-08-09 11:09:31 UTC (rev 1955)
@@ -186,9 +186,14 @@
 # 		"shape" = list( type = "double" ), 
 # 		"scale" = list( type = "double", default = "1.0" )
 #  	)  )
+# 
+# cook( "logis", params = list(
+# 		"location" = list( type = "double", default = "0.0" ), 
+# 		"scale" = list( type = "double", default = "1.0" )
+#  	)  )
 
-cook( "logis", params = list(
-		"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" )
  	)  )
 



More information about the Rcpp-commits mailing list