From 4f83a34fe0961bf00e27313949676c4101c44b73 Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Fri, 13 Oct 2006 18:18:18 +0000 Subject: Fix-up tensor solve and tensor inv and rename to match tensordot. --- numpy/core/numeric.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'numpy/core/numeric.py') diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index ee17e1886..541a54739 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -252,7 +252,7 @@ except ImportError: pass -def tensordot(a, b, axes=[-1,0]): +def tensordot(a, b, axes=2): """tensordot returns the product for any (ndim >= 1) arrays. r_{xxx, yyy} = \sum_k a_{xxx,k} b_{k,yyy} where @@ -265,9 +265,18 @@ def tensordot(a, b, axes=[-1,0]): When there is more than one axis to sum over, the corresponding arguments to axes should be sequences of the same length with the first axis to sum over given first in both sequences, the second axis second, - and so forth. + and so forth. + + If the axes argument is an integer, N, then the last N dimensions of a + and first N dimensions of b are summed over. """ - axes_a, axes_b = axes + try: + iter(axes) + except: + axes_a = range(-axes,0) + axes_b = range(0,axes) + else: + axes_a, axes_b = axes try: na = len(axes_a) axes_a = list(axes_a) -- cgit v1.2.1