/[jscoverage]/trunk/js/src/fdlibm/e_acosh.c
ViewVC logotype

Annotation of /trunk/js/src/fdlibm/e_acosh.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations)
Wed Aug 1 13:51:53 2007 UTC (14 years, 11 months ago) by siliconforks
File MIME type: text/plain
File size: 3462 byte(s)
Initial import.

1 siliconforks 2 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2     *
3     * ***** BEGIN LICENSE BLOCK *****
4     * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5     *
6     * The contents of this file are subject to the Mozilla Public License Version
7     * 1.1 (the "License"); you may not use this file except in compliance with
8     * the License. You may obtain a copy of the License at
9     * http://www.mozilla.org/MPL/
10     *
11     * Software distributed under the License is distributed on an "AS IS" basis,
12     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13     * for the specific language governing rights and limitations under the
14     * License.
15     *
16     * The Original Code is Mozilla Communicator client code, released
17     * March 31, 1998.
18     *
19     * The Initial Developer of the Original Code is
20     * Sun Microsystems, Inc.
21     * Portions created by the Initial Developer are Copyright (C) 1998
22     * the Initial Developer. All Rights Reserved.
23     *
24     * Contributor(s):
25     *
26     * Alternatively, the contents of this file may be used under the terms of
27     * either of the GNU General Public License Version 2 or later (the "GPL"),
28     * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29     * in which case the provisions of the GPL or the LGPL are applicable instead
30     * of those above. If you wish to allow use of your version of this file only
31     * under the terms of either the GPL or the LGPL, and not to allow others to
32     * use your version of this file under the terms of the MPL, indicate your
33     * decision by deleting the provisions above and replace them with the notice
34     * and other provisions required by the GPL or the LGPL. If you do not delete
35     * the provisions above, a recipient may use your version of this file under
36     * the terms of any one of the MPL, the GPL or the LGPL.
37     *
38     * ***** END LICENSE BLOCK ***** */
39    
40     /* @(#)e_acosh.c 1.3 95/01/18 */
41     /*
42     * ====================================================
43     * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
44     *
45     * Developed at SunSoft, a Sun Microsystems, Inc. business.
46     * Permission to use, copy, modify, and distribute this
47     * software is freely granted, provided that this notice
48     * is preserved.
49     * ====================================================
50     *
51     */
52    
53     /* __ieee754_acosh(x)
54     * Method :
55     * Based on
56     * acosh(x) = log [ x + sqrt(x*x-1) ]
57     * we have
58     * acosh(x) := log(x)+ln2, if x is large; else
59     * acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
60     * acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
61     *
62     * Special cases:
63     * acosh(x) is NaN with signal if x<1.
64     * acosh(NaN) is NaN without signal.
65     */
66    
67     #include "fdlibm.h"
68    
69     #ifdef __STDC__
70     static const double
71     #else
72     static double
73     #endif
74     one = 1.0,
75     ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */
76    
77     #ifdef __STDC__
78     double __ieee754_acosh(double x)
79     #else
80     double __ieee754_acosh(x)
81     double x;
82     #endif
83     {
84     fd_twoints u;
85     double t;
86     int hx;
87     u.d = x;
88     hx = __HI(u);
89     if(hx<0x3ff00000) { /* x < 1 */
90     return (x-x)/(x-x);
91     } else if(hx >=0x41b00000) { /* x > 2**28 */
92     if(hx >=0x7ff00000) { /* x is inf of NaN */
93     return x+x;
94     } else
95     return __ieee754_log(x)+ln2; /* acosh(huge)=log(2x) */
96     } else if(((hx-0x3ff00000)|__LO(u))==0) {
97     return 0.0; /* acosh(1) = 0 */
98     } else if (hx > 0x40000000) { /* 2**28 > x > 2 */
99     t=x*x;
100     return __ieee754_log(2.0*x-one/(x+fd_sqrt(t-one)));
101     } else { /* 1<x<2 */
102     t = x-one;
103     return fd_log1p(t+fd_sqrt(2.0*t+t*t));
104     }
105     }

  ViewVC Help
Powered by ViewVC 1.1.24