[Numpy-discussion] A basic question on the dot function
Tue Oct 16 13:14:35 CDT 2007
First of all, I'm sorry if this question had already been asked. I've
searched on the gmane archive and elsewhere on internet, but I didn't found
the answer to my question.
As expected, the dot product of 2 'classical' vectors works fine :
In : a0 = numpy.array([1,2,3])
In : numpy.dot(a0,a0)
What I don't understand, is why the dot product of a (3,N) vector gives an
In : a1 = numpy.array([[1,2,3],[1,2,3],[1,2,3],[1,2,3]])
In : numpy.dot(a1,a1)
<type 'exceptions.ValueError'> Traceback (most recent call last)
<type 'exceptions.ValueError'>: objects are not aligned
instead of what I've expected ; an array([14 14 14 14]).
Of course, I've found an alternative in doing :
In : numpy.sum(a1*a1,axis=1)
Out: array([14, 14, 14, 14])
But I like to understand my mistakes or misunderstands :) So, could someone
explained me what I've missed ? Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion