From b1b0ea8030cad32d6fce2e6e6b5068e54bd6b7a7 Mon Sep 17 00:00:00 2001 From: hpaulj Date: Tue, 7 Jan 2014 11:39:49 -0800 Subject: ENH: Remove unnecessary broadcasting notation restrictions in einsum. In a case where 'ik,kj->ij' works, einsum would raise an error for 'ik,k...->i...' because the 'ik' did not have ellipsis In einsum.c.src prepare_op_axes() pass all 'broadcast' cases through the 'RIGHT' case (interation from the end). Since the BROADCAST variable is not longer needed, all instances of it have been removed from einsum.c.src test_einsum.py - adds a test_einsum_broadcast case. --- numpy/add_newdocs.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 62ca6dca3..62e8898c9 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -2078,6 +2078,8 @@ add_newdoc('numpy.core', 'einsum', array([ 30, 80, 130, 180, 230]) >>> np.dot(a, b) array([ 30, 80, 130, 180, 230]) + >>> np.einsum('...j,j', a, b) + array([ 30, 80, 130, 180, 230]) >>> np.einsum('ji', c) array([[0, 3], @@ -2147,6 +2149,18 @@ add_newdoc('numpy.core', 'einsum', [ 4796., 5162.], [ 4928., 5306.]]) + >>> a = np.arange(6).reshape((3,2)) + >>> b = np.arange(12).reshape((4,3)) + >>> np.einsum('ki,jk->ij', a, b) + array([[10, 28, 46, 64], + [13, 40, 67, 94]]) + >>> np.einsum('ki,...k->i...', a, b) + array([[10, 28, 46, 64], + [13, 40, 67, 94]]) + >>> np.einsum('k...,jk', a, b) + array([[10, 28, 46, 64], + [13, 40, 67, 94]]) + """) add_newdoc('numpy.core', 'alterdot', -- cgit v1.2.1