[Rd] solve() benchmark in R-1.4.1 (PR#1397)

hyu@stats.uwo.ca hyu@stats.uwo.ca
Wed, 20 Mar 2002 04:50:40 +0100 (MET)


Full_Name: Hao Yu
Version: R-1.4.1
OS: Windows and Linux
Submission from: (NULL) (129.100.242.16)


I just report what I find for the solve() function when I was doing benchmark.

A specific function Toeplitz is used as following 
"Toeplitz" <- function(x)
{
        matrix(x[1 + abs(outer(seq(along = x), seq(along = x), FUN = "-"))], 
                byrow = T, ncol = length(x))
}

A. On a dual  PIII 1GHz Xeon Linux Redhat 7.2 (R-1.4.1 is recompiled to create
libR.so. No change to other settings. All libraries come with redhat.)
*****************************************************
> system.time(solve(matrix(rnorm(1000000),nrow=1000)))
[1] 35.04  0.30 35.33  0.00  0.00
> system.time(solve(Toeplitz(.5^seq(0,999))))
[1] 53.28  0.43 53.69  0.00  0.00
*****************************************************
B. On a PIII-M 1.2GHz laptop running Windows Xp Pro (download binary R from
CRAN)
*****************************************************
> system.time(solve(matrix(rnorm(1000000),nrow=1000)))
[1] 28.18  0.05 28.24    NA    NA
> system.time(solve(Toeplitz(.5^seq(0,999))))
[1] 33.80  0.03 34.14    NA    NA
*****************************************************
C. On a PIII 1.125GHz desktop Windows 2k (Download binary R from CRAN)
*****************************************************
> system.time(solve(matrix(rnorm(1000000),nrow=1000)))
[1] 32.31  0.14 36.37    NA    NA
> system.time(solve(Toeplitz(.5^seq(0,999))))
[1] 36.45  0.16 40.84    NA    NA
*****************************************************


Clearly solve() does a random matrix inverse faster than a positive definite and
symmetric matrix (covariance matrix). I do not think the results (inverses) are
wrong. But it is odd regarding the timing for solve(). Using solve.Matrix() from
the package Matrix, I got almost identical timings (it fails to identify
positive definite and symmetric matrices). 

Thanks
Hao Yu


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._