[Rinside-commits] r87 - in pkg: inst src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jan 29 05:52:31 CET 2010
Author: edd
Date: 2010-01-29 05:52:29 +0100 (Fri, 29 Jan 2010)
New Revision: 87
Modified:
pkg/inst/ChangeLog
pkg/src/RInside.cpp
pkg/src/RInside.h
Log:
restore assign(vector<vector<double>>)
document other minor changes of today
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2010-01-29 01:47:05 UTC (rev 86)
+++ pkg/inst/ChangeLog 2010-01-29 04:52:29 UTC (rev 87)
@@ -1,3 +1,12 @@
+2010-01-28 Dirk Eddelbuettel <edd at debian.org>
+
+ * src/RInside.{h,cpp}: Restore assign(vector<vector<double>>) which
+ is not (yet?) covered by the more general templated solution
+
+ * src/RInside.h: Minor cleanup regarding logTxt usage
+
+ * src/Makefile: Make sure we find Rcpp.h headers
+
2010-01-27 Romain Francois <francoisromain at free.fr>
* src/RInside.{h,cpp}: include Rcpp.h and use the Rf_ prefixed R API
@@ -3,6 +12,6 @@
functions. stop using macros from Rdefines because they don't
work with R_NOREMAP
-
- * src/RInside.{h,cpp}: using the new Rcpp API assign becomes
+
+ * src/RInside.{h,cpp}: using the new Rcpp API assign becomes
a template and let Rcpp::Environment.assign deal with the type
of the object and how to wrap it. specializations of wrap
Modified: pkg/src/RInside.cpp
===================================================================
--- pkg/src/RInside.cpp 2010-01-29 01:47:05 UTC (rev 86)
+++ pkg/src/RInside.cpp 2010-01-29 04:52:29 UTC (rev 87)
@@ -281,6 +281,20 @@
return rc;
}
+// 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);
+}
+
// specializations of Rcpp wrap template
namespace Rcpp{
Modified: pkg/src/RInside.h
===================================================================
--- pkg/src/RInside.h 2010-01-29 01:47:05 UTC (rev 86)
+++ pkg/src/RInside.h 2010-01-29 04:52:29 UTC (rev 87)
@@ -59,6 +59,9 @@
void assign(const T& object, const std::string& nam){
Rcpp::Environment::global_env().assign( nam, object ) ;
}
+
+ // non-templated version
+ 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