[R] inverse matrix

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Fri Oct 28 12:59:01 CEST 2005



Sam R. Smith wrote:
> if solve(a,b) means to calculate an inverse matrix of
> a with b, and i wonder why solve(a)%%b will get
> different result?
> 

It does? Or perhaps your "%%" is not just a typo. It should be "%*%".

 > a <- matrix(rnorm(16), 4, 4)
 > b <- matrix(rnorm(4), 4, 1)
 > solve(a, b)
            [,1]
[1,] -0.8005768
[2,]  0.5913755
[3,] -1.8256012
[4,]  0.8973716
 > solve(a) %*% b
            [,1]
[1,] -0.8005768
[2,]  0.5913755
[3,] -1.8256012
[4,]  0.8973716

HTH,

--sundar




More information about the R-help mailing list