From: Nadav H. <na...@vi...> - 2004-03-22 13:14:20
|
The function did not work. Here is the correction: def tensormultiply(array1, array2): """tensormultiply returns the product for any rank >=3D1 arrays, = defined as: r_{xxx, yyy} =3D \sum_k array1_{xxx, k} array2_{k, yyyy} where xxx, yyy denote the rest of the a and b dimensions. """ if array1.shape[-1] !=3D array2.shape[0]: raise ValueError, "Unmatched dimensions" shape =3D array1.shape[:-1] + array2.shape[1:] return _gen.reshape(dot(_gen.reshape(array1, (-1, = array1.shape[-1])), _gen.reshape(array2, (array2.shape[0], -1))), = shape) Nadav |