[Rinside-commits] r91 - in pkg: . inst src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jan 30 19:14:51 CET 2010


Author: romain
Date: 2010-01-30 19:14:51 +0100 (Sat, 30 Jan 2010)
New Revision: 91

Modified:
   pkg/DESCRIPTION
   pkg/inst/ChangeLog
   pkg/src/RInside.cpp
   pkg/src/RInside.h
Log:
use Rcpp 0.7.3.6 wrap specialization

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2010-01-30 18:09:49 UTC (rev 90)
+++ pkg/DESCRIPTION	2010-01-30 18:14:51 UTC (rev 91)
@@ -15,7 +15,7 @@
  Several examples are provided in the examples/ directory of
  the installed package, and Doxygen-generated documentation of
  the C++ classes is included as well.
-Depends: R (>= 2.10.0), Rcpp (>= 0.7.3)
+Depends: R (>= 2.10.0), Rcpp (>= 0.7.3.5)
 SystemRequirements: None
 URL: http://dirk.eddelbuettel.com/code/rinside.html
 License: GPL-2

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2010-01-30 18:09:49 UTC (rev 90)
+++ pkg/inst/ChangeLog	2010-01-30 18:14:51 UTC (rev 91)
@@ -1,3 +1,10 @@
+2010-01-28  Romain Francois <francoisromain at free.fr>
+
+	* src/RInside.{h,cpp}: Retire assign(vector<vector<double>> )
+	because now this can be taken care of by template specialization
+	
+	* DESCRIPTION: require Rcpp 0.7.3.6
+
 2010-01-28  Dirk Eddelbuettel  <edd at debian.org>
 
 	* src/RInside.{h,cpp}: Restore assign(vector<vector<double>>) which

Modified: pkg/src/RInside.cpp
===================================================================
--- pkg/src/RInside.cpp	2010-01-30 18:09:49 UTC (rev 90)
+++ pkg/src/RInside.cpp	2010-01-30 18:14:51 UTC (rev 91)
@@ -282,24 +282,24 @@
 }
 
 // assign for vector< vector< double > >
-void RInside::assign(const std::vector< std::vector< double > > & mat, const std::string & nam) {
-    int nx = mat.size();
-    int ny = mat[0].size();
-    SEXP sexpmat = PROTECT(Rf_allocMatrix(REALSXP, nx, ny));
-    for(int i = 0; i < nx; i++) {
-	for(int j = 0; j < ny; j++) {
-	    REAL(sexpmat)[i + nx*j] = mat[i][j];
-	}
-    }
-    Rf_setVar(Rf_install((char*) nam.c_str()), sexpmat, R_GlobalEnv);  // now set it
-    UNPROTECT(1);
-}
+//void RInside::assign(const std::vector< std::vector< double > > & mat, const std::string & nam) {
+//    int nx = mat.size();
+//    int ny = mat[0].size();
+//    SEXP sexpmat = PROTECT(Rf_allocMatrix(REALSXP, nx, ny));
+//    for(int i = 0; i < nx; i++) {
+//	for(int j = 0; j < ny; j++) {
+//	    REAL(sexpmat)[i + nx*j] = mat[i][j];
+//	}
+//    }
+//    Rf_setVar(Rf_install((char*) nam.c_str()), sexpmat, R_GlobalEnv);  // now set it
+//    UNPROTECT(1);
+//}
 
 // specializations of Rcpp wrap template
 
 namespace Rcpp{
 
-NumericVector wrap(const std::vector< std::vector< double > > & v) {
+template<> SEXP wrap(const std::vector< std::vector< double > > & v) {
     
     /* this just assumes this is not a rugged array */
     int nx = v.size();
@@ -312,12 +312,11 @@
 	    p[i + nx*j] = v[i][j];
 	}
     }
-    NumericVector out(sexpmat) ;
     UNPROTECT(1);
-    return out ;
+    return sexpmat ;
 }
 
-IntegerVector wrap(const std::vector< std::vector< int > > & v) {
+template<> SEXP wrap(const std::vector< std::vector< int > > & v) {
     int nx = v.size();
     int ny = v[0].size();
     SEXP sexpmat = PROTECT(Rf_allocMatrix(INTSXP, nx, ny));
@@ -327,9 +326,8 @@
 	    p[i + nx*j] = v[i][j];
 	}
     }
-    IntegerVector out(sexpmat) ;
     UNPROTECT(1);
-    return out ;
+    return sexpmat ;
 }
 
 }

Modified: pkg/src/RInside.h
===================================================================
--- pkg/src/RInside.h	2010-01-30 18:09:49 UTC (rev 90)
+++ pkg/src/RInside.h	2010-01-30 18:14:51 UTC (rev 91)
@@ -37,8 +37,8 @@
 
 namespace Rcpp{
 /* specializations of wrap, this should probably go in Rcpp */
-IntegerVector wrap( const std::vector< std::vector<int> >& v) ;
-NumericVector wrap( const std::vector< std::vector<double> >& v) ;
+template<> SEXP wrap< std::vector< std::vector<int> > >( const std::vector< std::vector<int> >& v) ;
+template<> SEXP wrap< std::vector< std::vector<double> > >( const std::vector< std::vector<double> >& v) ;
 }
 
 class RInside {
@@ -61,7 +61,7 @@
     }
     
     // non-templated version
-    void assign(const std::vector< std::vector< double > > & mat, const std::string & nam);
+    // void assign(const std::vector< std::vector< double > > & mat, const std::string & nam);
 
     RInside(const int argc, const char* const argv[]);
     ~RInside();



More information about the Rinside-commits mailing list