[R] columnwise multiplication?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Jun 23 18:04:32 CEST 2006
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 at 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 at 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
More information about the R-help
mailing list