[Numpy-discussion] dot product

Nadav Horesh nadavh at visionsense.com
Tue Mar 10 06:15:38 EDT 2009


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

  Nadav

-----הודעה מקורית-----
מאת: numpy-discussion-bounces at scipy.org בשם Nils Wagner
נשלח: ג 10-מרץ-09 11:37
אל: numpy-discussion at 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 at scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

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


More information about the NumPy-Discussion mailing list