Mercurial > hg > octave-kai > gnulib-hg
annotate lib/atanl.c @ 17476:6057744acd2c default tip master
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Fri, 16 Aug 2013 06:32:22 -0700 (2013-08-16) |
parents | 2074f2bf7216 |
children |
rev | line source |
---|---|
8186
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
1 /* Copyright 2001 by Stephen L. Moshier <moshier@na-net.ornl.gov> |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
2 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8563
diff
changeset
|
3 This program is free software: you can redistribute it and/or modify |
8186
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
4 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8563
diff
changeset
|
5 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8563
diff
changeset
|
6 (at your option) any later version. |
8186
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
7 |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
8 This program is distributed in the hope that it will be useful, |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
9 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
11 GNU General Public License for more details. |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
12 |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8563
diff
changeset
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8186
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
15 |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
16 #include <config.h> |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
17 |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
18 /* Specification. */ |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
19 #include <math.h> |
c115624bf99a
New module 'math'. <math.h> replaces mathl.h.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
20 |
15944
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
21 #if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE |
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
22 |
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
23 long double |
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
24 atanl (long double x) |
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
25 { |
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
26 return atan (x); |
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
27 } |
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
28 |
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
29 #else |
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
30 |
16511 | 31 /* Code based on glibc/sysdeps/ieee754/ldbl-128/s_atanl.c. */ |
32 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10667
diff
changeset
|
33 /* s_atanl.c |
4239
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 * |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10667
diff
changeset
|
35 * Inverse circular tangent for 128-bit long double precision |
4239
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 * (arctangent) |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 * SYNOPSIS: |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 * long double x, y, atanl(); |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 * y = atanl( x ); |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 * DESCRIPTION: |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 * Returns radian angle between -pi/2 and +pi/2 whose tangent is x. |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 * The function uses a rational approximation of the form |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 * t + t^3 P(t^2)/Q(t^2), optimized for |t| < 0.09375. |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 * The argument is reduced using the identity |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 * arctan x - arctan u = arctan ((x-u)/(1 + ux)) |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 * and an 83-entry lookup table for arctan u, with u = 0, 1/8, ..., 10.25. |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 * Use of the table improves the execution speed of the routine. |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 * ACCURACY: |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 * Relative error: |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 * arithmetic domain # trials peak rms |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 * IEEE -19, 19 4e5 1.7e-34 5.4e-35 |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 * WARNING: |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
70 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 * This program uses integer operations on bit fields of floating-point |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 * numbers. It does not work with data structures other than the |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 * structure assumed. |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
74 * |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 */ |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
76 |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
77 /* arctan(k/8), k = 0, ..., 82 */ |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 static const long double atantbl[84] = { |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
79 0.0000000000000000000000000000000000000000E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
80 1.2435499454676143503135484916387102557317E-1L, /* arctan(0.125) */ |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
81 2.4497866312686415417208248121127581091414E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
82 3.5877067027057222039592006392646049977698E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
83 4.6364760900080611621425623146121440202854E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
84 5.5859931534356243597150821640166127034645E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
85 6.4350110879328438680280922871732263804151E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
86 7.1882999962162450541701415152590465395142E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
87 7.8539816339744830961566084581987572104929E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
88 8.4415398611317100251784414827164750652594E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
89 8.9605538457134395617480071802993782702458E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
90 9.4200004037946366473793717053459358607166E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
91 9.8279372324732906798571061101466601449688E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
92 1.0191413442663497346383429170230636487744E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
93 1.0516502125483736674598673120862998296302E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
94 1.0808390005411683108871567292171998202703E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
95 1.1071487177940905030170654601785370400700E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
96 1.1309537439791604464709335155363278047493E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
97 1.1525719972156675180401498626127513797495E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
98 1.1722738811284763866005949441337046149712E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
99 1.1902899496825317329277337748293183376012E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
100 1.2068173702852525303955115800565576303133E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
101 1.2220253232109896370417417439225704908830E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
102 1.2360594894780819419094519711090786987027E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
103 1.2490457723982544258299170772810901230778E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
104 1.2610933822524404193139408812473357720101E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
105 1.2722973952087173412961937498224804940684E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
106 1.2827408797442707473628852511364955306249E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
107 1.2924966677897852679030914214070816845853E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
108 1.3016288340091961438047858503666855921414E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
109 1.3101939350475556342564376891719053122733E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
110 1.3182420510168370498593302023271362531155E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
111 1.3258176636680324650592392104284756311844E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
112 1.3329603993374458675538498697331558093700E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
113 1.3397056595989995393283037525895557411039E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
114 1.3460851583802539310489409282517796256512E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
115 1.3521273809209546571891479413898128509842E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
116 1.3578579772154994751124898859640585287459E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
117 1.3633001003596939542892985278250991189943E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
118 1.3684746984165928776366381936948529556191E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
119 1.3734007669450158608612719264449611486510E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
120 1.3780955681325110444536609641291551522494E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
121 1.3825748214901258580599674177685685125566E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
122 1.3868528702577214543289381097042486034883E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
123 1.3909428270024183486427686943836432060856E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
124 1.3948567013423687823948122092044222644895E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
125 1.3986055122719575950126700816114282335732E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
126 1.4021993871854670105330304794336492676944E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
127 1.4056476493802697809521934019958079881002E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
128 1.4089588955564736949699075250792569287156E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
129 1.4121410646084952153676136718584891599630E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
130 1.4152014988178669079462550975833894394929E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
131 1.4181469983996314594038603039700989523716E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
132 1.4209838702219992566633046424614466661176E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
133 1.4237179714064941189018190466107297503086E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
134 1.4263547484202526397918060597281265695725E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
135 1.4288992721907326964184700745371983590908E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
136 1.4313562697035588982240194668401779312122E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
137 1.4337301524847089866404719096698873648610E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
138 1.4360250423171655234964275337155008780675E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
139 1.4382447944982225979614042479354815855386E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
140 1.4403930189057632173997301031392126865694E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
141 1.4424730991091018200252920599377292525125E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
142 1.4444882097316563655148453598508037025938E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
143 1.4464413322481351841999668424758804165254E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
144 1.4483352693775551917970437843145232637695E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
145 1.4501726582147939000905940595923466567576E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
146 1.4519559822271314199339700039142990228105E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
147 1.4536875822280323362423034480994649820285E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
148 1.4553696664279718992423082296859928222270E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
149 1.4570043196511885530074841089245667532358E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
150 1.4585935117976422128825857356750737658039E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
151 1.4601391056210009726721818194296893361233E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
152 1.4616428638860188872060496086383008594310E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
153 1.4631064559620759326975975316301202111560E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
154 1.4645314639038178118428450961503371619177E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
155 1.4659193880646627234129855241049975398470E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
156 1.4672716522843522691530527207287398276197E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
157 1.4685896086876430842559640450619880951144E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
158 1.4698745421276027686510391411132998919794E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
159 1.4711276743037345918528755717617308518553E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
160 1.4723501675822635384916444186631899205983E0L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
161 1.4735431285433308455179928682541563973416E0L, /* arctan(10.25) */ |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
162 1.5707963267948966192313216916397514420986E0L /* pi/2 */ |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
163 }; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
164 |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
165 |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
166 /* arctan t = t + t^3 p(t^2) / q(t^2) |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
167 |t| <= 0.09375 |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
168 peak relative error 5.3e-37 */ |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
169 |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
170 static const long double |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
171 p0 = -4.283708356338736809269381409828726405572E1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
172 p1 = -8.636132499244548540964557273544599863825E1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
173 p2 = -5.713554848244551350855604111031839613216E1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
174 p3 = -1.371405711877433266573835355036413750118E1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
175 p4 = -8.638214309119210906997318946650189640184E-1L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
176 q0 = 1.285112506901621042780814422948906537959E2L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
177 q1 = 3.361907253914337187957855834229672347089E2L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
178 q2 = 3.180448303864130128268191635189365331680E2L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
179 q3 = 1.307244136980865800160844625025280344686E2L, |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
180 q4 = 2.173623741810414221251136181221172551416E1L; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
181 /* q5 = 1.000000000000000000000000000000000000000E0 */ |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
182 |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
183 |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
184 long double |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
185 atanl (long double x) |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
186 { |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
187 int k, sign; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
188 long double t, u, p, q; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
189 |
8563
c3d334708928
Better support of signalling NaNs.
Bruno Haible <bruno@clisp.org>
parents:
8186
diff
changeset
|
190 /* Check for zero or NaN. */ |
c3d334708928
Better support of signalling NaNs.
Bruno Haible <bruno@clisp.org>
parents:
8186
diff
changeset
|
191 if (isnanl (x) || x == 0.0) |
c3d334708928
Better support of signalling NaNs.
Bruno Haible <bruno@clisp.org>
parents:
8186
diff
changeset
|
192 return x + x; |
4239
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
193 |
8563
c3d334708928
Better support of signalling NaNs.
Bruno Haible <bruno@clisp.org>
parents:
8186
diff
changeset
|
194 sign = x < 0.0; |
4239
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
195 |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
196 if (x + x == x) |
5327
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
197 { |
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
198 /* Infinity. */ |
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
199 if (sign) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10667
diff
changeset
|
200 return -atantbl[83]; |
5327
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
201 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10667
diff
changeset
|
202 return atantbl[83]; |
5327
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
203 } |
4239
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
204 |
5327
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
205 if (sign) |
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
206 x = -x; |
4239
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
207 |
5327
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
208 if (x >= 10.25) |
4239
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
209 { |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
210 k = 83; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
211 t = -1.0/x; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
212 } |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
213 else |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
214 { |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
215 /* Index of nearest table element. |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10667
diff
changeset
|
216 Roundoff to integer is asymmetrical to avoid cancellation when t < 0 |
4239
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
217 (cf. fdlibm). */ |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
218 k = 8.0 * x + 0.25; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
219 u = 0.125 * k; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
220 /* Small arctan argument. */ |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
221 t = (x - u) / (1.0 + x * u); |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
222 } |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
223 |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
224 /* Arctan of small argument t. */ |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
225 u = t * t; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
226 p = ((((p4 * u) + p3) * u + p2) * u + p1) * u + p0; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
227 q = ((((u + q4) * u + q3) * u + q2) * u + q1) * u + q0; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
228 u = t * u * p / q + t; |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
229 |
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
230 /* arctan x = arctan u + arctan t */ |
5327
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
231 u = atantbl[k] + u; |
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
232 if (sign) |
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
233 return (-u); |
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
234 else |
31a3d72751e2
Add GPL notice, to match glibc's added LGPL notice.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4239
diff
changeset
|
235 return u; |
4239
b33b8603715c
Transcendental functions for 'long double', from Paolo Bonzini.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
236 } |
15944
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
237 |
4b3d35486c68
atanl: Simplify for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
238 #endif |