casinhq.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Return arc hyperbolic sine for a complex float type.
  2. Copyright (C) 1997-2018 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include "quadmath-imp.h"
  17. __complex128
  18. casinhq (__complex128 x)
  19. {
  20. __complex128 res;
  21. int rcls = fpclassifyq (__real__ x);
  22. int icls = fpclassifyq (__imag__ x);
  23. if (rcls <= QUADFP_INFINITE || icls <= QUADFP_INFINITE)
  24. {
  25. if (icls == QUADFP_INFINITE)
  26. {
  27. __real__ res = copysignq (HUGE_VALQ, __real__ x);
  28. if (rcls == QUADFP_NAN)
  29. __imag__ res = nanq ("");
  30. else
  31. __imag__ res = copysignq ((rcls >= QUADFP_ZERO
  32. ? M_PI_2q : M_PI_4q),
  33. __imag__ x);
  34. }
  35. else if (rcls <= QUADFP_INFINITE)
  36. {
  37. __real__ res = __real__ x;
  38. if ((rcls == QUADFP_INFINITE && icls >= QUADFP_ZERO)
  39. || (rcls == QUADFP_NAN && icls == QUADFP_ZERO))
  40. __imag__ res = copysignq (0, __imag__ x);
  41. else
  42. __imag__ res = nanq ("");
  43. }
  44. else
  45. {
  46. __real__ res = nanq ("");
  47. __imag__ res = nanq ("");
  48. }
  49. }
  50. else if (rcls == QUADFP_ZERO && icls == QUADFP_ZERO)
  51. {
  52. res = x;
  53. }
  54. else
  55. {
  56. res = __quadmath_kernel_casinhq (x, 0);
  57. }
  58. return res;
  59. }