[Numpy-discussion] Default type for functions that accumulate integers

Charles R Harris charlesr.harris at gmail.com
Mon Jan 2 21:27:09 EST 2017


Hi All,

Currently functions like trace use the C long type as the default
accumulator for integer types of lesser precision:

dtype : dtype, optional
>     Determines the data-type of the returned array and of the accumulator
>     where the elements are summed. If dtype has the value None and `a` is
>     of integer type of precision less than the default integer
>     precision, then the default integer precision is used. Otherwise,
>     the precision is the same as that of `a`.
>

The problem with this is that the precision of long varies with the
platform so that the result varies,  see gh-8433
<https://github.com/numpy/numpy/issues/8433> for a complaint about this.
There are two possible alternatives that seem reasonable to me:


   1. Use 32 bit accumulators on 32 bit platforms and 64 bit accumulators
   on 64 bit platforms.
   2. Always use 64 bit accumulators.

Thoughts?

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20170102/ab726f55/attachment.html>


More information about the NumPy-Discussion mailing list