[SciPy-user] Fastest dtype for matrix multiplication
Sat Oct 20 23:47:31 CDT 2007
Tom Johnson wrote:
> 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.
When you are using dot (and I guess most of the matrix multiplication
routines), internally, the function can only work on float. BLAS, for
example, only deal with float. For some routines such as multiplication,
it makes sense to use integer, but the implementation would have to be
totally different (for example handling overflow would be quite
different than with float).
So basically, as far as I am aware, all linear algebra only deal with
floating point, and for those, float32 is the fastest, generally. But
then, nonzero is ill defined with floating points (what you want
generally is really near 0), so you will have to take care of that, too.
More information about the SciPy-user