Why is a.T*b slower than M.dot(a.T, b)? Does it take longer to parse

or something?

>> a = M.randn(500,1)

>> b = M.randn(500,1)

>> timeit a.T*b

100000 loops, best of 3: 11 µs per loop

>> timeit M.dot(a.T, b)

100000 loops, best of 3: 6.72 µs per loop

>> a = M.randn(5,1)

>> b = M.randn(5,1)

>> timeit a.T*b

100000 loops, best of 3: 10.1 µs per loop

>> timeit M.dot(a.T, b)

100000 loops, best of 3: 6.16 µs per loop

I use matrices, but for inner loops I'll convert to arrays:

>> a = a.A

>> b = b.A

>> dot = M.dot

>> timeit dot(a.T, b)

1000000 loops, best of 3: 1.82 µs per loop

>> a = a.T

>> timeit dot(a, b)

1000000 loops, best of 3: 1.44 µs per loop

_______________________________________________

Numpy-discussion mailing list

[hidden email]
http://projects.scipy.org/mailman/listinfo/numpy-discussion