Matrix mulitplication
On 16-Feb-04 Ted Harding wrote:
On 16-Feb-04 Grace Conlon wrote:
ABCD are four matrix. A * Inverse((Transpose(A)*Tranpose(B)*B*A+C)) * Transpose(A) * Transpose(B) * D how to write in R in an efficient way?
The only "efficiency saving" I can see here is to evaluate transposes only once: At <- t(A) Bt <- t(B) A%*%solve(At%*%Bt%*%B%*%A + C)%*%At%*%Bt%*%D
Sorry! Missed a trick here:
At <- t(A)
Bt <- t(B)
E <- B%*%A
Et <- t(E)
A%*%solve(Et%*%E + C)%*%Et%*%D
(saves 2 multiplications at the relatively cheap cost of 1 transpose)
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 16-Feb-04 Time: 23:05:21
------------------------------ XFMail ------------------------------