[R] Matrix
Uwe Ligges
ligges at statistik.uni-dortmund.de
Thu Sep 30 15:31:37 CEST 2004
Douglas Bates wrote:
> Uwe Ligges wrote:
>
>> salvati nicola wrote:
>>
>>> I have a matrix 2900X2900 and I have to solve it. But R says that it
>>> can't allocate 67899kb.
>>> How can I do?
>>
>>
>>
>> a) Clean up your workspace before trying to work on the matrix
>> b) Is this an outdated R version on Windows? Then (i) please upgrade
>> and (ii) please read the R for Windows FAQs and ?Memory.
>> c) Buy more memory, if you have less than 512MB. 512 MB suffices for
>> me (in a clean workspace!) in ~5 min. using Rblas.dll linked against
>> ATLAS. You probably want to have ~1GB of memory for serious other
>> calculations with those matrices.
>>
>> Uwe Ligges
>
>
> 5 Min?
>
> On a modest desktop system (Athlon XP 2500+, approx 1.8 GHz) it took
> about 20 seconds for the inversion and about 8 seconds for the LU
> decomposition. This is using the Matrix package.
>
> > mm <- Matrix(rnorm(2900*2900), ncol = 2900)
> > object.size(mm)
> [1] 67280636
> > system.time(rcond(mm))
> [1] 7.73 0.10 7.96 0.00 0.00
> > object.size(mm)
> [1] 134573052
> > system.time(minv <- solve(mm))
> [1] 19.93 0.10 20.04 0.00 0.00
> > rcond(mm)
> [1] 2.466351e-07
>
> The initial call to rcond calculates and stores the LU decomposition.
> That is why the size of the object approximately doubles.
>
> I get similar results without the matrix package except that the
> decomposition must be recomputed for each such operation on the matrix.
>
> > m1 <- matrix(rnorm(2900*2900), ncol = 2900)
> > system.time(minv1 <- solve(m1))
> [1] 30.08 0.86 32.32 0.00 0.00
I'm sorry, I only thought I had used the ATLAS optimized version (but it
was the standard Rblas.dll), it really has
> system.time(minv <- solve(mm))
[1] 31.69 1.82 34.14 NA NA
(R-1.9.1, ATLAS, WinNT4.0, Athlon with real 1.67 GHz)
Uwe
More information about the R-help
mailing list