~ubuntu-branches/ubuntu/precise/eglibc/precise

« back to all changes in this revision

Viewing changes to math/s_cacoshl.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-10-04 17:48:26 UTC
  • mfrom: (216.1.23 oneiric)
  • Revision ID: package-import@ubuntu.com-20111004174826-2cyb9ewn3ucymlsx
Tags: 2.13-20ubuntu5
libc6-dev: Don't break the current {gnat,gcj}-4.4-base versons. LP: #853688.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Return arc hyperbole cosine for long double value.
2
 
   Copyright (C) 1997, 1998, 2006, 2011 Free Software Foundation, Inc.
 
2
   Copyright (C) 1997, 1998, 2006 Free Software Foundation, Inc.
3
3
   This file is part of the GNU C Library.
4
4
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5
5
 
20
20
 
21
21
#include <complex.h>
22
22
#include <math.h>
23
 
#include <math_private.h>
24
23
 
25
24
 
26
25
__complex__ long double
65
64
      __real__ res = 0.0;
66
65
      __imag__ res = __copysignl (M_PI_2l, __imag__ x);
67
66
    }
68
 
  /* The factor 16 is just a guess.  */
69
 
  else if (16.0L * fabsl (__imag__ x) < fabsl (__real__ x))
70
 
    /* Kahan's formula which avoid cancellation through subtraction in
71
 
       some cases.  */
72
 
    res = 2.0L * __clogl (__csqrtl ((x + 1.0L) / 2.0L)
73
 
                          + __csqrtl ((x - 1.0L) / 2.0L));
74
67
  else
75
68
    {
76
69
      __complex__ long double y;
80
73
 
81
74
      y = __csqrtl (y);
82
75
 
83
 
      if (signbit (__real__ x))
 
76
      if (__real__ x < 0.0)
84
77
        y = -y;
85
78
 
86
79
      __real__ y += __real__ x;
87
80
      __imag__ y += __imag__ x;
88
81
 
89
82
      res = __clogl (y);
 
83
 
 
84
      /* We have to use the positive branch.  */
 
85
      if (__real__ res < 0.0)
 
86
        res = -res;
90
87
    }
91
88
 
92
89
  return res;