On Fri, 23 Jun 2006, Mu Tian wrote: > Hi all, > > I'd like to do a multiplication between 2 matrices buy only want resulsts of > cloumn 1 * column 1, column 2 * column 2 and so on. > > Now I do > > C <- diag(t(A) %*% B) > > Is there a bulit in way to do this?
If * here means vector inner product, colSums(A*B) which is a lot more efficient. > > Thank you. > > [[alternative HTML version deleted]] > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
