[Rcpp-commits] r3846 - in pkg/Rcpp: . inst inst/include inst/include/Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Oct 28 20:57:54 CET 2012
Author: edd
Date: 2012-10-28 20:57:54 +0100 (Sun, 28 Oct 2012)
New Revision: 3846
Added:
pkg/Rcpp/inst/include/Rcpp/Rmath.h
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/DESCRIPTION
pkg/Rcpp/inst/NEWS.Rd
pkg/Rcpp/inst/include/Rcpp.h
Log:
starting to fill a namespace 'R' with Rmath functions
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2012-10-27 22:17:03 UTC (rev 3845)
+++ pkg/Rcpp/ChangeLog 2012-10-28 19:57:54 UTC (rev 3846)
@@ -1,3 +1,10 @@
+2012-10-28 Dirk Eddelbuettel <edd at debian.org>
+
+ * inst/include/Rcpp/Rmath.h: Beginnings of a namespave 'R' around
+ Rmath functions so that Rcpp users can call the (scalar) functions
+ R::pnorm() which helps with adapting or integrating programs writting
+ outside of Rcpp
+
2012-10-27 Dirk Eddelbuettel <edd at debian.org>
* inst/include/Rcpp/module/macros.h: Add forward declaration of class
Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION 2012-10-27 22:17:03 UTC (rev 3845)
+++ pkg/Rcpp/DESCRIPTION 2012-10-28 19:57:54 UTC (rev 3846)
@@ -1,6 +1,6 @@
Package: Rcpp
Title: Seamless R and C++ Integration
-Version: 0.9.15.4
+Version: 0.9.15.5
Date: $Date$
Author: Dirk Eddelbuettel and Romain Francois, with contributions
by Douglas Bates and John Chambers
Modified: pkg/Rcpp/inst/NEWS.Rd
===================================================================
--- pkg/Rcpp/inst/NEWS.Rd 2012-10-27 22:17:03 UTC (rev 3845)
+++ pkg/Rcpp/inst/NEWS.Rd 2012-10-28 19:57:54 UTC (rev 3846)
@@ -5,6 +5,9 @@
\section{Changes in Rcpp version 0.9.16 (future)}{
\itemize{
\item Exposed methods for class Foo can now return a Foo*
+ [ TODO -- Lots more Rcpp modules work to be described ? ]
+ \item Provide a namespace 'R' for the standalone Rmath library so
+ that Rcpp users can access those functions too
}
}
Added: pkg/Rcpp/inst/include/Rcpp/Rmath.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Rmath.h (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/Rmath.h 2012-10-28 19:57:54 UTC (rev 3846)
@@ -0,0 +1,43 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+//
+// Rmath.h: Rcpp R/C++ interface class library -- Wrappers for R's Rmath API
+//
+// Copyright (C) 2010 - 2012 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_Rmath_h
+#define Rcpp_Rmath_h
+
+namespace R {
+
+ // see R's Rmath.h as well as Writing R Extension
+
+ /* Random Number Generators */
+ inline double norm_rand(void) { return ::norm_rand(); }
+ inline double unif_rand(void) { return ::unif_rand(); }
+ inline double exp_rand(void) { return ::exp_rand(); }
+
+ /* Normal Distribution */
+ inline double dnorm(double x, double mu, double sigma, int lg) { return ::Rf_dnorm4(x, mu, sigma, lg); }
+ inline double pnorm(double x, double mu, double sigma, int lt, int lg) { return ::Rf_pnorm5(x, mu, sigma, lt, lg); }
+ inline double qnorm(double x, double mu, double sigma, int lt, int lg) { return ::Rf_qnorm5(x, mu, sigma, lt, lg); }
+ inline double rnorm(double mu, double sigma) { return ::Rf_rnorm(mu, sigma); }
+ inline void pnorm_both(double x, double *cum, double *ccum, int lt, int lg) { return ::Rf_pnorm_both(x, cum, ccum, lt, lg); }
+
+}
+
+#endif
Modified: pkg/Rcpp/inst/include/Rcpp.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp.h 2012-10-27 22:17:03 UTC (rev 3845)
+++ pkg/Rcpp/inst/include/Rcpp.h 2012-10-28 19:57:54 UTC (rev 3846)
@@ -68,4 +68,7 @@
#include <Rcpp/sugar/sugar.h>
#include <Rcpp/stats/stats.h>
+// wrappers for R API 'scalar' functions
+#include <Rcpp/Rmath.h>
+
#endif
More information about the Rcpp-commits
mailing list