## Re: [Numpy-discussion] Matrix products

 Re: [Numpy-discussion] Matrix products From: Curzio Basso - 2005-01-25 13:48:59 ```konrad.hinsen@... wrote: > How about > > A[:, :, NewAxis]*A[:, NewAxis, :] > > That works for your example at least. I am not quite sure why you use > matrixmultiply in your definition as there doesn't seem to be any > summation. You're right, it was my mistake to use matrixmultiply. Thanks a lot. ```

 [Numpy-discussion] Matrix products From: Curzio Basso - 2005-01-25 13:11:16 ```Hi all, assume that I have a matrix A with shape = (m,n), what I would like to compute is a matrix B with shape = (m, n, n) such as B[i] = NA.matrixmultiply(A[i, :, NA.NewAxis], A[i, NA.NewAxis]) e.g. if A is array([[0, 1], [2, 3]]) then B would be array([[[0, 0], [0, 1]], [[4, 6], [6, 9]]]) Does anyone know how to do this without using loops? thanks ```
 Re: [Numpy-discussion] Matrix products From: - 2005-01-25 13:32:36 ```On Jan 25, 2005, at 14:10, Curzio Basso wrote: > assume that I have a matrix A with shape =3D (m,n), what I would like = to=20 > compute is a matrix B with shape =3D (m, n, n) such as > B[i] =3D NA.matrixmultiply(A[i, :, NA.NewAxis], A[i, NA.NewAxis]) ... > Does anyone know how to do this without using loops? How about A[:, :, NewAxis]*A[:, NewAxis, :] That works for your example at least. I am not quite sure why you use=20 matrixmultiply in your definition as there doesn't seem to be any=20 summation. Konrad. -- --------------------------------------------------------------------- Konrad Hinsen Laboratoire L=E9on Brillouin, CEA Saclay, 91191 Gif-sur-Yvette Cedex, France Tel.: +33-1 69 08 79 25 Fax: +33-1 69 08 82 61 E-Mail: hinsen@... --------------------------------------------------------------------- ```
 Re: [Numpy-discussion] Matrix products From: Curzio Basso - 2005-01-25 13:48:59 ```konrad.hinsen@... wrote: > How about > > A[:, :, NewAxis]*A[:, NewAxis, :] > > That works for your example at least. I am not quite sure why you use > matrixmultiply in your definition as there doesn't seem to be any > summation. You're right, it was my mistake to use matrixmultiply. Thanks a lot. ```