[Numpy-discussion] dot product
Nils Wagner
nwagner at iam.uni-stuttgart.de
Tue Mar 10 05:37:49 EDT 2009
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
More information about the NumPy-Discussion
mailing list