[SciPy-dev] Re: [SciPy-user] Vector mean calculation?
oliphant at ee.byu.edu
Fri Apr 22 06:03:06 CDT 2005
Lance Boyle wrote:
> On Apr 21, 2005, at 5:41 PM, Fernando.Perez at colorado.edu wrote:
>> Quoting Thomas Davidoff <davidoff at haas.berkeley.edu>:
>>> I have a vector with min equal to 412. Why am I getting a negative
>> Without more details, it's quite difficult to be sure. Most likely,
>> it's very long and of integer type (ints are 32 bit objects, so you are
>> effectively doing mod 2^31 arithmetic with negative wraparound).
> Why does Python allow modular arithmetic when the user doesn't request
> modular arithmetic?
To get speed, scipy must assume that if you are using an integer array
then you actually are requesting modular arithmetic (to the size of the
integers in question). The other option would be to silently and
automatically upcast when you get too large.
I don't think that is the right way to go. It would be a good idea,
however, to allow the user to specify a larger type within which to
accomplish a reduction. Look for this in scipy.base (the new Numeric).
I'm thinking of something like
add.reduce(a, Int32) or add.reduce(a, Float64)
which gives a return type for the array.
More information about the Scipy-dev