Simon Burton wrote: >>>> numpy.dot.__doc__ >>>> > matrixproduct(a,b) > Returns the dot product of a and b for arrays of floating point types. > Like the generic numpy equivalent the product sum is over > the last dimension of a and the second-to-last dimension of b. > NB: The first argument is not conjugated. > > Does numpy support summing over arbitrary dimensions, > as in tensor calculus ? > > I could cook up something that uses transpose and dot, but it's > reasonably tricky i think :) >
I've just added tensordot to NumPy (adapted and enhanced from numarray). It allows you to sum over an arbitrary number of axes. It uses a 2-d dot-product internally as that is optimized if you have a fast blas installed. Example: If a.shape is (3,4,5) and b.shape is (4,3,2) Then tensordot(a, b, axes=([1,0],[0,1])) returns a (5,2) array which is equivalent to the code: c = zeros((5,2)) for i in range(5): for j in range(2): for k in range(3): for l in range(4): c[i,j] += a[k,l,i]*b[l,k,j] -Travis ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion