[Rcpp-commits] r3670 - in pkg/RcppCNPy: inst src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 6 04:39:39 CEST 2012


Author: edd
Date: 2012-07-06 04:39:39 +0200 (Fri, 06 Jul 2012)
New Revision: 3670

Modified:
   pkg/RcppCNPy/inst/NEWS.Rd
   pkg/RcppCNPy/src/cnpyMod.cpp
Log:
 o Disabled "integer" support: we get different results on 32 and 64 bit OSs
   and this should really be taken care of at the library layer


Modified: pkg/RcppCNPy/inst/NEWS.Rd
===================================================================
--- pkg/RcppCNPy/inst/NEWS.Rd	2012-07-06 01:08:16 UTC (rev 3669)
+++ pkg/RcppCNPy/inst/NEWS.Rd	2012-07-06 02:39:39 UTC (rev 3670)
@@ -7,6 +7,7 @@
     \item Added automatic use of transpose to automagically account for
     Fortran-vs-C major storage defaults between Python and R.
     \item Added support for reading gzip'ed files ending in ".npy.gz"
+  }
 }
 \section{Changes in version 0.0.1 (2012-07-04)}{
   \itemize{

Modified: pkg/RcppCNPy/src/cnpyMod.cpp
===================================================================
--- pkg/RcppCNPy/src/cnpyMod.cpp	2012-07-06 01:08:16 UTC (rev 3669)
+++ pkg/RcppCNPy/src/cnpyMod.cpp	2012-07-06 02:39:39 UTC (rev 3670)
@@ -61,9 +61,15 @@
         if (type == "numeric") {
             double *p = reinterpret_cast<double*>(arr.data);
             ret = Rcpp::NumericVector(p, p + shape[0]);
-        } else if (type == "integer") {
-            int *p = reinterpret_cast<int*>(arr.data);
-            ret = Rcpp::IntegerVector(p, p + shape[0]);
+//         } else if (type == "integer") {
+// #ifdef __i386__
+//             Rcpp::Rcout << "i386 sees " << sizeof(void*) << std::endl;
+//             long int *p = reinterpret_cast<long int*>(arr.data);
+// #else
+//             Rcpp::Rcout << "x64 sees " << sizeof(void*) << std::endl;
+//             long int *p = reinterpret_cast<long int*>(arr.data);
+// #endif
+//             ret = Rcpp::IntegerVector(p, p + shape[0]);
         } else {
             arr.destruct();
             REprintf("Unsupported type in npyLoad");
@@ -72,9 +78,19 @@
         if (type == "numeric") {
             // invert dimension for creation, and then tranpose to correct Fortran-vs-C storage
             ret = transpose(Rcpp::NumericMatrix(shape[1], shape[0], reinterpret_cast<double*>(arr.data)));
-        } else if (type == "integer") {
-            // invert dimension for creation, and then tranpose to correct Fortran-vs-C storage
-            ret = transpose(Rcpp::IntegerMatrix(shape[1], shape[0], reinterpret_cast<double*>(arr.data)));
+//         } else if (type == "integer") {
+//             // invert dimension for creation, and then tranpose to correct Fortran-vs-C storage
+// #ifdef __i386__
+//             Rcpp::Rcout << "i386 sees " << sizeof(void*) << std::endl;
+//             ret = transpose(Rcpp::IntegerMatrix(shape[1], shape[0], reinterpret_cast<int*>(arr.data)));
+//             for (int i=0; i<shape[0]*shape[1]; i++){
+//                 Rcpp::Rcout << static_cast<double>(arr.data[i]) << ", ";
+//             }
+//             Rcpp::Rcout << std::endl;
+// #else
+//             Rcpp::Rcout << "x64 sees " << sizeof(void*) << std::endl;
+//             ret = transpose(Rcpp::IntegerMatrix(shape[1], shape[0], reinterpret_cast<long int*>(arr.data)));
+// #endif
         } else {
             arr.destruct();
             REprintf("Unsupported type in npyLoad");



More information about the Rcpp-commits mailing list