| LongVectors | R Documentation |
Vectors of2^31 or more elements were added inR 3.0.0.
Prior toR 3.0.0, all vectors inR were restricted to at most2^31 - 1 elements and could be indexed by integervectors.
Currently all atomic (raw, logical, integer, numeric, complex,character) vectors, lists and expressions can be muchlonger on 64-bit platforms: such vectors are referred to as‘long vectors’ and have a slightly different internalstructure. In theory they can contain up to2^52 elements, butaddress space limits of current CPUs and OSes will be much smaller.Such objects will have a length that is expressed as a double,and can be indexed by double vectors.
Arrays (including matrices) can be based on long vectors provided eachof their dimensions is at most2^31 - 1: thus thereare no 1-dimensional long arrays.
R code typically only needs minor changes to work with long vectors,maybe only checking thatas.integer is not used unnecessarilyfor e.g. lengths. However, compiled code typically needs quiteextensive changes. Note that the.C and.Fortran interfaces do not accept long vectors, so.Call (or similar) has to be used.
Because of the storage requirements (a minimum of 64 bytes percharacter string), character vectors are only going to be usable ifthey have a small number of distinct elements, and even then factorswill be more efficient (4 bytes per element rather than 8). So it isexpected that most of the usage of long vectors will be integervectors (including factors) and numeric vectors.
It is now possible to usem x n matrices with morethan 2 billion elements. Whether matrix algebra (including%*%,crossprod,svd,qr,solve andeigen) willactually work is somewhat implementation dependent, including theFortran compiler used and if an external BLAS or LAPACK is used.
An efficient parallel BLAS implementation will often be important toobtain usable performance. For example on one particular platformchol on a 47,000 square matrix took about 5 hours with theinternal BLAS, 21 minutes using an optimized BLAS on one core, and 2minutes using an optimized BLAS on 16 cores.
Add the following code to your website.
For more information on customizing the embed code, readEmbedding Snippets.
