[R] allocMatrix limits

Vadim Kutsyy vadim at kutsyy.com
Fri Aug 1 16:35:01 CEST 2008


Martin Maechler wrote:
>
>     VK> The problem is in array.c, where allocMatrix check for
>     VK> "if ((double)nrow * (double)ncol > INT_MAX)".  But why
>     VK> itn is used and not long int for indexing? (max int is
>     VK> 2147483647, max long int is 9223372036854775807)
>
> Well, Brian gave you all info:
>   
exactly, and given that most modern system used for computations (i.e. 
64bit system) have long int which is much larger than int, I am 
wondering why long int is not used for indexing (I don't think that 4 
bit vs 8 bit storage is an issue).
> Did you really carefully read  ?Memory-limits  
> ??
>   
Yes, it is specify that 4 bit int is used for indexing in all version of 
R, but why? I think 2147483647 elements for a single vector is OK, but 
not as total number of elements for the matrix.  I am running out of 
indexing at mere 10% memory consumption.
> BTW: The package 'Matrix' has many facilities to work with
> sparse matrices; 
Is is a very good package, but I don't see a relation to a limitation in 
array.c (and I don't have scarce matrices).

Thanks,

Vadim

PS: I have no problem to go and modify C code, but I am just wondering 
what are the reasons for having such limitation.



More information about the R-help mailing list