Complex arg-trig functions

Stephen Montgomery-Smith stephen at missouri.edu
Thu Aug 16 04:12:44 UTC 2012


On 08/15/2012 03:56 PM, Stephen Montgomery-Smith wrote:
> On 08/15/2012 08:35 AM, Bruce Evans wrote:
>> On Tue, 14 Aug 2012, Stephen Montgomery-Smith wrote:

>> I added this to the NaN mixing in catan[h]*(),
>> and now all my tests pass:
>>
>> % diff -c2 catrig.c~ catrig.c
>> % *** catrig.c~    Sun Aug 12 17:29:18 2012
>> % --- catrig.c    Wed Aug 15 11:57:02 2012
>> % ***************
>> % *** 605,609 ****
>> %        */
>> %       if (ISNAN(x) || ISNAN(y))
>> % !         return (cpack(x+y, x+y));
>> % %       /* (x,inf) and (inf,y) and (inf,inf) -> (0,PI/2) */
>> % --- 609,613 ----
>> %        */
>> %       if (ISNAN(x) || ISNAN(y))
>> % !         return (cpack((x+0.0L)+(y+0), (x+0.0L)+(y+0)));
>> % %       /* (x,inf) and (inf,y) and (inf,inf) -> (0,PI/2) */
>>
>> Use this expression in all precisions.
>
>
> Would this work?
>
>         if (ISNAN(x) || ISNAN(y))
>                  return (cpack((x+x)+(y+y), (x+x)+(y+y)));
>

I know Bruce is gone for a couple of weeks, but can someone else answer 
these questions?  I decided to start reading a bit about nans: 
http://en.wikipedia.org/wiki/NaN

I don't understand why my original code:

if (ISNAN(x) || ISNAN(y)) return (cpack(x+y, x+y));

doesn't return quiet nans, and generally do everything else it should do 
(like raise invalid if one or both are signaling nans).

This is what I read on the web page: "Signaling NaNs, or sNaNs, are 
special forms of a NaN that when consumed by most operations should 
raise an invalid exception and then, if appropriate, be "quieted" into a 
qNaN that may then propagate."

This is Bruce's code:

return (cpack((x+0.0L)+(y+0), (x+0.0L)+(y+0)))

and he says he does this for all precisions.  Why does he add 0.0L to x, 
but only add 0 to y?




More information about the freebsd-numerics mailing list