[SciPy-user] Fastest dtype for matrix multiplication
Tom Johnson
tjhnson@gmail....
Sat Oct 20 23:49:29 CDT 2007
Hi,
I am interested in doing matrix multiplication, but all I really care
about is if the elements are nonzero or not (after all the
multiplication is done).
Which dtype should I use to accomplish this in the fastest manner?
I did some quick tests...and it seemed like dtype=bool was quite slow
(contrary to my expectations). Could someone explain this and
recommend the best dtype? So far, it seems like float64 is the best.
These are 36x36 matrices:
In [100]: T0.dtype
Out[100]: dtype('float64')
In [101]: timeit dot(T0,T1)
10000 loops, best of 3: 87.4 µs per loop
In [102]: T0b.dtype
Out[102]: dtype('bool')
In [103]: timeit dot(T0b,T1b)
1000 loops, best of 3: 175 µs per loop
In [104]: T0i.dtype
Out[104]: dtype('int32')
In [105]: timeit dot(T0i,T1i)
10000 loops, best of 3: 189 µs per loop
More information about the SciPy-user
mailing list