I don't quite understand how einsum handles broadcasting. I get the following error, but I don't understand why:
In [8]: import numpy as np In [9]: A = np.arange(12).reshape((4,3)) In [10]: B = np.arange(6).reshape((3,2)) In [11]: np.einsum('ik,k...->i...', A, B) --------------------------------------------------------------------------- ValueError: operand 0 did not have enough dimensions to match the broadcasting, and couldn't be extended because einstein sum subscripts were specified at both the start and end However, if I use explicit indexing, it works: In [12]: np.einsum('ik,kj->ij', A, B) Out[12]: array([[10, 13], [28, 40], [46, 67], [64, 94]]) It seems that it also works if I add '...' to the first operand: In [12]: np.einsum('ik...,k...->i...', A, B) Out[12]: array([[10, 13], [28, 40], [46, 67], [64, 94]]) However, as far as I understand, the syntax np.einsum('ik,k...->i...', A, B) should work. Have I misunderstood something or is there a bug? Thanks for your help! Jaakko _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion