jbarnette-johnson 1.0.0.200806240111 → 1.0.0.200807291507
Sign up to get free protection for your applications and to get access to all the features.
- data/MANIFEST +1 -0
- data/Rakefile +3 -10
- data/bin/johnson +2 -1
- data/ext/spidermonkey/context.c +3 -4
- data/ext/spidermonkey/context.h +1 -1
- data/ext/spidermonkey/conversions.c +39 -33
- data/ext/spidermonkey/debugger.c +5 -5
- data/ext/spidermonkey/immutable_node.c.erb +11 -11
- data/ext/spidermonkey/jroot.h +4 -4
- data/ext/spidermonkey/js_land_proxy.c +9 -8
- data/ext/spidermonkey/ruby_land_proxy.c +5 -4
- data/ext/spidermonkey/runtime.c +1 -1
- data/johnson.gemspec +36 -0
- data/lib/hoe.rb +0 -7
- data/lib/johnson/cli/options.rb +10 -4
- data/lib/johnson/spidermonkey/runtime.rb +2 -2
- data/lib/johnson/version.rb +4 -2
- data/lib/johnson.rb +1 -0
- data/test/johnson/runtime_test.rb +11 -0
- data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +6 -0
- data/vendor/spidermonkey/.cvsignore +9 -0
- data/vendor/spidermonkey/Makefile.in +462 -0
- data/vendor/spidermonkey/Makefile.ref +364 -0
- data/vendor/spidermonkey/README.html +820 -0
- data/vendor/spidermonkey/SpiderMonkey.rsp +12 -0
- data/vendor/spidermonkey/Y.js +19 -0
- data/vendor/spidermonkey/build.mk +43 -0
- data/vendor/spidermonkey/config/AIX4.1.mk +65 -0
- data/vendor/spidermonkey/config/AIX4.2.mk +64 -0
- data/vendor/spidermonkey/config/AIX4.3.mk +65 -0
- data/vendor/spidermonkey/config/Darwin.mk +83 -0
- data/vendor/spidermonkey/config/Darwin1.3.mk +81 -0
- data/vendor/spidermonkey/config/Darwin1.4.mk +41 -0
- data/vendor/spidermonkey/config/Darwin5.2.mk +81 -0
- data/vendor/spidermonkey/config/Darwin5.3.mk +81 -0
- data/vendor/spidermonkey/config/HP-UXB.10.10.mk +77 -0
- data/vendor/spidermonkey/config/HP-UXB.10.20.mk +77 -0
- data/vendor/spidermonkey/config/HP-UXB.11.00.mk +80 -0
- data/vendor/spidermonkey/config/IRIX.mk +87 -0
- data/vendor/spidermonkey/config/IRIX5.3.mk +44 -0
- data/vendor/spidermonkey/config/IRIX6.1.mk +44 -0
- data/vendor/spidermonkey/config/IRIX6.2.mk +44 -0
- data/vendor/spidermonkey/config/IRIX6.3.mk +44 -0
- data/vendor/spidermonkey/config/IRIX6.5.mk +44 -0
- data/vendor/spidermonkey/config/Linux_All.mk +103 -0
- data/vendor/spidermonkey/config/Mac_OS10.0.mk +82 -0
- data/vendor/spidermonkey/config/OSF1V4.0.mk +72 -0
- data/vendor/spidermonkey/config/OSF1V5.0.mk +69 -0
- data/vendor/spidermonkey/config/SunOS4.1.4.mk +101 -0
- data/vendor/spidermonkey/config/SunOS5.10.mk +50 -0
- data/vendor/spidermonkey/config/SunOS5.3.mk +91 -0
- data/vendor/spidermonkey/config/SunOS5.4.mk +92 -0
- data/vendor/spidermonkey/config/SunOS5.5.1.mk +44 -0
- data/vendor/spidermonkey/config/SunOS5.5.mk +87 -0
- data/vendor/spidermonkey/config/SunOS5.6.mk +89 -0
- data/vendor/spidermonkey/config/SunOS5.7.mk +44 -0
- data/vendor/spidermonkey/config/SunOS5.8.mk +44 -0
- data/vendor/spidermonkey/config/SunOS5.9.mk +44 -0
- data/vendor/spidermonkey/config/WINNT4.0.mk +117 -0
- data/vendor/spidermonkey/config/WINNT5.0.mk +117 -0
- data/vendor/spidermonkey/config/WINNT5.1.mk +117 -0
- data/vendor/spidermonkey/config/WINNT5.2.mk +117 -0
- data/vendor/spidermonkey/config/WINNT6.0.mk +117 -0
- data/vendor/spidermonkey/config/dgux.mk +64 -0
- data/vendor/spidermonkey/config.mk +192 -0
- data/vendor/spidermonkey/editline/Makefile.ref +144 -0
- data/vendor/spidermonkey/editline/README +83 -0
- data/vendor/spidermonkey/editline/editline.3 +175 -0
- data/vendor/spidermonkey/editline/editline.c +1369 -0
- data/vendor/spidermonkey/editline/editline.h +135 -0
- data/vendor/spidermonkey/editline/sysunix.c +182 -0
- data/vendor/spidermonkey/editline/unix.h +82 -0
- data/vendor/spidermonkey/fdlibm/.cvsignore +7 -0
- data/vendor/spidermonkey/fdlibm/Makefile.in +127 -0
- data/vendor/spidermonkey/fdlibm/Makefile.ref +192 -0
- data/vendor/spidermonkey/fdlibm/e_acos.c +147 -0
- data/vendor/spidermonkey/fdlibm/e_acosh.c +105 -0
- data/vendor/spidermonkey/fdlibm/e_asin.c +156 -0
- data/vendor/spidermonkey/fdlibm/e_atan2.c +165 -0
- data/vendor/spidermonkey/fdlibm/e_atanh.c +110 -0
- data/vendor/spidermonkey/fdlibm/e_cosh.c +133 -0
- data/vendor/spidermonkey/fdlibm/e_exp.c +202 -0
- data/vendor/spidermonkey/fdlibm/e_fmod.c +184 -0
- data/vendor/spidermonkey/fdlibm/e_gamma.c +71 -0
- data/vendor/spidermonkey/fdlibm/e_gamma_r.c +70 -0
- data/vendor/spidermonkey/fdlibm/e_hypot.c +173 -0
- data/vendor/spidermonkey/fdlibm/e_j0.c +524 -0
- data/vendor/spidermonkey/fdlibm/e_j1.c +523 -0
- data/vendor/spidermonkey/fdlibm/e_jn.c +315 -0
- data/vendor/spidermonkey/fdlibm/e_lgamma.c +71 -0
- data/vendor/spidermonkey/fdlibm/e_lgamma_r.c +347 -0
- data/vendor/spidermonkey/fdlibm/e_log.c +184 -0
- data/vendor/spidermonkey/fdlibm/e_log10.c +134 -0
- data/vendor/spidermonkey/fdlibm/e_pow.c +386 -0
- data/vendor/spidermonkey/fdlibm/e_rem_pio2.c +222 -0
- data/vendor/spidermonkey/fdlibm/e_remainder.c +120 -0
- data/vendor/spidermonkey/fdlibm/e_scalb.c +89 -0
- data/vendor/spidermonkey/fdlibm/e_sinh.c +122 -0
- data/vendor/spidermonkey/fdlibm/e_sqrt.c +497 -0
- data/vendor/spidermonkey/fdlibm/fdlibm.h +273 -0
- data/vendor/spidermonkey/fdlibm/fdlibm.mak +1453 -0
- data/vendor/spidermonkey/fdlibm/fdlibm.mdp +0 -0
- data/vendor/spidermonkey/fdlibm/k_cos.c +135 -0
- data/vendor/spidermonkey/fdlibm/k_rem_pio2.c +354 -0
- data/vendor/spidermonkey/fdlibm/k_sin.c +114 -0
- data/vendor/spidermonkey/fdlibm/k_standard.c +785 -0
- data/vendor/spidermonkey/fdlibm/k_tan.c +170 -0
- data/vendor/spidermonkey/fdlibm/s_asinh.c +101 -0
- data/vendor/spidermonkey/fdlibm/s_atan.c +175 -0
- data/vendor/spidermonkey/fdlibm/s_cbrt.c +133 -0
- data/vendor/spidermonkey/fdlibm/s_ceil.c +120 -0
- data/vendor/spidermonkey/fdlibm/s_copysign.c +72 -0
- data/vendor/spidermonkey/fdlibm/s_cos.c +118 -0
- data/vendor/spidermonkey/fdlibm/s_erf.c +356 -0
- data/vendor/spidermonkey/fdlibm/s_expm1.c +267 -0
- data/vendor/spidermonkey/fdlibm/s_fabs.c +70 -0
- data/vendor/spidermonkey/fdlibm/s_finite.c +71 -0
- data/vendor/spidermonkey/fdlibm/s_floor.c +121 -0
- data/vendor/spidermonkey/fdlibm/s_frexp.c +99 -0
- data/vendor/spidermonkey/fdlibm/s_ilogb.c +85 -0
- data/vendor/spidermonkey/fdlibm/s_isnan.c +74 -0
- data/vendor/spidermonkey/fdlibm/s_ldexp.c +66 -0
- data/vendor/spidermonkey/fdlibm/s_lib_version.c +73 -0
- data/vendor/spidermonkey/fdlibm/s_log1p.c +211 -0
- data/vendor/spidermonkey/fdlibm/s_logb.c +79 -0
- data/vendor/spidermonkey/fdlibm/s_matherr.c +64 -0
- data/vendor/spidermonkey/fdlibm/s_modf.c +132 -0
- data/vendor/spidermonkey/fdlibm/s_nextafter.c +124 -0
- data/vendor/spidermonkey/fdlibm/s_rint.c +131 -0
- data/vendor/spidermonkey/fdlibm/s_scalbn.c +107 -0
- data/vendor/spidermonkey/fdlibm/s_signgam.c +40 -0
- data/vendor/spidermonkey/fdlibm/s_significand.c +68 -0
- data/vendor/spidermonkey/fdlibm/s_sin.c +118 -0
- data/vendor/spidermonkey/fdlibm/s_tan.c +112 -0
- data/vendor/spidermonkey/fdlibm/s_tanh.c +122 -0
- data/vendor/spidermonkey/fdlibm/w_acos.c +78 -0
- data/vendor/spidermonkey/fdlibm/w_acosh.c +78 -0
- data/vendor/spidermonkey/fdlibm/w_asin.c +80 -0
- data/vendor/spidermonkey/fdlibm/w_atan2.c +79 -0
- data/vendor/spidermonkey/fdlibm/w_atanh.c +81 -0
- data/vendor/spidermonkey/fdlibm/w_cosh.c +77 -0
- data/vendor/spidermonkey/fdlibm/w_exp.c +88 -0
- data/vendor/spidermonkey/fdlibm/w_fmod.c +78 -0
- data/vendor/spidermonkey/fdlibm/w_gamma.c +85 -0
- data/vendor/spidermonkey/fdlibm/w_gamma_r.c +81 -0
- data/vendor/spidermonkey/fdlibm/w_hypot.c +78 -0
- data/vendor/spidermonkey/fdlibm/w_j0.c +105 -0
- data/vendor/spidermonkey/fdlibm/w_j1.c +106 -0
- data/vendor/spidermonkey/fdlibm/w_jn.c +128 -0
- data/vendor/spidermonkey/fdlibm/w_lgamma.c +85 -0
- data/vendor/spidermonkey/fdlibm/w_lgamma_r.c +81 -0
- data/vendor/spidermonkey/fdlibm/w_log.c +78 -0
- data/vendor/spidermonkey/fdlibm/w_log10.c +81 -0
- data/vendor/spidermonkey/fdlibm/w_pow.c +99 -0
- data/vendor/spidermonkey/fdlibm/w_remainder.c +77 -0
- data/vendor/spidermonkey/fdlibm/w_scalb.c +95 -0
- data/vendor/spidermonkey/fdlibm/w_sinh.c +77 -0
- data/vendor/spidermonkey/fdlibm/w_sqrt.c +77 -0
- data/vendor/spidermonkey/javascript-trace.d +73 -0
- data/vendor/spidermonkey/js.c +3951 -0
- data/vendor/spidermonkey/js.mak +4438 -0
- data/vendor/spidermonkey/js.mdp +0 -0
- data/vendor/spidermonkey/js.msg +307 -0
- data/vendor/spidermonkey/js.pkg +2 -0
- data/vendor/spidermonkey/js3240.rc +79 -0
- data/vendor/spidermonkey/jsOS240.def +654 -0
- data/vendor/spidermonkey/jsapi.c +5836 -0
- data/vendor/spidermonkey/jsapi.h +2624 -0
- data/vendor/spidermonkey/jsarena.c +450 -0
- data/vendor/spidermonkey/jsarena.h +318 -0
- data/vendor/spidermonkey/jsarray.c +2988 -0
- data/vendor/spidermonkey/jsarray.h +124 -0
- data/vendor/spidermonkey/jsatom.c +1045 -0
- data/vendor/spidermonkey/jsatom.h +442 -0
- data/vendor/spidermonkey/jsbit.h +253 -0
- data/vendor/spidermonkey/jsbool.c +176 -0
- data/vendor/spidermonkey/jsbool.h +73 -0
- data/vendor/spidermonkey/jsclist.h +139 -0
- data/vendor/spidermonkey/jscntxt.c +1348 -0
- data/vendor/spidermonkey/jscntxt.h +1120 -0
- data/vendor/spidermonkey/jscompat.h +57 -0
- data/vendor/spidermonkey/jsconfig.h +248 -0
- data/vendor/spidermonkey/jsconfig.mk +181 -0
- data/vendor/spidermonkey/jscpucfg.c +383 -0
- data/vendor/spidermonkey/jscpucfg.h +212 -0
- data/vendor/spidermonkey/jsdate.c +2398 -0
- data/vendor/spidermonkey/jsdate.h +124 -0
- data/vendor/spidermonkey/jsdbgapi.c +1799 -0
- data/vendor/spidermonkey/jsdbgapi.h +464 -0
- data/vendor/spidermonkey/jsdhash.c +868 -0
- data/vendor/spidermonkey/jsdhash.h +592 -0
- data/vendor/spidermonkey/jsdtoa.c +3167 -0
- data/vendor/spidermonkey/jsdtoa.h +130 -0
- data/vendor/spidermonkey/jsdtracef.c +317 -0
- data/vendor/spidermonkey/jsdtracef.h +77 -0
- data/vendor/spidermonkey/jsemit.c +6909 -0
- data/vendor/spidermonkey/jsemit.h +741 -0
- data/vendor/spidermonkey/jsexn.c +1371 -0
- data/vendor/spidermonkey/jsexn.h +96 -0
- data/vendor/spidermonkey/jsfile.c +2736 -0
- data/vendor/spidermonkey/jsfile.h +56 -0
- data/vendor/spidermonkey/jsfile.msg +90 -0
- data/vendor/spidermonkey/jsfun.c +2634 -0
- data/vendor/spidermonkey/jsfun.h +254 -0
- data/vendor/spidermonkey/jsgc.c +3554 -0
- data/vendor/spidermonkey/jsgc.h +403 -0
- data/vendor/spidermonkey/jshash.c +476 -0
- data/vendor/spidermonkey/jshash.h +151 -0
- data/vendor/spidermonkey/jsify.pl +485 -0
- data/vendor/spidermonkey/jsinterp.c +6981 -0
- data/vendor/spidermonkey/jsinterp.h +521 -0
- data/vendor/spidermonkey/jsinvoke.c +43 -0
- data/vendor/spidermonkey/jsiter.c +1067 -0
- data/vendor/spidermonkey/jsiter.h +122 -0
- data/vendor/spidermonkey/jskeyword.tbl +124 -0
- data/vendor/spidermonkey/jskwgen.c +460 -0
- data/vendor/spidermonkey/jslibmath.h +266 -0
- data/vendor/spidermonkey/jslock.c +1309 -0
- data/vendor/spidermonkey/jslock.h +313 -0
- data/vendor/spidermonkey/jslocko.asm +60 -0
- data/vendor/spidermonkey/jslog2.c +94 -0
- data/vendor/spidermonkey/jslong.c +264 -0
- data/vendor/spidermonkey/jslong.h +412 -0
- data/vendor/spidermonkey/jsmath.c +568 -0
- data/vendor/spidermonkey/jsmath.h +57 -0
- data/vendor/spidermonkey/jsnum.c +1228 -0
- data/vendor/spidermonkey/jsnum.h +283 -0
- data/vendor/spidermonkey/jsobj.c +5266 -0
- data/vendor/spidermonkey/jsobj.h +709 -0
- data/vendor/spidermonkey/jsopcode.c +5245 -0
- data/vendor/spidermonkey/jsopcode.h +394 -0
- data/vendor/spidermonkey/jsopcode.tbl +523 -0
- data/vendor/spidermonkey/jsotypes.h +202 -0
- data/vendor/spidermonkey/jsparse.c +6680 -0
- data/vendor/spidermonkey/jsparse.h +511 -0
- data/vendor/spidermonkey/jsprf.c +1262 -0
- data/vendor/spidermonkey/jsprf.h +150 -0
- data/vendor/spidermonkey/jsproto.tbl +128 -0
- data/vendor/spidermonkey/jsprvtd.h +267 -0
- data/vendor/spidermonkey/jspubtd.h +744 -0
- data/vendor/spidermonkey/jsregexp.c +4352 -0
- data/vendor/spidermonkey/jsregexp.h +183 -0
- data/vendor/spidermonkey/jsreops.tbl +145 -0
- data/vendor/spidermonkey/jsscan.c +2003 -0
- data/vendor/spidermonkey/jsscan.h +387 -0
- data/vendor/spidermonkey/jsscope.c +1948 -0
- data/vendor/spidermonkey/jsscope.h +418 -0
- data/vendor/spidermonkey/jsscript.c +1832 -0
- data/vendor/spidermonkey/jsscript.h +287 -0
- data/vendor/spidermonkey/jsshell.msg +50 -0
- data/vendor/spidermonkey/jsstddef.h +83 -0
- data/vendor/spidermonkey/jsstr.c +5004 -0
- data/vendor/spidermonkey/jsstr.h +641 -0
- data/vendor/spidermonkey/jstypes.h +475 -0
- data/vendor/spidermonkey/jsutil.c +345 -0
- data/vendor/spidermonkey/jsutil.h +157 -0
- data/vendor/spidermonkey/jsxdrapi.c +800 -0
- data/vendor/spidermonkey/jsxdrapi.h +218 -0
- data/vendor/spidermonkey/jsxml.c +8471 -0
- data/vendor/spidermonkey/jsxml.h +349 -0
- data/vendor/spidermonkey/lock_SunOS.s +119 -0
- data/vendor/spidermonkey/perfect.js +39 -0
- data/vendor/spidermonkey/plify_jsdhash.sed +36 -0
- data/vendor/spidermonkey/prmjtime.c +846 -0
- data/vendor/spidermonkey/prmjtime.h +103 -0
- data/vendor/spidermonkey/resource.h +15 -0
- data/vendor/spidermonkey/rules.mk +197 -0
- data/vendor/spidermonkey/win32.order +384 -0
- metadata +4 -3
@@ -0,0 +1,315 @@
|
|
1
|
+
/* -*- 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_jn.c 1.4 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_jn(n, x), __ieee754_yn(n, x)
|
54
|
+
* floating point Bessel's function of the 1st and 2nd kind
|
55
|
+
* of order n
|
56
|
+
*
|
57
|
+
* Special cases:
|
58
|
+
* y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal;
|
59
|
+
* y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal.
|
60
|
+
* Note 2. About jn(n,x), yn(n,x)
|
61
|
+
* For n=0, j0(x) is called,
|
62
|
+
* for n=1, j1(x) is called,
|
63
|
+
* for n<x, forward recursion us used starting
|
64
|
+
* from values of j0(x) and j1(x).
|
65
|
+
* for n>x, a continued fraction approximation to
|
66
|
+
* j(n,x)/j(n-1,x) is evaluated and then backward
|
67
|
+
* recursion is used starting from a supposed value
|
68
|
+
* for j(n,x). The resulting value of j(0,x) is
|
69
|
+
* compared with the actual value to correct the
|
70
|
+
* supposed value of j(n,x).
|
71
|
+
*
|
72
|
+
* yn(n,x) is similar in all respects, except
|
73
|
+
* that forward recursion is used for all
|
74
|
+
* values of n>1.
|
75
|
+
*
|
76
|
+
*/
|
77
|
+
|
78
|
+
#include "fdlibm.h"
|
79
|
+
|
80
|
+
#ifdef __STDC__
|
81
|
+
static const double
|
82
|
+
#else
|
83
|
+
static double
|
84
|
+
#endif
|
85
|
+
invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
|
86
|
+
two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */
|
87
|
+
one = 1.00000000000000000000e+00; /* 0x3FF00000, 0x00000000 */
|
88
|
+
|
89
|
+
static double zero = 0.00000000000000000000e+00;
|
90
|
+
|
91
|
+
#ifdef __STDC__
|
92
|
+
double __ieee754_jn(int n, double x)
|
93
|
+
#else
|
94
|
+
double __ieee754_jn(n,x)
|
95
|
+
int n; double x;
|
96
|
+
#endif
|
97
|
+
{
|
98
|
+
fd_twoints u;
|
99
|
+
int i,hx,ix,lx, sgn;
|
100
|
+
double a, b, temp, di;
|
101
|
+
double z, w;
|
102
|
+
|
103
|
+
/* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x)
|
104
|
+
* Thus, J(-n,x) = J(n,-x)
|
105
|
+
*/
|
106
|
+
u.d = x;
|
107
|
+
hx = __HI(u);
|
108
|
+
ix = 0x7fffffff&hx;
|
109
|
+
lx = __LO(u);
|
110
|
+
/* if J(n,NaN) is NaN */
|
111
|
+
if((ix|((unsigned)(lx|-lx))>>31)>0x7ff00000) return x+x;
|
112
|
+
if(n<0){
|
113
|
+
n = -n;
|
114
|
+
x = -x;
|
115
|
+
hx ^= 0x80000000;
|
116
|
+
}
|
117
|
+
if(n==0) return(__ieee754_j0(x));
|
118
|
+
if(n==1) return(__ieee754_j1(x));
|
119
|
+
sgn = (n&1)&(hx>>31); /* even n -- 0, odd n -- sign(x) */
|
120
|
+
x = fd_fabs(x);
|
121
|
+
if((ix|lx)==0||ix>=0x7ff00000) /* if x is 0 or inf */
|
122
|
+
b = zero;
|
123
|
+
else if((double)n<=x) {
|
124
|
+
/* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */
|
125
|
+
if(ix>=0x52D00000) { /* x > 2**302 */
|
126
|
+
/* (x >> n**2)
|
127
|
+
* Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi)
|
128
|
+
* Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi)
|
129
|
+
* Let s=sin(x), c=cos(x),
|
130
|
+
* xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then
|
131
|
+
*
|
132
|
+
* n sin(xn)*sqt2 cos(xn)*sqt2
|
133
|
+
* ----------------------------------
|
134
|
+
* 0 s-c c+s
|
135
|
+
* 1 -s-c -c+s
|
136
|
+
* 2 -s+c -c-s
|
137
|
+
* 3 s+c c-s
|
138
|
+
*/
|
139
|
+
switch(n&3) {
|
140
|
+
case 0: temp = fd_cos(x)+fd_sin(x); break;
|
141
|
+
case 1: temp = -fd_cos(x)+fd_sin(x); break;
|
142
|
+
case 2: temp = -fd_cos(x)-fd_sin(x); break;
|
143
|
+
case 3: temp = fd_cos(x)-fd_sin(x); break;
|
144
|
+
}
|
145
|
+
b = invsqrtpi*temp/fd_sqrt(x);
|
146
|
+
} else {
|
147
|
+
a = __ieee754_j0(x);
|
148
|
+
b = __ieee754_j1(x);
|
149
|
+
for(i=1;i<n;i++){
|
150
|
+
temp = b;
|
151
|
+
b = b*((double)(i+i)/x) - a; /* avoid underflow */
|
152
|
+
a = temp;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
} else {
|
156
|
+
if(ix<0x3e100000) { /* x < 2**-29 */
|
157
|
+
/* x is tiny, return the first Taylor expansion of J(n,x)
|
158
|
+
* J(n,x) = 1/n!*(x/2)^n - ...
|
159
|
+
*/
|
160
|
+
if(n>33) /* underflow */
|
161
|
+
b = zero;
|
162
|
+
else {
|
163
|
+
temp = x*0.5; b = temp;
|
164
|
+
for (a=one,i=2;i<=n;i++) {
|
165
|
+
a *= (double)i; /* a = n! */
|
166
|
+
b *= temp; /* b = (x/2)^n */
|
167
|
+
}
|
168
|
+
b = b/a;
|
169
|
+
}
|
170
|
+
} else {
|
171
|
+
/* use backward recurrence */
|
172
|
+
/* x x^2 x^2
|
173
|
+
* J(n,x)/J(n-1,x) = ---- ------ ------ .....
|
174
|
+
* 2n - 2(n+1) - 2(n+2)
|
175
|
+
*
|
176
|
+
* 1 1 1
|
177
|
+
* (for large x) = ---- ------ ------ .....
|
178
|
+
* 2n 2(n+1) 2(n+2)
|
179
|
+
* -- - ------ - ------ -
|
180
|
+
* x x x
|
181
|
+
*
|
182
|
+
* Let w = 2n/x and h=2/x, then the above quotient
|
183
|
+
* is equal to the continued fraction:
|
184
|
+
* 1
|
185
|
+
* = -----------------------
|
186
|
+
* 1
|
187
|
+
* w - -----------------
|
188
|
+
* 1
|
189
|
+
* w+h - ---------
|
190
|
+
* w+2h - ...
|
191
|
+
*
|
192
|
+
* To determine how many terms needed, let
|
193
|
+
* Q(0) = w, Q(1) = w(w+h) - 1,
|
194
|
+
* Q(k) = (w+k*h)*Q(k-1) - Q(k-2),
|
195
|
+
* When Q(k) > 1e4 good for single
|
196
|
+
* When Q(k) > 1e9 good for double
|
197
|
+
* When Q(k) > 1e17 good for quadruple
|
198
|
+
*/
|
199
|
+
/* determine k */
|
200
|
+
double t,v;
|
201
|
+
double q0,q1,h,tmp; int k,m;
|
202
|
+
w = (n+n)/(double)x; h = 2.0/(double)x;
|
203
|
+
q0 = w; z = w+h; q1 = w*z - 1.0; k=1;
|
204
|
+
while(q1<1.0e9) {
|
205
|
+
k += 1; z += h;
|
206
|
+
tmp = z*q1 - q0;
|
207
|
+
q0 = q1;
|
208
|
+
q1 = tmp;
|
209
|
+
}
|
210
|
+
m = n+n;
|
211
|
+
for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t);
|
212
|
+
a = t;
|
213
|
+
b = one;
|
214
|
+
/* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n)
|
215
|
+
* Hence, if n*(log(2n/x)) > ...
|
216
|
+
* single 8.8722839355e+01
|
217
|
+
* double 7.09782712893383973096e+02
|
218
|
+
* long double 1.1356523406294143949491931077970765006170e+04
|
219
|
+
* then recurrent value may overflow and the result is
|
220
|
+
* likely underflow to zero
|
221
|
+
*/
|
222
|
+
tmp = n;
|
223
|
+
v = two/x;
|
224
|
+
tmp = tmp*__ieee754_log(fd_fabs(v*tmp));
|
225
|
+
if(tmp<7.09782712893383973096e+02) {
|
226
|
+
for(i=n-1,di=(double)(i+i);i>0;i--){
|
227
|
+
temp = b;
|
228
|
+
b *= di;
|
229
|
+
b = b/x - a;
|
230
|
+
a = temp;
|
231
|
+
di -= two;
|
232
|
+
}
|
233
|
+
} else {
|
234
|
+
for(i=n-1,di=(double)(i+i);i>0;i--){
|
235
|
+
temp = b;
|
236
|
+
b *= di;
|
237
|
+
b = b/x - a;
|
238
|
+
a = temp;
|
239
|
+
di -= two;
|
240
|
+
/* scale b to avoid spurious overflow */
|
241
|
+
if(b>1e100) {
|
242
|
+
a /= b;
|
243
|
+
t /= b;
|
244
|
+
b = one;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}
|
248
|
+
b = (t*__ieee754_j0(x)/b);
|
249
|
+
}
|
250
|
+
}
|
251
|
+
if(sgn==1) return -b; else return b;
|
252
|
+
}
|
253
|
+
|
254
|
+
#ifdef __STDC__
|
255
|
+
double __ieee754_yn(int n, double x)
|
256
|
+
#else
|
257
|
+
double __ieee754_yn(n,x)
|
258
|
+
int n; double x;
|
259
|
+
#endif
|
260
|
+
{
|
261
|
+
fd_twoints u;
|
262
|
+
int i,hx,ix,lx;
|
263
|
+
int sign;
|
264
|
+
double a, b, temp;
|
265
|
+
|
266
|
+
u.d = x;
|
267
|
+
hx = __HI(u);
|
268
|
+
ix = 0x7fffffff&hx;
|
269
|
+
lx = __LO(u);
|
270
|
+
/* if Y(n,NaN) is NaN */
|
271
|
+
if((ix|((unsigned)(lx|-lx))>>31)>0x7ff00000) return x+x;
|
272
|
+
if((ix|lx)==0) return -one/zero;
|
273
|
+
if(hx<0) return zero/zero;
|
274
|
+
sign = 1;
|
275
|
+
if(n<0){
|
276
|
+
n = -n;
|
277
|
+
sign = 1 - ((n&1)<<1);
|
278
|
+
}
|
279
|
+
if(n==0) return(__ieee754_y0(x));
|
280
|
+
if(n==1) return(sign*__ieee754_y1(x));
|
281
|
+
if(ix==0x7ff00000) return zero;
|
282
|
+
if(ix>=0x52D00000) { /* x > 2**302 */
|
283
|
+
/* (x >> n**2)
|
284
|
+
* Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi)
|
285
|
+
* Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi)
|
286
|
+
* Let s=sin(x), c=cos(x),
|
287
|
+
* xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then
|
288
|
+
*
|
289
|
+
* n sin(xn)*sqt2 cos(xn)*sqt2
|
290
|
+
* ----------------------------------
|
291
|
+
* 0 s-c c+s
|
292
|
+
* 1 -s-c -c+s
|
293
|
+
* 2 -s+c -c-s
|
294
|
+
* 3 s+c c-s
|
295
|
+
*/
|
296
|
+
switch(n&3) {
|
297
|
+
case 0: temp = fd_sin(x)-fd_cos(x); break;
|
298
|
+
case 1: temp = -fd_sin(x)-fd_cos(x); break;
|
299
|
+
case 2: temp = -fd_sin(x)+fd_cos(x); break;
|
300
|
+
case 3: temp = fd_sin(x)+fd_cos(x); break;
|
301
|
+
}
|
302
|
+
b = invsqrtpi*temp/fd_sqrt(x);
|
303
|
+
} else {
|
304
|
+
a = __ieee754_y0(x);
|
305
|
+
b = __ieee754_y1(x);
|
306
|
+
/* quit if b is -inf */
|
307
|
+
u.d = b;
|
308
|
+
for(i=1;i<n&&(__HI(u) != 0xfff00000);i++){
|
309
|
+
temp = b;
|
310
|
+
b = ((double)(i+i)/x)*b - a;
|
311
|
+
a = temp;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
if(sign>0) return b; else return -b;
|
315
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/* -*- 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_lgamma.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_lgamma(x)
|
54
|
+
* Return the logarithm of the Gamma function of x.
|
55
|
+
*
|
56
|
+
* Method: call __ieee754_lgamma_r
|
57
|
+
*/
|
58
|
+
|
59
|
+
#include "fdlibm.h"
|
60
|
+
|
61
|
+
extern int signgam;
|
62
|
+
|
63
|
+
#ifdef __STDC__
|
64
|
+
double __ieee754_lgamma(double x)
|
65
|
+
#else
|
66
|
+
double __ieee754_lgamma(x)
|
67
|
+
double x;
|
68
|
+
#endif
|
69
|
+
{
|
70
|
+
return __ieee754_lgamma_r(x,&signgam);
|
71
|
+
}
|
@@ -0,0 +1,347 @@
|
|
1
|
+
/* -*- 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_lgamma_r.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_lgamma_r(x, signgamp)
|
54
|
+
* Reentrant version of the logarithm of the Gamma function
|
55
|
+
* with user provide pointer for the sign of Gamma(x).
|
56
|
+
*
|
57
|
+
* Method:
|
58
|
+
* 1. Argument Reduction for 0 < x <= 8
|
59
|
+
* Since gamma(1+s)=s*gamma(s), for x in [0,8], we may
|
60
|
+
* reduce x to a number in [1.5,2.5] by
|
61
|
+
* lgamma(1+s) = log(s) + lgamma(s)
|
62
|
+
* for example,
|
63
|
+
* lgamma(7.3) = log(6.3) + lgamma(6.3)
|
64
|
+
* = log(6.3*5.3) + lgamma(5.3)
|
65
|
+
* = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3)
|
66
|
+
* 2. Polynomial approximation of lgamma around its
|
67
|
+
* minimun ymin=1.461632144968362245 to maintain monotonicity.
|
68
|
+
* On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use
|
69
|
+
* Let z = x-ymin;
|
70
|
+
* lgamma(x) = -1.214862905358496078218 + z^2*poly(z)
|
71
|
+
* where
|
72
|
+
* poly(z) is a 14 degree polynomial.
|
73
|
+
* 2. Rational approximation in the primary interval [2,3]
|
74
|
+
* We use the following approximation:
|
75
|
+
* s = x-2.0;
|
76
|
+
* lgamma(x) = 0.5*s + s*P(s)/Q(s)
|
77
|
+
* with accuracy
|
78
|
+
* |P/Q - (lgamma(x)-0.5s)| < 2**-61.71
|
79
|
+
* Our algorithms are based on the following observation
|
80
|
+
*
|
81
|
+
* zeta(2)-1 2 zeta(3)-1 3
|
82
|
+
* lgamma(2+s) = s*(1-Euler) + --------- * s - --------- * s + ...
|
83
|
+
* 2 3
|
84
|
+
*
|
85
|
+
* where Euler = 0.5771... is the Euler constant, which is very
|
86
|
+
* close to 0.5.
|
87
|
+
*
|
88
|
+
* 3. For x>=8, we have
|
89
|
+
* lgamma(x)~(x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+....
|
90
|
+
* (better formula:
|
91
|
+
* lgamma(x)~(x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...)
|
92
|
+
* Let z = 1/x, then we approximation
|
93
|
+
* f(z) = lgamma(x) - (x-0.5)(log(x)-1)
|
94
|
+
* by
|
95
|
+
* 3 5 11
|
96
|
+
* w = w0 + w1*z + w2*z + w3*z + ... + w6*z
|
97
|
+
* where
|
98
|
+
* |w - f(z)| < 2**-58.74
|
99
|
+
*
|
100
|
+
* 4. For negative x, since (G is gamma function)
|
101
|
+
* -x*G(-x)*G(x) = pi/sin(pi*x),
|
102
|
+
* we have
|
103
|
+
* G(x) = pi/(sin(pi*x)*(-x)*G(-x))
|
104
|
+
* since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0
|
105
|
+
* Hence, for x<0, signgam = sign(sin(pi*x)) and
|
106
|
+
* lgamma(x) = log(|Gamma(x)|)
|
107
|
+
* = log(pi/(|x*sin(pi*x)|)) - lgamma(-x);
|
108
|
+
* Note: one should avoid compute pi*(-x) directly in the
|
109
|
+
* computation of sin(pi*(-x)).
|
110
|
+
*
|
111
|
+
* 5. Special Cases
|
112
|
+
* lgamma(2+s) ~ s*(1-Euler) for tiny s
|
113
|
+
* lgamma(1)=lgamma(2)=0
|
114
|
+
* lgamma(x) ~ -log(x) for tiny x
|
115
|
+
* lgamma(0) = lgamma(inf) = inf
|
116
|
+
* lgamma(-integer) = +-inf
|
117
|
+
*
|
118
|
+
*/
|
119
|
+
|
120
|
+
#include "fdlibm.h"
|
121
|
+
|
122
|
+
#ifdef __STDC__
|
123
|
+
static const double
|
124
|
+
#else
|
125
|
+
static double
|
126
|
+
#endif
|
127
|
+
two52= 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
|
128
|
+
half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
|
129
|
+
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
|
130
|
+
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
|
131
|
+
a0 = 7.72156649015328655494e-02, /* 0x3FB3C467, 0xE37DB0C8 */
|
132
|
+
a1 = 3.22467033424113591611e-01, /* 0x3FD4A34C, 0xC4A60FAD */
|
133
|
+
a2 = 6.73523010531292681824e-02, /* 0x3FB13E00, 0x1A5562A7 */
|
134
|
+
a3 = 2.05808084325167332806e-02, /* 0x3F951322, 0xAC92547B */
|
135
|
+
a4 = 7.38555086081402883957e-03, /* 0x3F7E404F, 0xB68FEFE8 */
|
136
|
+
a5 = 2.89051383673415629091e-03, /* 0x3F67ADD8, 0xCCB7926B */
|
137
|
+
a6 = 1.19270763183362067845e-03, /* 0x3F538A94, 0x116F3F5D */
|
138
|
+
a7 = 5.10069792153511336608e-04, /* 0x3F40B6C6, 0x89B99C00 */
|
139
|
+
a8 = 2.20862790713908385557e-04, /* 0x3F2CF2EC, 0xED10E54D */
|
140
|
+
a9 = 1.08011567247583939954e-04, /* 0x3F1C5088, 0x987DFB07 */
|
141
|
+
a10 = 2.52144565451257326939e-05, /* 0x3EFA7074, 0x428CFA52 */
|
142
|
+
a11 = 4.48640949618915160150e-05, /* 0x3F07858E, 0x90A45837 */
|
143
|
+
tc = 1.46163214496836224576e+00, /* 0x3FF762D8, 0x6356BE3F */
|
144
|
+
tf = -1.21486290535849611461e-01, /* 0xBFBF19B9, 0xBCC38A42 */
|
145
|
+
/* tt = -(tail of tf) */
|
146
|
+
tt = -3.63867699703950536541e-18, /* 0xBC50C7CA, 0xA48A971F */
|
147
|
+
t0 = 4.83836122723810047042e-01, /* 0x3FDEF72B, 0xC8EE38A2 */
|
148
|
+
t1 = -1.47587722994593911752e-01, /* 0xBFC2E427, 0x8DC6C509 */
|
149
|
+
t2 = 6.46249402391333854778e-02, /* 0x3FB08B42, 0x94D5419B */
|
150
|
+
t3 = -3.27885410759859649565e-02, /* 0xBFA0C9A8, 0xDF35B713 */
|
151
|
+
t4 = 1.79706750811820387126e-02, /* 0x3F9266E7, 0x970AF9EC */
|
152
|
+
t5 = -1.03142241298341437450e-02, /* 0xBF851F9F, 0xBA91EC6A */
|
153
|
+
t6 = 6.10053870246291332635e-03, /* 0x3F78FCE0, 0xE370E344 */
|
154
|
+
t7 = -3.68452016781138256760e-03, /* 0xBF6E2EFF, 0xB3E914D7 */
|
155
|
+
t8 = 2.25964780900612472250e-03, /* 0x3F6282D3, 0x2E15C915 */
|
156
|
+
t9 = -1.40346469989232843813e-03, /* 0xBF56FE8E, 0xBF2D1AF1 */
|
157
|
+
t10 = 8.81081882437654011382e-04, /* 0x3F4CDF0C, 0xEF61A8E9 */
|
158
|
+
t11 = -5.38595305356740546715e-04, /* 0xBF41A610, 0x9C73E0EC */
|
159
|
+
t12 = 3.15632070903625950361e-04, /* 0x3F34AF6D, 0x6C0EBBF7 */
|
160
|
+
t13 = -3.12754168375120860518e-04, /* 0xBF347F24, 0xECC38C38 */
|
161
|
+
t14 = 3.35529192635519073543e-04, /* 0x3F35FD3E, 0xE8C2D3F4 */
|
162
|
+
u0 = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */
|
163
|
+
u1 = 6.32827064025093366517e-01, /* 0x3FE4401E, 0x8B005DFF */
|
164
|
+
u2 = 1.45492250137234768737e+00, /* 0x3FF7475C, 0xD119BD6F */
|
165
|
+
u3 = 9.77717527963372745603e-01, /* 0x3FEF4976, 0x44EA8450 */
|
166
|
+
u4 = 2.28963728064692451092e-01, /* 0x3FCD4EAE, 0xF6010924 */
|
167
|
+
u5 = 1.33810918536787660377e-02, /* 0x3F8B678B, 0xBF2BAB09 */
|
168
|
+
v1 = 2.45597793713041134822e+00, /* 0x4003A5D7, 0xC2BD619C */
|
169
|
+
v2 = 2.12848976379893395361e+00, /* 0x40010725, 0xA42B18F5 */
|
170
|
+
v3 = 7.69285150456672783825e-01, /* 0x3FE89DFB, 0xE45050AF */
|
171
|
+
v4 = 1.04222645593369134254e-01, /* 0x3FBAAE55, 0xD6537C88 */
|
172
|
+
v5 = 3.21709242282423911810e-03, /* 0x3F6A5ABB, 0x57D0CF61 */
|
173
|
+
s0 = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */
|
174
|
+
s1 = 2.14982415960608852501e-01, /* 0x3FCB848B, 0x36E20878 */
|
175
|
+
s2 = 3.25778796408930981787e-01, /* 0x3FD4D98F, 0x4F139F59 */
|
176
|
+
s3 = 1.46350472652464452805e-01, /* 0x3FC2BB9C, 0xBEE5F2F7 */
|
177
|
+
s4 = 2.66422703033638609560e-02, /* 0x3F9B481C, 0x7E939961 */
|
178
|
+
s5 = 1.84028451407337715652e-03, /* 0x3F5E26B6, 0x7368F239 */
|
179
|
+
s6 = 3.19475326584100867617e-05, /* 0x3F00BFEC, 0xDD17E945 */
|
180
|
+
r1 = 1.39200533467621045958e+00, /* 0x3FF645A7, 0x62C4AB74 */
|
181
|
+
r2 = 7.21935547567138069525e-01, /* 0x3FE71A18, 0x93D3DCDC */
|
182
|
+
r3 = 1.71933865632803078993e-01, /* 0x3FC601ED, 0xCCFBDF27 */
|
183
|
+
r4 = 1.86459191715652901344e-02, /* 0x3F9317EA, 0x742ED475 */
|
184
|
+
r5 = 7.77942496381893596434e-04, /* 0x3F497DDA, 0xCA41A95B */
|
185
|
+
r6 = 7.32668430744625636189e-06, /* 0x3EDEBAF7, 0xA5B38140 */
|
186
|
+
w0 = 4.18938533204672725052e-01, /* 0x3FDACFE3, 0x90C97D69 */
|
187
|
+
w1 = 8.33333333333329678849e-02, /* 0x3FB55555, 0x5555553B */
|
188
|
+
w2 = -2.77777777728775536470e-03, /* 0xBF66C16C, 0x16B02E5C */
|
189
|
+
w3 = 7.93650558643019558500e-04, /* 0x3F4A019F, 0x98CF38B6 */
|
190
|
+
w4 = -5.95187557450339963135e-04, /* 0xBF4380CB, 0x8C0FE741 */
|
191
|
+
w5 = 8.36339918996282139126e-04, /* 0x3F4B67BA, 0x4CDAD5D1 */
|
192
|
+
w6 = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */
|
193
|
+
|
194
|
+
static double zero= 0.00000000000000000000e+00;
|
195
|
+
|
196
|
+
#ifdef __STDC__
|
197
|
+
static double sin_pi(double x)
|
198
|
+
#else
|
199
|
+
static double sin_pi(x)
|
200
|
+
double x;
|
201
|
+
#endif
|
202
|
+
{
|
203
|
+
fd_twoints u;
|
204
|
+
double y,z;
|
205
|
+
int n,ix;
|
206
|
+
|
207
|
+
u.d = x;
|
208
|
+
ix = 0x7fffffff&__HI(u);
|
209
|
+
|
210
|
+
if(ix<0x3fd00000) return __kernel_sin(pi*x,zero,0);
|
211
|
+
y = -x; /* x is assume negative */
|
212
|
+
|
213
|
+
/*
|
214
|
+
* argument reduction, make sure inexact flag not raised if input
|
215
|
+
* is an integer
|
216
|
+
*/
|
217
|
+
z = fd_floor(y);
|
218
|
+
if(z!=y) { /* inexact anyway */
|
219
|
+
y *= 0.5;
|
220
|
+
y = 2.0*(y - fd_floor(y)); /* y = |x| mod 2.0 */
|
221
|
+
n = (int) (y*4.0);
|
222
|
+
} else {
|
223
|
+
if(ix>=0x43400000) {
|
224
|
+
y = zero; n = 0; /* y must be even */
|
225
|
+
} else {
|
226
|
+
if(ix<0x43300000) z = y+two52; /* exact */
|
227
|
+
u.d = z;
|
228
|
+
n = __LO(u)&1; /* lower word of z */
|
229
|
+
y = n;
|
230
|
+
n<<= 2;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
switch (n) {
|
234
|
+
case 0: y = __kernel_sin(pi*y,zero,0); break;
|
235
|
+
case 1:
|
236
|
+
case 2: y = __kernel_cos(pi*(0.5-y),zero); break;
|
237
|
+
case 3:
|
238
|
+
case 4: y = __kernel_sin(pi*(one-y),zero,0); break;
|
239
|
+
case 5:
|
240
|
+
case 6: y = -__kernel_cos(pi*(y-1.5),zero); break;
|
241
|
+
default: y = __kernel_sin(pi*(y-2.0),zero,0); break;
|
242
|
+
}
|
243
|
+
return -y;
|
244
|
+
}
|
245
|
+
|
246
|
+
|
247
|
+
#ifdef __STDC__
|
248
|
+
double __ieee754_lgamma_r(double x, int *signgamp)
|
249
|
+
#else
|
250
|
+
double __ieee754_lgamma_r(x,signgamp)
|
251
|
+
double x; int *signgamp;
|
252
|
+
#endif
|
253
|
+
{
|
254
|
+
fd_twoints u;
|
255
|
+
double t,y,z,nadj,p,p1,p2,p3,q,r,w;
|
256
|
+
int i,hx,lx,ix;
|
257
|
+
|
258
|
+
u.d = x;
|
259
|
+
hx = __HI(u);
|
260
|
+
lx = __LO(u);
|
261
|
+
|
262
|
+
/* purge off +-inf, NaN, +-0, and negative arguments */
|
263
|
+
*signgamp = 1;
|
264
|
+
ix = hx&0x7fffffff;
|
265
|
+
if(ix>=0x7ff00000) return x*x;
|
266
|
+
if((ix|lx)==0) return one/zero;
|
267
|
+
if(ix<0x3b900000) { /* |x|<2**-70, return -log(|x|) */
|
268
|
+
if(hx<0) {
|
269
|
+
*signgamp = -1;
|
270
|
+
return -__ieee754_log(-x);
|
271
|
+
} else return -__ieee754_log(x);
|
272
|
+
}
|
273
|
+
if(hx<0) {
|
274
|
+
if(ix>=0x43300000) /* |x|>=2**52, must be -integer */
|
275
|
+
return one/zero;
|
276
|
+
t = sin_pi(x);
|
277
|
+
if(t==zero) return one/zero; /* -integer */
|
278
|
+
nadj = __ieee754_log(pi/fd_fabs(t*x));
|
279
|
+
if(t<zero) *signgamp = -1;
|
280
|
+
x = -x;
|
281
|
+
}
|
282
|
+
|
283
|
+
/* purge off 1 and 2 */
|
284
|
+
if((((ix-0x3ff00000)|lx)==0)||(((ix-0x40000000)|lx)==0)) r = 0;
|
285
|
+
/* for x < 2.0 */
|
286
|
+
else if(ix<0x40000000) {
|
287
|
+
if(ix<=0x3feccccc) { /* lgamma(x) = lgamma(x+1)-log(x) */
|
288
|
+
r = -__ieee754_log(x);
|
289
|
+
if(ix>=0x3FE76944) {y = one-x; i= 0;}
|
290
|
+
else if(ix>=0x3FCDA661) {y= x-(tc-one); i=1;}
|
291
|
+
else {y = x; i=2;}
|
292
|
+
} else {
|
293
|
+
r = zero;
|
294
|
+
if(ix>=0x3FFBB4C3) {y=2.0-x;i=0;} /* [1.7316,2] */
|
295
|
+
else if(ix>=0x3FF3B4C4) {y=x-tc;i=1;} /* [1.23,1.73] */
|
296
|
+
else {y=x-one;i=2;}
|
297
|
+
}
|
298
|
+
switch(i) {
|
299
|
+
case 0:
|
300
|
+
z = y*y;
|
301
|
+
p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
|
302
|
+
p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
|
303
|
+
p = y*p1+p2;
|
304
|
+
r += (p-0.5*y); break;
|
305
|
+
case 1:
|
306
|
+
z = y*y;
|
307
|
+
w = z*y;
|
308
|
+
p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */
|
309
|
+
p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
|
310
|
+
p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
|
311
|
+
p = z*p1-(tt-w*(p2+y*p3));
|
312
|
+
r += (tf + p); break;
|
313
|
+
case 2:
|
314
|
+
p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
|
315
|
+
p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
|
316
|
+
r += (-0.5*y + p1/p2);
|
317
|
+
}
|
318
|
+
}
|
319
|
+
else if(ix<0x40200000) { /* x < 8.0 */
|
320
|
+
i = (int)x;
|
321
|
+
t = zero;
|
322
|
+
y = x-(double)i;
|
323
|
+
p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
|
324
|
+
q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
|
325
|
+
r = half*y+p/q;
|
326
|
+
z = one; /* lgamma(1+s) = log(s) + lgamma(s) */
|
327
|
+
switch(i) {
|
328
|
+
case 7: z *= (y+6.0); /* FALLTHRU */
|
329
|
+
case 6: z *= (y+5.0); /* FALLTHRU */
|
330
|
+
case 5: z *= (y+4.0); /* FALLTHRU */
|
331
|
+
case 4: z *= (y+3.0); /* FALLTHRU */
|
332
|
+
case 3: z *= (y+2.0); /* FALLTHRU */
|
333
|
+
r += __ieee754_log(z); break;
|
334
|
+
}
|
335
|
+
/* 8.0 <= x < 2**58 */
|
336
|
+
} else if (ix < 0x43900000) {
|
337
|
+
t = __ieee754_log(x);
|
338
|
+
z = one/x;
|
339
|
+
y = z*z;
|
340
|
+
w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
|
341
|
+
r = (x-half)*(t-one)+w;
|
342
|
+
} else
|
343
|
+
/* 2**58 <= x <= inf */
|
344
|
+
r = x*(__ieee754_log(x)-one);
|
345
|
+
if(hx<0) r = nadj - r;
|
346
|
+
return r;
|
347
|
+
}
|