Skip to content

Commit 70d14fc

Browse files
authored
Merge pull request #55 from rstub/long-vec
Support long vectors
2 parents 915b200 + 8d5ba30 commit 70d14fc

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2018-05-25 Ralf Stubner <ralf.stubner@daqana.com>
2+
3+
* inst/include/RcppEigenWrap.h: Use Rf_xlength and R_xlen_t to
4+
support long vectors
5+
16
2018-02-07 Dirk Eddelbuettel <edd@debian.org>
27

38
* patches/eigen-3.3.4.diff: Diff to upstream Eigen 3.3.4,

inst/include/RcppEigenWrap.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ namespace Rcpp{
8787
T::ColsAtCompileTime>,
8888
const T&>::type objCopy(obj);
8989
int m = obj.rows(), n = obj.cols();
90-
SEXP ans = PROTECT(::Rcpp::wrap(objCopy.data(), objCopy.data() + m * n));
90+
R_xlen_t size = static_cast<R_xlen_t>(m) * n;
91+
SEXP ans = PROTECT(::Rcpp::wrap(objCopy.data(), objCopy.data() + size));
9192
if( T::ColsAtCompileTime != 1 ) {
9293
SEXP dd = PROTECT(::Rf_allocVector(INTSXP, 2));
9394
int *d = INTEGER(dd);
@@ -159,7 +160,7 @@ namespace Rcpp{
159160
template <typename T, int RTYPE>
160161
class Eigen_Matrix_Exporter {
161162
public:
162-
Eigen_Matrix_Exporter(SEXP x) : vec(x), d_ncol(1), d_nrow(Rf_length(x)) {
163+
Eigen_Matrix_Exporter(SEXP x) : vec(x), d_ncol(1), d_nrow(Rf_xlength(x)) {
163164
if (TYPEOF(x) != RTYPE)
164165
throw std::invalid_argument("Wrong R type for mapped vector");
165166
if (::Rf_isMatrix(x)) {
@@ -254,7 +255,7 @@ namespace Rcpp{
254255
int d_ncol, d_nrow ;
255256

256257
public:
257-
Exporter(SEXP x) : vec(x), d_ncol(1), d_nrow(Rf_length(x)) {
258+
Exporter(SEXP x) : vec(x), d_ncol(1), d_nrow(Rf_xlength(x)) {
258259
if (TYPEOF(x) != RTYPE)
259260
throw std::invalid_argument("Wrong R type for mapped matrix");
260261
if (::Rf_isMatrix(x)) {
@@ -274,7 +275,7 @@ namespace Rcpp{
274275
int d_ncol, d_nrow ;
275276

276277
public:
277-
Exporter(SEXP x) : vec(x), d_ncol(1), d_nrow(Rf_length(x)) {
278+
Exporter(SEXP x) : vec(x), d_ncol(1), d_nrow(Rf_xlength(x)) {
278279
if (TYPEOF(x) != RTYPE)
279280
throw std::invalid_argument("Wrong R type for mapped 2D array");
280281
if (::Rf_isMatrix(x)) {

0 commit comments

Comments
 (0)