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

  Nadav

-----הודעה מקורית-----
מאת: numpy-discussion-boun...@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

<<winmail.dat>>

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

Reply via email to