[R] Matrix
Douglas Bates
bates at stat.wisc.edu
Thu Sep 30 15:07:15 CEST 2004
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
More information about the R-help
mailing list