John Lawless wrote:
> Travis,
>
>      Thanks!
>
> 1).  I haven't found any documentation on dtype='O'.  (I purchased your
>      trelgol book but it hasn't arrived yet.)  Does 'O' guarantee no
>      wrong answers?
>   
The object data-type uses Python objects instead of low-level C-types 
for the calculations.  So, it gives the same calculations that Python 
would do (but of course it's much slower).
> 2).  My actual code was more complex than the example I posted.  It was
>      giving correct answers until I increased the dataset size.  Then,
>      luckily, the result became obviously wrong.  I can go through a
>      code and try to coerce everything to double but, when debugging a
>      large code, how can one ever be sure that all types are coerced
>      correctly if no errors are generated?
>   
NumPy uses c data-types for calculations.  It is therefore, *much* 
faster, but you have to take precautions about overflowing on integer 
operations.

> 3).  AFAIK, checking for overflows should take no CPU time whatsoever
>      unless an exception is actually generated. 
This is true for floating point operations, but you were doing integer 
multiplication.    There is no support for hardware multiply overflow in 
NumPy (is there even such a thing?). 

Python checks for overflow on integer arithmetic by doing some 
additional calculations.    It would be possible to add slower, integer 
over-flow checking ufuncs to NumPy if this was desired and you could 
replace the standard non-checking functions pretty easily.


-Travis




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to