From: Tim H. <tim...@ie...> - 2006-10-15 00:26:55
|
Charles R Harris wrote: > > > On 10/14/06, *A. M. Archibald* <per...@gm... > <mailto:per...@gm...>> wrote: [SNIP] > > > Hmmm, I wonder if we have a dictionary of precisions indexed by dtype > somewhere? Here's some code I stole from somewhere for computing EPS. It would easy enough to generate the dictionary you are looking for at startup using this. I can't recall the pedigree of this code though, so caveat emptor: def bits_of_precision(dtype): one = np.array([1], dtype) i = 0 while not np.alltrue(one + (one / 2.**i) == one): i += 1 return i - 1 EPSS = 1.0 / 2**bits_of_precision(float) * 10 # XXX safety factor It's sorta old and translated from numpy too, so it could probably be rewritten in better style. -tim > [SNIP] |