[Rcpp-commits] r1944 - in pkg/Rcpp: . inst/include/Rcpp/stats inst/unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Aug 6 10:21:37 CEST 2010
Author: romain
Date: 2010-08-06 10:21:37 +0200 (Fri, 06 Aug 2010)
New Revision: 1944
Added:
pkg/Rcpp/inst/include/Rcpp/stats/chisq.h
Modified:
pkg/Rcpp/NEWS
pkg/Rcpp/TODO
pkg/Rcpp/inst/include/Rcpp/stats/stats.h
pkg/Rcpp/inst/unitTests/runit.stats.R
Log:
(dpq)chisq (not tested yet)
Modified: pkg/Rcpp/NEWS
===================================================================
--- pkg/Rcpp/NEWS 2010-08-06 08:11:35 UTC (rev 1943)
+++ pkg/Rcpp/NEWS 2010-08-06 08:21:37 UTC (rev 1944)
@@ -1,6 +1,6 @@
0.8.6 (future)
- o new sugar functions (dpq)(unif|norm|pois|binom|t|beta)
+ o new sugar functions (dpq)(unif|norm|gamma|chisq|pois|binom|t|beta)
o new vignette Rcpp-quickref : quick reference guide of Rcpp API
Modified: pkg/Rcpp/TODO
===================================================================
--- pkg/Rcpp/TODO 2010-08-06 08:11:35 UTC (rev 1943)
+++ pkg/Rcpp/TODO 2010-08-06 08:21:37 UTC (rev 1944)
@@ -65,8 +65,9 @@
o Compound operators: ++,--,+=, -=, ...
- o other statistical distribution functions : dnorm, etc ...
- as well as qbinom, pbinom, rbinom, qpois, ppois, rpois, ...
+ o other statistical distribution functions : lnorm, nchisq, f,
+ multinom, cauchy, exp, geom, hyper, nbinom, nbinom_mu, weibull,
+ logis, nbeta, nf, nt, tukey, wilcox, signrank
o sum : deal with missing values
Added: pkg/Rcpp/inst/include/Rcpp/stats/chisq.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/chisq.h (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/stats/chisq.h 2010-08-06 08:21:37 UTC (rev 1944)
@@ -0,0 +1,118 @@
+
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// auto generated file (from script/stats.R)
+//
+// chisq.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__chisq_h
+#define Rcpp__stats__chisq_h
+
+namespace Rcpp {
+namespace stats {
+namespace impl {
+
+ template <bool NA, typename T>
+ class DChisq : public Rcpp::VectorBase< REALSXP, NA, DChisq<NA,T> >{
+ public:
+ typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+
+ DChisq( const VEC_TYPE& vec_, double df_ , bool log_ = false ) :
+ vec(vec_), df(df_) , log(log_) {}
+
+ inline double operator[]( int i) const {
+ return ::dchisq( vec[i], df , log );
+ }
+
+ inline int size() const { return vec.size(); }
+
+ private:
+ const VEC_TYPE& vec;
+ double df;
+ int log;
+
+ };
+
+ template <bool NA, typename T>
+ class PChisq : public Rcpp::VectorBase< REALSXP, NA, PChisq<NA,T> >{
+ public:
+ typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+
+ PChisq( const VEC_TYPE& vec_, double df_ ,
+ bool lower_tail = true, bool log_ = false ) :
+ vec(vec_), df(df_) , lower(lower_tail), log(log_) {}
+
+ inline double operator[]( int i) const {
+ return ::pchisq( vec[i], df, lower, log );
+ }
+
+ inline int size() const { return vec.size(); }
+
+ private:
+ const VEC_TYPE& vec;
+ double df;
+ int lower, log;
+
+ };
+
+ template <bool NA, typename T>
+ class QChisq : public Rcpp::VectorBase< REALSXP, NA, QChisq<NA,T> >{
+ public:
+ typedef typename Rcpp::VectorBase<REALSXP,NA,T> VEC_TYPE;
+
+ QChisq( const VEC_TYPE& vec_, double df_ ,
+ bool lower_tail = true, bool log_ = false ) :
+ vec(vec_), df(df_), lower(lower_tail), log(log_) {}
+
+ inline double operator[]( int i) const {
+ return ::qchisq( vec[i], df, lower, log );
+ }
+
+ inline int size() const { return vec.size(); }
+
+ private:
+ const VEC_TYPE& vec;
+ double df;
+ int lower, log;
+
+ };
+
+} // impl
+
+template <bool NA, typename T>
+inline impl::DChisq<NA,T> dchisq( const Rcpp::VectorBase<REALSXP,NA,T>& x, double df_, bool log = false ) {
+ return impl::DChisq<NA,T>( x, df_, log );
+}
+
+template <bool NA, typename T>
+inline impl::PChisq<NA,T> pchisq( const Rcpp::VectorBase<REALSXP,NA,T>& x, double df_, bool lower = true, bool log = false ) {
+ return impl::PChisq<NA,T>( x, df_, lower, log );
+}
+
+template <bool NA, typename T>
+inline impl::QChisq<NA,T> qchisq( const Rcpp::VectorBase<REALSXP,NA,T>& x, double df_, bool lower = true, bool log = false ) {
+ return impl::QChisq<NA,T>( x, df_, lower, log );
+}
+
+}
+}
+
+#endif
+
Modified: pkg/Rcpp/inst/include/Rcpp/stats/stats.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/stats.h 2010-08-06 08:11:35 UTC (rev 1943)
+++ pkg/Rcpp/inst/include/Rcpp/stats/stats.h 2010-08-06 08:21:37 UTC (rev 1944)
@@ -25,6 +25,7 @@
#include <Rcpp/stats/unif.h>
#include <Rcpp/stats/norm.h>
#include <Rcpp/stats/gamma.h>
+#include <Rcpp/stats/chisq.h>
#include <Rcpp/stats/beta.h>
#include <Rcpp/stats/t.h>
Modified: pkg/Rcpp/inst/unitTests/runit.stats.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.stats.R 2010-08-06 08:11:35 UTC (rev 1943)
+++ pkg/Rcpp/inst/unitTests/runit.stats.R 2010-08-06 08:21:37 UTC (rev 1944)
@@ -486,4 +486,5 @@
}
# TODO: test.stats.qgamma
+# TODO: test.stats.(dpq)chisq
More information about the Rcpp-commits
mailing list