[Rcpp-commits] r3250 - in pkg/Rcpp: . inst/include/Rcpp/iostream
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Oct 31 20:48:01 CET 2011
Author: edd
Date: 2011-10-31 20:48:01 +0100 (Mon, 31 Oct 2011)
New Revision: 3250
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/include/Rcpp/iostream/Rostream.h
Log:
committing (albeit commented-out) Jelmer's patch for operator<< -- this may
need more work and/or go to RObject.h or ...
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2011-10-31 18:51:17 UTC (rev 3249)
+++ pkg/Rcpp/ChangeLog 2011-10-31 19:48:01 UTC (rev 3250)
@@ -1,11 +1,17 @@
2011-10-31 Romain Francois <romain at r-enthusiasts.com>
- * include/Rcpp/int64/int64_lite.h: handling int64_t and uint64_t types,
- based on the int64 package
- * include/Rcpp/internal/wrap.h: new dispatch layers to handle int64_t,
- uint64_t and containers of these
- * DESCRIPTION: new depending on int64
+ * include/Rcpp/int64/int64_lite.h: handling int64_t and uint64_t types,
+ based on the int64 package
+ * include/Rcpp/internal/wrap.h: new dispatch layers to handle int64_t,
+ uint64_t and containers of these
+ * DESCRIPTION: new depending on int64
+2011-10-28 Dirk Eddelbuettel <edd at debian.org>
+
+ * inst/include/Rcpp/iostream/Rostream.h (Rcpp): Added tentative patch
+ for operator<< also contributed by Jelmer Ypma -- but kept commented
+ out for now
+
2011-10-25 Dirk Eddelbuettel <edd at debian.org>
* src/Rostream.cpp: Patch by Jelmer Ypma which adds a new device
Modified: pkg/Rcpp/inst/include/Rcpp/iostream/Rostream.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/iostream/Rostream.h 2011-10-31 18:51:17 UTC (rev 3249)
+++ pkg/Rcpp/inst/include/Rcpp/iostream/Rostream.h 2011-10-31 19:48:01 UTC (rev 3250)
@@ -22,9 +22,10 @@
#ifndef __ROSTREAM_H__
#define __ROSTREAM_H__
-#include <RcppCommon.h>
-#include <Rcpp/iostream/Rstreambuf.h>
+#include <iomanip> // USES setw
+#include <Rcpp.h>
+
// modified from
// http://stackoverflow.com/questions/243696/correctly-over-loading-a-stringbuf-to-replace-cout-in-a-matlab-mex-file
@@ -42,6 +43,45 @@
// declare global variable
extern Rostream Rcout;
+ // template <int RTYPE> std::ostream& operator<<(std::ostream& out, const Rcpp::Vector< RTYPE >& v) {
+ // out << "[1] " << v[0];
+ // for (int i=1;i<v.size();i++) {
+ // out << " " << v[i];
+ // }
+ // return out; // for multiple << operators.
+ // }
+
+ // template <int RTYPE> std::ostream& operator<<(std::ostream& out, const Rcpp::Matrix< RTYPE >& m) {
+ // // width of columns showing values
+ // int val_col_width = 12;
+
+ // // width of first column, showing row index
+ // int max_row_idx = m.rows() + 1;
+ // int idx_col_width = 0;
+ // while(max_row_idx > 0) {
+ // max_row_idx /= 10;
+ // idx_col_width++;
+ // }
+
+ // // print column headers (add 1 to have R indexing)
+ // out << std::setw( val_col_width + idx_col_width + 3 ) << "[,1]";
+ // for (int jcol=1;jcol<m.ncol();jcol++) {
+ // out << std::setw( val_col_width-2 ) << "[," << jcol+1 << "]";
+ // }
+ // out << std::endl;
+ // for (int irow=0;irow<m.nrow();irow++) {
+ // // print row header (add 1 to have R indexing)
+ // out << "[" << std::setw( idx_col_width ) << irow+1 << ",]";
+
+ // // print values in current row
+ // for (int jcol=0;jcol<m.ncol();jcol++) {
+ // out << std::setw( val_col_width ) << m( irow, jcol );
+ // }
+ // out << std::endl;
+ // }
+ // return out; // for multiple << operators.
+ // }
+
}
#endif
More information about the Rcpp-commits
mailing list