From simon.urbanek at r-project.org  Sat Feb 12 02:45:06 2011
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Fri, 11 Feb 2011 20:45:06 -0500
Subject: [Rd] R limits documented?
In-Reply-To: <7C9BDD66-4BF5-4A49-A3E1-B96274457DA4@comcast.net>
References: <AANLkTinoie27eMBdq7=QBBcrhBLorhFoiBX6sW+6vBzm@mail.gmail.com>
	<7C9BDD66-4BF5-4A49-A3E1-B96274457DA4@comcast.net>
Message-ID: <433F8810-FE8D-4AD0-A012-45C056A505FA@r-project.org>


On Feb 11, 2011, at 7:55 PM, David Winsemius wrote:

> 
> On Feb 11, 2011, at 7:09 PM, Dominick Samperi wrote:
> 
>> Is there documentation on R limits?
>> That is, max matrix size, etc.?
>> 
>> Diagnostics when limits are exceeded are not always
>> meaningful. For example:
>>> x <- rep(0,50000*50000)
>> Error in rep(0, 50000 * 50000) : invalid 'times' argument
>> In addition: Warning message:
>> In as.vector(data) : NAs introduced by coercion
> 
> > x <- rep(0,40000*50000)
> > gc()
>             used    (Mb) gc trigger    (Mb)   max used    (Mb)
> Ncells    4673306   249.6    6945861   371.0    5315868   283.9
> Vcells 2165579376 16522.1 4374103452 33371.8 4165580443 31780.9
> > object.size(x)
> 16000000040 bytes
> 
> So that is about 2/3 of my installed memory. This seems to be a limitation due to the maximum positive integer being ~ 2*10^9
> > 2*10^9 < 50000*50000
> [1] TRUE
> > 2*10^9 < 40000*50000
> [1] FALSE
> 

The actual limit is for obvious reasons 2^31-1

> as.integer(2^31-1)
[1] 2147483647
> as.integer(2^31)
[1] NA
Warning message:
NAs introduced by coercion 

(ok, for those that this is not obvious: the integer type ("int" in C) is 32-bit wide and it is a signed type so the range is -2^31-1 .. 2^31-1 -- the minus one on each side is the representation of NA and 0 respectively).

Cheers,
Simon


>> 
>> Here's another example:
>>> library(orthopolynom)
>>> hermite <- hermite.h.polynomials(1001)
>>> hermite[[1001]] # should display 1000-th degree polynomial
>> Error in if (signs[1] == "- ") "-" else "" :
>> missing value where TRUE/FALSE needed
> 
> Sounds as though the maximum length of an element of type character has been exceeded.
>> 
>> Thanks,
>> Dominick
>> 
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> David Winsemius, MD
> West Hartford, CT
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 



[Rd] R limits documented?
Simon Urbanek