[SciPy-user] matrix multipy ...

Matteo Bertini matteo@naufraghi....
Mon May 19 13:11:21 CDT 2008


Perhaps it's simple, but...

Suppose I have 2 "vectors" (1xN matrix really)

n [27]: a = mat("1,2,3,4,5")
In [29]: b = mat("1,2,3")

If I whant the product, no problem.

But suppose I have a list of vectors (a proper matrix)

In [37]: aa = mat("1,2,3,4,5;6,7,8,9,0")
In [38]: bb = mat("1,2,3;4,5,6")

Can I avoid a loop and have the resulting "cube"?

In [40]: aa[0].T*bb[0]
Out[40]:
matrix([[ 1,  2,  3],
        [ 2,  4,  6],
        [ 3,  6,  9],
        [ 4,  8, 12],
        [ 5, 10, 15]])

I admit, I can't really understand array slicing power/limits!

Thank you,
Matteo Bertini



More information about the SciPy-user mailing list