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

             Branch data     Line data    Source code
       1                 :             : /*-
       2                 :             :  * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl
       3                 :             :  * All rights reserved.
       4                 :             :  *
       5                 :             :  * Redistribution and use in source and binary forms, with or without
       6                 :             :  * modification, are permitted provided that the following conditions
       7                 :             :  * are met:
       8                 :             :  * 1. Redistributions of source code must retain the above copyright
       9                 :             :  *    notice unmodified, this list of conditions, and the following
      10                 :             :  *    disclaimer.
      11                 :             :  * 2. Redistributions in binary form must reproduce the above copyright
      12                 :             :  *    notice, this list of conditions and the following disclaimer in the
      13                 :             :  *    documentation and/or other materials provided with the distribution.
      14                 :             :  *
      15                 :             :  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
      16                 :             :  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
      17                 :             :  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
      18                 :             :  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
      19                 :             :  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
      20                 :             :  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      21                 :             :  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      22                 :             :  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      23                 :             :  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
      24                 :             :  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      25                 :             :  */
      26                 :             : 
      27                 :             : /*
      28                 :             :  * Hyperbolic sine of a complex argument z.  See s_csinh.c for details.
      29                 :             :  */
      30                 :             : 
      31                 :             : #include "cdefs-compat.h"
      32                 :             : //__FBSDID("$FreeBSD: src/lib/msun/src/s_csinhf.c,v 1.2 2011/10/21 06:29:32 das Exp $");
      33                 :             : 
      34                 :             : #include <openlibm_complex.h>
      35                 :             : #include <openlibm_math.h>
      36                 :             : 
      37                 :             : #include "math_private.h"
      38                 :             : 
      39                 :             : static const float huge = 0x1p127;
      40                 :             : 
      41                 :             : OLM_DLLEXPORT float complex
      42                 :           0 : csinhf(float complex z)
      43                 :             : {
      44                 :             :         float x, y, h;
      45                 :             :         int32_t hx, hy, ix, iy;
      46                 :             : 
      47                 :           0 :         x = crealf(z);
      48                 :           0 :         y = cimagf(z);
      49                 :             : 
      50                 :           0 :         GET_FLOAT_WORD(hx, x);
      51                 :           0 :         GET_FLOAT_WORD(hy, y);
      52                 :             : 
      53                 :           0 :         ix = 0x7fffffff & hx;
      54                 :           0 :         iy = 0x7fffffff & hy;
      55                 :             : 
      56   [ #  #  #  # ]:           0 :         if (ix < 0x7f800000 && iy < 0x7f800000) {
      57         [ #  # ]:           0 :                 if (iy == 0)
      58                 :           0 :                         return (CMPLXF(sinhf(x), y));
      59         [ #  # ]:           0 :                 if (ix < 0x41100000) /* small x: normal case */
      60                 :           0 :                         return (CMPLXF(sinhf(x) * cosf(y), coshf(x) * sinf(y)));
      61                 :             : 
      62                 :             :                 /* |x| >= 9, so cosh(x) ~= exp(|x|) */
      63         [ #  # ]:           0 :                 if (ix < 0x42b17218) {
      64                 :             :                         /* x < 88.7: expf(|x|) won't overflow */
      65                 :           0 :                         h = expf(fabsf(x)) * 0.5f;
      66                 :           0 :                         return (CMPLXF(copysignf(h, x) * cosf(y), h * sinf(y)));
      67         [ #  # ]:           0 :                 } else if (ix < 0x4340b1e7) {
      68                 :             :                         /* x < 192.7: scale to avoid overflow */
      69                 :           0 :                         z = __ldexp_cexpf(CMPLXF(fabsf(x), y), -1);
      70                 :           0 :                         return (CMPLXF(crealf(z) * copysignf(1, x), cimagf(z)));
      71                 :             :                 } else {
      72                 :             :                         /* x >= 192.7: the result always overflows */
      73                 :           0 :                         h = huge * x;
      74                 :           0 :                         return (CMPLXF(h * cosf(y), h * h * sinf(y)));
      75                 :             :                 }
      76                 :             :         }
      77                 :             : 
      78   [ #  #  #  # ]:           0 :         if (ix == 0 && iy >= 0x7f800000)
      79                 :           0 :                 return (CMPLXF(copysignf(0, x * (y - y)), y - y));
      80                 :             : 
      81   [ #  #  #  # ]:           0 :         if (iy == 0 && ix >= 0x7f800000) {
      82         [ #  # ]:           0 :                 if ((hx & 0x7fffff) == 0)
      83                 :           0 :                         return (CMPLXF(x, y));
      84                 :           0 :                 return (CMPLXF(x, copysignf(0, y)));
      85                 :             :         }
      86                 :             : 
      87   [ #  #  #  # ]:           0 :         if (ix < 0x7f800000 && iy >= 0x7f800000)
      88                 :           0 :                 return (CMPLXF(y - y, x * (y - y)));
      89                 :             : 
      90   [ #  #  #  # ]:           0 :         if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) {
      91         [ #  # ]:           0 :                 if (iy >= 0x7f800000)
      92                 :           0 :                         return (CMPLXF(x * x, x * (y - y)));
      93                 :           0 :                 return (CMPLXF(x * cosf(y), INFINITY * sinf(y)));
      94                 :             :         }
      95                 :             : 
      96                 :           0 :         return (CMPLXF((x * x) * (y - y), (x + x) * (y - y)));
      97                 :             : }
      98                 :             : 
      99                 :             : OLM_DLLEXPORT float complex
     100                 :           0 : csinf(float complex z)
     101                 :             : {
     102                 :             : 
     103                 :           0 :         z = csinhf(CMPLXF(-cimagf(z), crealf(z)));
     104                 :           0 :         return (CMPLXF(cimagf(z), -crealf(z)));
     105                 :             : }
        

Generated by: LCOV version 2.0-115.g950771e