<div dir="ltr">OK,<div><br></div><div>I tossed together an example implementation:</div><div><br></div><div><a href="https://gist.github.com/PythonCHB/6e9ef7732a9074d9337a">https://gist.github.com/PythonCHB/6e9ef7732a9074d9337a</a><br></div><div><br></div><div>Simple enough, and seems to work fine for complex, too, out of the box (just using plain old abs). I haven't tried it, but it should work for integers (and decimal?), too, though less need for that anyway.</div><div><br></div><div>The Boost docs talk about overflow issues, but I can't trigger them, nor see where there would show up, except for if the two values tested were REALLY far apart, which isn't really the use case we're worried about. But I could very well be missing something, I'm no FP expert.</div><div><br></div><div>It would probably be good if someone that understands these things better than me came up with some near-pathological test cases.</div><div><br></div><div>Nathaniel, thanks for the pointer to the Boost docs -- I like this much more than numpy's weird atol+rtol approach.</div><div><br></div><div>-Chris</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 12, 2015 at 3:34 PM, Chris Barker <span dir="ltr"><<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><span class="">On Mon, Jan 12, 2015 at 2:56 PM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">But should probably use complex abs().</div></blockquote><div><br></div></span><div>maybe, it does add complication  -- I'd need to look more closely at the Boost code. And I'm trying to think if there are any numerical FP issues that would arise from that -- I'm no expert.</div><span class=""><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Adding it to cmath makes sense (if adding it to math happens).</div></blockquote><div><br></div></span><div>sure.</div><div><br></div><div>And I hate to bring this up, but any reason for a cmath.nan and cmath.inf ?</div><span class=""><div><br></div><div><br></div><div>I wrote:</div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">It looks like they start with two, but end up with<br><span style="font-size:13px">"the implementation is using modified version of the equations (1) and (2) where all underflow, overflow conditions could be guarded safely"</span></blockquote></div><div><span style="font-size:13px"><br></span></div></span><div>oops, they do indeed keep both versions, a "weak" and "strong" one.</div><div><br></div><div>essentially, "is the error small enough relative to both input values, or only one of them. Fairly subtle difference, but I like the "strong" definition, as it gives the same result regardless of input order. though it does guarantee a bit of maybe unnecessary computation.</div><div><br></div><div>I'm going to play with code a bit now.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Chris</div><div><br></div><div> </div></font></span></div><span class="">-- <br><div><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            <a href="tel:%28206%29%20526-6959" value="+12065266959" target="_blank">(206) 526-6959</a>   voice<br>7600 Sand Point Way NE   <a href="tel:%28206%29%20526-6329" value="+12065266329" target="_blank">(206) 526-6329</a>   fax<br>Seattle, WA  98115       <a href="tel:%28206%29%20526-6317" value="+12065266317" target="_blank">(206) 526-6317</a>   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div>