Re: [R] columnwise multiplication?

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Sat 24 Jun 2006 - 02:04:32 EST

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]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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,                  ripley@stats.ox.ac.uk
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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Jun 24 02:07:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 24 Jun 2006 - 04:12:03 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.