On Fri, Jul 27, 2012 at 5:15 AM, Charles R Harris
<charlesr.har...@gmail.com> wrote:
> I would support accumulating in 64 bits but, IIRC, the function will need to
> be rewritten so that it works by adding 32 bit floats to the accumulator to
> save space. There are also more stable methods that could also be
> investigated. There is a nice little project there for someone to cut their
> teeth on.

So the obvious solution here would be to make the ufunc reduce loop
smart enough that
  x = np.zeros(2 ** 30, dtype=float32)
  np.sum(x, dtype=float64)
does not upcast 'x' to float64's as a whole. This shouldn't be too
terrible to implement -- iterate over the float32 array, and only
upcast each inner-loop "buffer" as you go, instead of upcasting the
whole thing.

In fact, nditer might do this already?

Then using a wide accumulator by default would just take a few lines
of code in numpy.core._methods._mean to select the proper dtype and
downcast the result.

-n
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to