Message-ID: <3AB630BF-6287-4E31-BBF3-544B970DEDFA@soc.soton.ac.uk>
Date: 2005-10-05T10:19:43Z
From: robin hankin
Subject: eliminate t() and %*% using crossprod() and solve(A,b)
Hi
I have a square matrix Ainv of size N-by-N where N ~ 1000
I have a rectangular matrix H of size N by n where n ~ 4.
I have a vector d of length N.
I need X = solve(t(H) %*% Ainv %*% H) %*% t(H) %*% Ainv %*% d
and
H %*% X.
It is possible to rewrite X in the recommended crossprod way:
X <- solve(quad.form(Ainv, H), crossprod(crossprod(Ainv, H), d))
where quad.form() is a little function that evaluates a quadratic form:
quad.form <- function (M, x){
jj <- crossprod(M, x)
return(drop(crossprod(jj, jj)))
}
QUESTION:
how to calculate
H %*% X
in the recommended crossprod way? (I don't want to take a transpose
because t() is expensive, and I know that %*% is slow).
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
tel 023-8059-7743