Bug 16198 - Enable long vector support in cbind()
Summary: Enable long vector support in cbind()
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: R-devel (trunk)
Hardware: All All
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-02-09 12:44 UTC by Simen Gaure
Modified: 2015-02-12 16:29 UTC (History)
1 user (show)

See Also:


Attachments
Short R program which provokes the error (919 bytes, text/plain)
2015-02-09 12:44 UTC, Simen Gaure
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simen Gaure 2015-02-09 12:44:58 UTC
Created attachment 1739 [details]
Short R program which provokes the error

cbind(a,b) where a and b are long vectors fails with the message

Error in cbind(a, b) : long vectors not supported yet: bind.c:1311

I believe the patch is fairly simple:
In cbind() in src/main/bind.c, the int i,j,k,idx should be declared as R_xlen_t instead of int.  The macro calls LENGTH(u) should be replaced with XLENGTH(u).
Comment 1 Simen Gaure 2015-02-10 14:15:28 UTC
By the way, the loops doing the actual copying computes i % k for each element. Integer remainder is a very costly cpu operation, rewriting the loops to avoid this would most probably result in cbind being much faster.
Comment 2 Brian Ripley 2015-02-12 16:29:27 UTC
That's not a very accurate description.  cbind (and rbind) do support long vectors as outputs, and long vectors are not allowed as inputs because of the restriction on dimensions of an array. What they did not support (but could have) was input matrices with 2^31 or more elements but dimensions less than that.  That has been added for R 3.2.0 (and care is needed as some of those variables are dimensions not lengths).