OSDN Git Service

Add MS7619SE
[uclinux-h8/uClinux-dist.git] / lib / libm / i0f.c
1 /*                                                      i0f.c
2  *
3  *      Modified Bessel function of order zero
4  *
5  *
6  *
7  * SYNOPSIS:
8  *
9  * float x, y, i0();
10  *
11  * y = i0f( x );
12  *
13  *
14  *
15  * DESCRIPTION:
16  *
17  * Returns modified Bessel function of order zero of the
18  * argument.
19  *
20  * The function is defined as i0(x) = j0( ix ).
21  *
22  * The range is partitioned into the two intervals [0,8] and
23  * (8, infinity).  Chebyshev polynomial expansions are employed
24  * in each interval.
25  *
26  *
27  *
28  * ACCURACY:
29  *
30  *                      Relative error:
31  * arithmetic   domain     # trials      peak         rms
32  *    IEEE      0,30        100000      4.0e-7      7.9e-8
33  *
34  */
35 \f/*                                                     i0ef.c
36  *
37  *      Modified Bessel function of order zero,
38  *      exponentially scaled
39  *
40  *
41  *
42  * SYNOPSIS:
43  *
44  * float x, y, i0ef();
45  *
46  * y = i0ef( x );
47  *
48  *
49  *
50  * DESCRIPTION:
51  *
52  * Returns exponentially scaled modified Bessel function
53  * of order zero of the argument.
54  *
55  * The function is defined as i0e(x) = exp(-|x|) j0( ix ).
56  *
57  *
58  *
59  * ACCURACY:
60  *
61  *                      Relative error:
62  * arithmetic   domain     # trials      peak         rms
63  *    IEEE      0,30        100000      3.7e-7      7.0e-8
64  * See i0f().
65  *
66  */
67 \f
68 /*                                                      i0.c            */
69
70
71 /*
72 Cephes Math Library Release 2.2:  June, 1992
73 Copyright 1984, 1987, 1992 by Stephen L. Moshier
74 Direct inquiries to 30 Frost Street, Cambridge, MA 02140
75 */
76
77 #include "mconf.h"
78
79 /* Chebyshev coefficients for exp(-x) I0(x)
80  * in the interval [0,8].
81  *
82  * lim(x->0){ exp(-x) I0(x) } = 1.
83  */
84
85 static float A[] =
86 {
87 -1.30002500998624804212E-8f,
88  6.04699502254191894932E-8f,
89 -2.67079385394061173391E-7f,
90  1.11738753912010371815E-6f,
91 -4.41673835845875056359E-6f,
92  1.64484480707288970893E-5f,
93 -5.75419501008210370398E-5f,
94  1.88502885095841655729E-4f,
95 -5.76375574538582365885E-4f,
96  1.63947561694133579842E-3f,
97 -4.32430999505057594430E-3f,
98  1.05464603945949983183E-2f,
99 -2.37374148058994688156E-2f,
100  4.93052842396707084878E-2f,
101 -9.49010970480476444210E-2f,
102  1.71620901522208775349E-1f,
103 -3.04682672343198398683E-1f,
104  6.76795274409476084995E-1f
105 };
106
107
108 /* Chebyshev coefficients for exp(-x) sqrt(x) I0(x)
109  * in the inverted interval [8,infinity].
110  *
111  * lim(x->inf){ exp(-x) sqrt(x) I0(x) } = 1/sqrt(2pi).
112  */
113
114 static float B[] =
115 {
116  3.39623202570838634515E-9f,
117  2.26666899049817806459E-8f,
118  2.04891858946906374183E-7f,
119  2.89137052083475648297E-6f,
120  6.88975834691682398426E-5f,
121  3.36911647825569408990E-3f,
122  8.04490411014108831608E-1f
123 };
124
125  
126 #ifdef ANSIC
127 float chbevlf(float, float *, int), expf(float), sqrtf(float);
128
129 float i0f( float x )
130 #else
131 float chbevlf(), expf(), sqrtf();
132
133 float i0f(x)
134 double x;
135 #endif
136 {
137 float y;
138
139 if( x < 0 )
140         x = -x;
141 if( x <= 8.0f )
142         {
143         y = 0.5f*x - 2.0f;
144         return( expf(x) * chbevlf( y, A, 18 ) );
145         }
146
147 return(  expf(x) * chbevlf( 32.0f/x - 2.0f, B, 7 ) / sqrtf(x) );
148 }
149
150
151
152 #ifdef ANSIC
153 float chbevlf(float, float *, int), expf(float), sqrtf(float);
154
155 float i0ef( float x )
156 #else
157 float chbevlf(), expf(), sqrtf();
158
159 float i0ef( x )
160 double x;
161 #endif
162 {
163 float y;
164
165 if( x < 0 )
166         x = -x;
167 if( x <= 8.0f )
168         {
169         y = 0.5f*x - 2.0f;
170         return( chbevlf( y, A, 18 ) );
171         }
172
173 return(  chbevlf( 32.0f/x - 2.0f, B, 7 ) / sqrtf(x) );
174 }