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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 6 14:08:53 CEST 2012


Author: edd
Date: 2012-07-06 14:08:52 +0200 (Fri, 06 Jul 2012)
New Revision: 3671

Modified:
   pkg/RcppCNPy/ChangeLog
   pkg/RcppCNPy/inst/NEWS.Rd
   pkg/RcppCNPy/src/cnpy.h
   pkg/RcppCNPy/src/cnpyMod.cpp
Log:
 o "integer" support now conditional on int64_t / use of -std=c++11


Modified: pkg/RcppCNPy/ChangeLog
===================================================================
--- pkg/RcppCNPy/ChangeLog	2012-07-06 02:39:39 UTC (rev 3670)
+++ pkg/RcppCNPy/ChangeLog	2012-07-06 12:08:52 UTC (rev 3671)
@@ -1,7 +1,10 @@
+2012-07-06  Dirk Eddelbuettel  <edd at debian.org>
+
+	* src/cnpy.h: Include cstdint for int64_t if C++11 has been enabled
+	* src/cnpyMod.cpp (npyLoad): Support integer types if C++11 avail.
+
 2012-07-05  Dirk Eddelbuettel  <edd at dexter>
 
-	* DESCRIPTION (Version): Version 0.0.2
-
 	* src/cnpyMod.cpp: Added transpose() method to transparently deal
 	with the Fortran-vs-C storage order difference between Python and R.
 	Also added support for reading vectors.

Modified: pkg/RcppCNPy/inst/NEWS.Rd
===================================================================
--- pkg/RcppCNPy/inst/NEWS.Rd	2012-07-06 02:39:39 UTC (rev 3670)
+++ pkg/RcppCNPy/inst/NEWS.Rd	2012-07-06 12:08:52 UTC (rev 3671)
@@ -2,10 +2,13 @@
 \title{News for Package \pkg{RcppCNPy}}
 \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
 
-\section{Changes in version 0.0.2 (2012-07-05)}{
+\section{Changes in version 0.0.2 (2012-07-xx)}{
   \itemize{
     \item Added automatic use of transpose to automagically account for
     Fortran-vs-C major storage defaults between Python and R.
+    \item Support for integer types in dependent on the \code{int64_t}
+    type which is available only when the \code{-std=c++0x} switch is
+    used at build-time (and CRAN still discourages use of it)
     \item Added support for reading gzip'ed files ending in ".npy.gz"
   }
 }

Modified: pkg/RcppCNPy/src/cnpy.h
===================================================================
--- pkg/RcppCNPy/src/cnpy.h	2012-07-06 02:39:39 UTC (rev 3670)
+++ pkg/RcppCNPy/src/cnpy.h	2012-07-06 12:08:52 UTC (rev 3671)
@@ -15,7 +15,10 @@
 #include<zlib.h>
 #include<map>
 
-#include <R_ext/Print.h>      // for REprintf
+#ifdef RCPP_HAS_LONG_LONG_TYPES
+#include <cstdint>		// for std::int64_t, needs c++11 switch
+#endif
+#include <R_ext/Print.h>      	// for REprintf
 
 namespace cnpy {
 

Modified: pkg/RcppCNPy/src/cnpyMod.cpp
===================================================================
--- pkg/RcppCNPy/src/cnpyMod.cpp	2012-07-06 02:39:39 UTC (rev 3670)
+++ pkg/RcppCNPy/src/cnpyMod.cpp	2012-07-06 12:08:52 UTC (rev 3671)
@@ -61,15 +61,11 @@
         if (type == "numeric") {
             double *p = reinterpret_cast<double*>(arr.data);
             ret = Rcpp::NumericVector(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]);
+#ifdef RCPP_HAS_LONG_LONG_TYPES
+        } else if (type == "integer") {
+            int64_t *p = reinterpret_cast<int64_t*>(arr.data);
+            ret = Rcpp::IntegerVector(p, p + shape[0]);
+#endif
         } else {
             arr.destruct();
             REprintf("Unsupported type in npyLoad");
@@ -78,19 +74,11 @@
         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
-// #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
+#ifdef RCPP_HAS_LONG_LONG_TYPES
+        } 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<int64_t*>(arr.data)));
+#endif
         } else {
             arr.destruct();
             REprintf("Unsupported type in npyLoad");



More information about the Rcpp-commits mailing list