[Numpy-discussion] Matrix products

Curzio Basso curzio.basso at unibas.ch
Tue Jan 25 05:12:03 CST 2005

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?


More information about the Numpy-discussion mailing list