Re: [R] vectorization of groups of dot products

From: Berton Gunter <gunter.berton_at_gene.com>
Date: Sat 07 Jan 2006 - 09:11:58 EST


colSums(X^2) -- or am I missing something?

"The business of the statistician is to catalyze the scientific learning process." - George E. P. Box    

> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Rossi, Peter E.
> Sent: Friday, January 06, 2006 1:56 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] vectorization of groups of dot products
>
>
> I have a set of n vectors, x_1, ..., x_n, of the same length.
> I would like to form the vector of dot products -- x_1'x_1,
> ..., x_n'x_n
>
> the fastest way I can think to do this is to put the vectors into a
> matrix
> and do
>
> diag(crossprod(X))
>
> however, this seems to be very wasteful since this computes n(n+1)/2-n
> unnecessary
> dot products.
>
> Is there a better way using existing functions in R?
>
> thanks!
>
> peter
>
>
> ................................
> Peter E. Rossi
> Joseph T. and Bernice S. Lewis Professor of Marketing and Statistics
> Editor, Quantitative Marketing and Economics
> Rm 353, Graduate School of Business, U of Chicago
> 5807 S. Woodlawn Ave, Chicago IL 60637, USA
> Tel: (773) 702-7513 | Fax: (773) 834-2081
>
> ______________________________________________
> 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
>



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 Jan 07 09:18:22 2006

This archive was generated by hypermail 2.1.8 : Sat 07 Jan 2006 - 14:08:34 EST