[Rcpp-commits] r2614 - in pkg/RcppGSL: . inst/doc inst/doc/RcppGSL src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 30 12:41:26 CET 2010


Author: romain
Date: 2010-11-30 12:41:26 +0100 (Tue, 30 Nov 2010)
New Revision: 2614

Removed:
   pkg/RcppGSL/src/RcppGSL.cpp
Modified:
   pkg/RcppGSL/DESCRIPTION
   pkg/RcppGSL/inst/doc/Makefile
   pkg/RcppGSL/inst/doc/RcppGSL/RcppGSL.Rnw
Log:
move functions that help the vignette into the vignette using inline

Modified: pkg/RcppGSL/DESCRIPTION
===================================================================
--- pkg/RcppGSL/DESCRIPTION	2010-11-30 11:29:03 UTC (rev 2613)
+++ pkg/RcppGSL/DESCRIPTION	2010-11-30 11:41:26 UTC (rev 2614)
@@ -22,7 +22,7 @@
   eases the interfaces between R and C++.
 License: GPL (>=2)
 LazyLoad: yes
-Depends: Rcpp (>= 0.8.7)
-Suggests: RUnit
+Depends: Rcpp (>= 0.8.9)
+Suggests: RUnit, inline
 LinkingTo: Rcpp
 SystemRequirements: GNU GSL

Modified: pkg/RcppGSL/inst/doc/Makefile
===================================================================
--- pkg/RcppGSL/inst/doc/Makefile	2010-11-30 11:29:03 UTC (rev 2613)
+++ pkg/RcppGSL/inst/doc/Makefile	2010-11-30 11:41:26 UTC (rev 2614)
@@ -12,6 +12,8 @@
 
 clean:
         # rm RcppGSL.pdf
+	rm -f RcppGSL.Rnw
+	cp RcppGSL/RcppGSL-fake.Rnw RcppGSL.Rnw
 
 RcppGSL.pdf: RcppGSL/RcppGSL.Rnw
 	cp -f RcppGSL/RcppGSL.Rnw .

Modified: pkg/RcppGSL/inst/doc/RcppGSL/RcppGSL.Rnw
===================================================================
--- pkg/RcppGSL/inst/doc/RcppGSL/RcppGSL.Rnw	2010-11-30 11:29:03 UTC (rev 2613)
+++ pkg/RcppGSL/inst/doc/RcppGSL/RcppGSL.Rnw	2010-11-30 11:41:26 UTC (rev 2614)
@@ -24,6 +24,8 @@
 options("width"=65)
 rcppgsl.version <- packageDescription( "RcppGSL" )$Version
 prettyDate <- format(Sys.Date(), "%B %e, %Y")
+require( inline )
+require( RcppGSL )
 @
 % closing $ needed here
 
@@ -296,9 +298,20 @@
 
 The function can then simply be called from \proglang{R} :
 
-<<>>=
+<<results=hide,echo=FALSE>>=
+fx <- cxxfunction( signature( vec_ = "integer" ), '
+  RcppGSL::vector<int> vec = as< RcppGSL::vector<int> >(vec_) ;
+  int res = std::accumulate( vec.begin(), vec.end(), 0 ) ;
+  vec.free() ;  // we need to free vec after use
+  return wrap( res ) ;
+', plugin = "RcppGSL" )
+@
+<<eval=FALSE>>=
 .Call( "sum_gsl_vector_int", 1:10 )
 @
+<<echo=FALSE>>=
+fx(1:10)
+@
 
 A second example shows a simple function that grabs elements of an
 R list as \verb|gsl_vector| objects using implicit conversion mechanisms
@@ -329,10 +342,33 @@
 
 <<>>=
 data <- list( x = seq(0,1,length=10), y = 1:10 )
+@
+<<eval=FALSE>>=
 .Call( "gsl_vector_sum_2", data )
 @
+<<results=hide, echo=FALSE>>=
+fx2 <- cxxfunction( signature( data_ = "list" ), '
+    List data(data_) ;
 
+  // grab "x" as a gsl_vector through the RcppGSL::vector<double> class
+  RcppGSL::vector<double> x = data["x"] ;
 
+  // grab "y" as a gsl_vector through the RcppGSL::vector<int> class
+  RcppGSL::vector<int> y = data["y"] ;
+  double res = 0.0 ;
+  for( size_t i=0; i< x->size; i++){
+    res += x[i] * y[i] ;
+  }
+
+  // as usual with GSL, we need to explicitely free the memory
+  x.free() ;
+  y.free() ;
+
+  // return the result
+  return wrap(res);
+', plugin = "RcppGSL" )
+@
+
 \subsection{Mapping}
 
 Table~\ref{tab:mappingVectors} shows the mapping between types defined by the

Deleted: pkg/RcppGSL/src/RcppGSL.cpp
===================================================================
--- pkg/RcppGSL/src/RcppGSL.cpp	2010-11-30 11:29:03 UTC (rev 2613)
+++ pkg/RcppGSL/src/RcppGSL.cpp	2010-11-30 11:41:26 UTC (rev 2614)
@@ -1,52 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
-//
-// RcppGSL.cpp: Rcpp/GSL glue
-//
-// Copyright (C)  2010 Dirk Eddelbuettel, Romain Francois
-//
-// This file is part of RcppGSL.
-//
-// RcppGSL 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.
-//
-// RcppGSL 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 RcppGSL.  If not, see <http://www.gnu.org/licenses/>.
-
-#include <RcppGSL.h>
-
-// helping the vignette
-RCPP_FUNCTION_1( int, sum_gsl_vector_int, RcppGSL::vector<int> vec){
-  int res = std::accumulate( vec.begin(), vec.end(), 0 ) ;
-  vec.free() ;
-  return res ;
-}
-
-RCPP_FUNCTION_1( double, gsl_vector_sum_2, Rcpp::List data ){
-  // grab "x" as a gsl_vector through
-  // the RcppGSL::vector<double> class
-  RcppGSL::vector<double> x = data["x"] ;
-
-  // grab "y" as a gsl_vector through
-  // the RcppGSL::vector<int> class
-  RcppGSL::vector<int> y = data["y"] ;
-  double res = 0.0 ;
-  for( size_t i=0; i< x->size; i++){
-    res += x[i] * y[i] ;
-  }
-
-  // as usual with GSL, we need to explicitely free the
-  // memory
-  x.free() ;
-  y.free() ;
-
-  // return the result
-  return res ;
-}
-



More information about the Rcpp-commits mailing list