LCOV - code coverage report
Current view: top level - src - s_atanl.c (source / functions) Coverage Total Hit
Test: app.info Lines: 0.0 % 30 0
Test Date: 2024-01-11 15:52:50 Functions: 0.0 % 1 0
Branches: 0.0 % 24 0

             Branch data     Line data    Source code
       1                 :             : /* @(#)s_atan.c 5.1 93/09/24 */
       2                 :             : /* FreeBSD: head/lib/msun/src/s_atan.c 176451 2008-02-22 02:30:36Z das */
       3                 :             : /*
       4                 :             :  * ====================================================
       5                 :             :  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
       6                 :             :  *
       7                 :             :  * Developed at SunPro, a Sun Microsystems, Inc. business.
       8                 :             :  * Permission to use, copy, modify, and distribute this
       9                 :             :  * software is freely granted, provided that this notice
      10                 :             :  * is preserved.
      11                 :             :  * ====================================================
      12                 :             :  */
      13                 :             : 
      14                 :             : #include "cdefs-compat.h"
      15                 :             : //__FBSDID("$FreeBSD: src/lib/msun/src/s_atanl.c,v 1.1 2008/07/31 22:41:26 das Exp $");
      16                 :             : 
      17                 :             : /*
      18                 :             :  * See comments in s_atan.c.
      19                 :             :  * Converted to long double by David Schultz <das@FreeBSD.ORG>.
      20                 :             :  */
      21                 :             : 
      22                 :             : #include <float.h>
      23                 :             : #include <openlibm_math.h>
      24                 :             : 
      25                 :             : #include "invtrig.h"
      26                 :             : #include "math_private.h"
      27                 :             : 
      28                 :             : static const long double
      29                 :             : one   = 1.0,
      30                 :             : huge   = 1.0e300;
      31                 :             : 
      32                 :             : OLM_DLLEXPORT long double
      33                 :           0 : atanl(long double x)
      34                 :             : {
      35                 :             :         union IEEEl2bits u;
      36                 :             :         long double w,s1,s2,z;
      37                 :             :         int id;
      38                 :             :         int16_t expsign, expt;
      39                 :             :         int32_t expman;
      40                 :             : 
      41                 :           0 :         u.e = x;
      42                 :           0 :         expsign = u.xbits.expsign;
      43                 :           0 :         expt = expsign & 0x7fff;
      44         [ #  # ]:           0 :         if(expt >= ATAN_CONST) {     /* if |x| is large, atan(x)~=pi/2 */
      45         [ #  # ]:           0 :             if(expt == BIAS + LDBL_MAX_EXP &&
      46         [ #  # ]:           0 :                ((u.bits.manh&~LDBL_NBIT)|u.bits.manl)!=0)
      47                 :           0 :                 return x+x;             /* NaN */
      48         [ #  # ]:           0 :             if(expsign>0) return  atanhi[3]+atanlo[3];
      49                 :           0 :             else     return -atanhi[3]-atanlo[3];
      50                 :             :         }
      51                 :             :         /* Extract the exponent and the first few bits of the mantissa. */
      52                 :             :         /* XXX There should be a more convenient way to do this. */
      53                 :           0 :         expman = (expt << 8) | ((u.bits.manh >> (MANH_SIZE - 9)) & 0xff);
      54         [ #  # ]:           0 :         if (expman < ((BIAS - 2) << 8) + 0xc0) {       /* |x| < 0.4375 */
      55         [ #  # ]:           0 :             if (expt < ATAN_LINEAR) {        /* if |x| is small, atanl(x)~=x */
      56         [ #  # ]:           0 :                 if(huge+x>one) return x;     /* raise inexact */
      57                 :             :             }
      58                 :           0 :             id = -1;
      59                 :             :         } else {
      60                 :           0 :         x = fabsl(x);
      61         [ #  # ]:           0 :         if (expman < (BIAS << 8) + 0x30) {             /* |x| < 1.1875 */
      62         [ #  # ]:           0 :             if (expman < ((BIAS - 1) << 8) + 0x60) {   /* 7/16 <=|x|<11/16 */
      63                 :           0 :                 id = 0; x = (2.0*x-one)/(2.0+x);
      64                 :             :             } else {                    /* 11/16<=|x|< 19/16 */
      65                 :           0 :                 id = 1; x  = (x-one)/(x+one);
      66                 :             :             }
      67                 :             :         } else {
      68         [ #  # ]:           0 :             if (expman < ((BIAS + 1) << 8) + 0x38) {   /* |x| < 2.4375 */
      69                 :           0 :                 id = 2; x  = (x-1.5)/(one+1.5*x);
      70                 :             :             } else {                    /* 2.4375 <= |x| < 2^ATAN_CONST */
      71                 :           0 :                 id = 3; x  = -1.0/x;
      72                 :             :             }
      73                 :             :         }}
      74                 :             :     /* end of argument reduction */
      75                 :           0 :         z = x*x;
      76                 :           0 :         w = z*z;
      77                 :             :     /* break sum aT[i]z**(i+1) into odd and even poly */
      78                 :           0 :         s1 = z*T_even(w);
      79                 :           0 :         s2 = w*T_odd(w);
      80         [ #  # ]:           0 :         if (id<0) return x - x*(s1+s2);
      81                 :             :         else {
      82                 :           0 :             z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
      83         [ #  # ]:           0 :             return (expsign<0)? -z:z;
      84                 :             :         }
      85                 :             : }
        

Generated by: LCOV version 2.0-115.g950771e