# [Numpy-discussion] dot product

Tue Mar 10 05:15:38 CDT 2009

dot(X.transpose(), Y)**2 / ( (X*X).sum(0)[:,None] * (Y*Y).sum(0) )

-----הודעה מקורית-----
מאת: numpy-discussion-bounces@scipy.org בשם Nils Wagner
נשלח: ג 10-מרץ-09 11:37
אל: numpy-discussion@scipy.org
נושא: [Numpy-discussion] dot product

Hi all,

The dot product can be defined for two vectors x and y by
x·y=|x||y| \cos(\theta),

where theta is the angle between the vectors and |x| is
the norm.

Now assume that we have arrays(matrices)

X = [x_1, ..., x_m]

Y = [y_1, ..., y_s]

m <> s

Is there a built-in function to compute the following
matrix

for i in arange(0,m):
for j in arange(0,s):
MAC[i,j] =
dot(X[:,i],Y[:,j])**2/(dot(X[:,i],X[:,i])*dot(Y[:,j],Y[:,j]))

Each element of the matrix represents the corresponding
angle squared.

Nils

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 3075 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090310/712378ba/attachment.bin