[R] multiplication question
Moshe Olshansky
m_olshansky at yahoo.com
Tue Jul 8 00:54:12 CEST 2008
The answer to your first question is
sum(x)8sum(y) - sum(x*y)
and for the second one
x %*% R %*% y - sum(x*y*diag(R))
--- On Thu, 3/7/08, Murali Menon <feanor0 at hotmail.com> wrote:
> From: Murali Menon <feanor0 at hotmail.com>
> Subject: [R] multiplication question
> To: r-help at stat.math.ethz.ch
> Received: Thursday, 3 July, 2008, 2:30 AM
> folks,
>
> is there a clever way to compute the sum of the product of
> two vectors such that the common indices are not multiplied
> together?
>
> i.e. if i have vectors X, Y, how can i compute
>
> Sum (X[i] * Y[j])
> i != j
>
> where i != j
>
> also, what if i wanted
>
> Sum (X[i] * Y[j] * R[i, j])
> i != j
>
> where R is a matrix?
>
> thanks,
>
> murali
>
>
> _________________________________________________________________
> Enter the Zune-A-Day Giveaway for your chance to win —
> day after day after day
>
> M_Mobile_Zune_V1
> [[alternative HTML version
> deleted]]______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
More information about the R-help
mailing list