[Rcpp-commits] r1962 - in pkg/Rcpp/inst: . include/Rcpp/stats/random

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 10 08:26:10 CEST 2010


Author: romain
Date: 2010-08-10 08:26:10 +0200 (Tue, 10 Aug 2010)
New Revision: 1962

Added:
   pkg/Rcpp/inst/include/Rcpp/stats/random/rbeta.h
Modified:
   pkg/Rcpp/inst/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/stats/random/random.h
Log:
rbeta( int n, double a, double b ) 

Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-08-10 06:18:04 UTC (rev 1961)
+++ pkg/Rcpp/inst/ChangeLog	2010-08-10 06:26:10 UTC (rev 1962)
@@ -4,6 +4,8 @@
 
 	* inst/include/Rcpp/stats/random/runif.h: Added runif and runif_
 	
+	* inst/include/Rcpp/stats/random/rbeta.h: Added rbeta and rbeta_
+
 	* inst/include/Rcpp/stats/stats.h : fixed name clash reported on Rcpp-devel
 	http://permalink.gmane.org/gmane.comp.lang.r.rcpp/610
 

Modified: pkg/Rcpp/inst/include/Rcpp/stats/random/random.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/random/random.h	2010-08-10 06:18:04 UTC (rev 1961)
+++ pkg/Rcpp/inst/include/Rcpp/stats/random/random.h	2010-08-10 06:26:10 UTC (rev 1962)
@@ -22,6 +22,7 @@
 #ifndef Rcpp__stats__random_random_h
 #define Rcpp__stats__random_random_h
 
+#include <Rcpp/stats/random/rbeta.h>
 #include <Rcpp/stats/random/rnorm.h>
 #include <Rcpp/stats/random/runif.h>
 

Added: pkg/Rcpp/inst/include/Rcpp/stats/random/rbeta.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/random/rbeta.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/stats/random/rbeta.h	2010-08-10 06:26:10 UTC (rev 1962)
@@ -0,0 +1,56 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// rbeta.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__random_rbeta_h
+#define Rcpp__stats__random_rbeta_h
+
+namespace Rcpp {
+namespace stats {
+
+template <bool seed>
+class BetaGenerator : public Rcpp::Generator<seed,double> {
+public:
+	
+	BetaGenerator( double a_, double b_ ) : a(a_), b(b_) {}
+	
+	inline double operator()() const {
+		return ::dbeta( a, b );
+	}
+	
+private:
+	double a, b ;
+} ;
+
+template <bool seed>
+Rcpp::NumericVector rbeta__impl( int n, double a, double b ){
+	return Rcpp::NumericVector( n, BetaGenerator<seed>( min, max ) ) ;
+}
+inline Rcpp::NumericVector rbeta( int n, double a, double b ){
+	return rbeta__impl<true>( n, a, b );
+}
+inline Rcpp::NumericVector rbeta_( int n, double a, double b ){
+	return rbeta__impl<false>( n, a, b );
+}
+
+}
+}
+
+#endif



More information about the Rcpp-commits mailing list