Julien Hillairet wrote: > Hello, > > > 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 [50]: a0 = numpy.array([1,2,3]) > In [51]: numpy.dot(a0,a0) > Out[51]: 14 > > What I don't understand, is why the dot product of a (3,N) vector gives > an error : > > In [52]: a1 = numpy.array([[1,2,3],[1,2,3],[1,2,3],[1,2,3]]) > In [54]: 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]).
When given two 2-D arrays, dot() essentially does matrix multiplication. The last dimension of the first argument is matched with the next-to-last dimension of the second argument. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion