OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libm/] [mathfp/] [w_jn.c] - Blame information for rev 829

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
 
2
/* @(#)w_jn.c 5.1 93/09/24 */
3
/*
4
 * ====================================================
5
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6
 *
7
 * Developed at SunPro, a Sun Microsystems, Inc. business.
8
 * Permission to use, copy, modify, and distribute this
9
 * software is freely granted, provided that this notice
10
 * is preserved.
11
 * ====================================================
12
 */
13
 
14
/*
15
FUNCTION
16
<<jN>>, <<jNf>>, <<yN>>, <<yNf>>---Bessel functions
17
 
18
INDEX
19
j0
20
INDEX
21
j0f
22
INDEX
23
j1
24
INDEX
25
j1f
26
INDEX
27
jn
28
INDEX
29
jnf
30
INDEX
31
y0
32
INDEX
33
y0f
34
INDEX
35
y1
36
INDEX
37
y1f
38
INDEX
39
yn
40
INDEX
41
ynf
42
 
43
ANSI_SYNOPSIS
44
#include <math.h>
45
double j0(double <[x]>);
46
float j0f(float <[x]>);
47
double j1(double <[x]>);
48
float j1f(float <[x]>);
49
double jn(int <[n]>, double <[x]>);
50
float jnf(int <[n]>, float <[x]>);
51
double y0(double <[x]>);
52
float y0f(float <[x]>);
53
double y1(double <[x]>);
54
float y1f(float <[x]>);
55
double yn(int <[n]>, double <[x]>);
56
float ynf(int <[n]>, float <[x]>);
57
 
58
TRAD_SYNOPSIS
59
#include <math.h>
60
 
61
double j0(<[x]>)
62
double <[x]>;
63
float j0f(<[x]>)
64
float <[x]>;
65
double j1(<[x]>)
66
double <[x]>;
67
float j1f(<[x]>)
68
float <[x]>;
69
double jn(<[n]>, <[x]>)
70
int <[n]>;
71
double <[x]>;
72
float jnf(<[n]>, <[x]>)
73
int <[n]>;
74
float <[x]>;
75
 
76
double y0(<[x]>)
77
double <[x]>;
78
float y0f(<[x]>)
79
float <[x]>;
80
double y1(<[x]>)
81
double <[x]>;
82
float y1f(<[x]>)
83
float <[x]>;
84
double yn(<[n]>, <[x]>)
85
int <[n]>;
86
double <[x]>;
87
float ynf(<[n]>, <[x]>)
88
int <[n]>;
89
float <[x]>;
90
 
91
DESCRIPTION
92
The Bessel functions are a family of functions that solve the
93
differential equation
94
@ifnottex
95
.  2               2    2
96
. x  y'' + xy' + (x  - p )y  = 0
97
@end ifnottex
98
@tex
99
$$x^2{d^2y\over dx^2} + x{dy\over dx} + (x^2-p^2)y = 0$$
100
@end tex
101
These functions have many applications in engineering and physics.
102
 
103
<<jn>> calculates the Bessel function of the first kind of order
104
<[n]>.  <<j0>> and <<j1>> are special cases for order 0 and order
105
1 respectively.
106
 
107
Similarly, <<yn>> calculates the Bessel function of the second kind of
108
order <[n]>, and <<y0>> and <<y1>> are special cases for order 0 and
109
1.
110
 
111
<<jnf>>, <<j0f>>, <<j1f>>, <<ynf>>, <<y0f>>, and <<y1f>> perform the
112
same calculations, but on <<float>> rather than <<double>> values.
113
 
114
RETURNS
115
The value of each Bessel function at <[x]> is returned.
116
 
117
PORTABILITY
118
None of the Bessel functions are in ANSI C.
119
*/
120
 
121
/*
122
 * wrapper jn(int n, double x), yn(int n, double x)
123
 * floating point Bessel's function of the 1st and 2nd kind
124
 * of order n
125
 *
126
 * Special cases:
127
 *      y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal;
128
 *      y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal.
129
 * Note 2. About jn(n,x), yn(n,x)
130
 *      For n=0, j0(x) is called,
131
 *      for n=1, j1(x) is called,
132
 *      for n<x, forward recursion us used starting
133
 *      from values of j0(x) and j1(x).
134
 *      for n>x, a continued fraction approximation to
135
 *      j(n,x)/j(n-1,x) is evaluated and then backward
136
 *      recursion is used starting from a supposed value
137
 *      for j(n,x). The resulting value of j(0,x) is
138
 *      compared with the actual value to correct the
139
 *      supposed value of j(n,x).
140
 *
141
 *      yn(n,x) is similar in all respects, except
142
 *      that forward recursion is used for all
143
 *      values of n>1.
144
 *
145
 */
146
 
147
#include "fdlibm.h"
148
#include <errno.h>
149
 
150
#ifndef _DOUBLE_IS_32BITS
151
 
152
#ifdef __STDC__
153
        double jn(int n, double x)      /* wrapper jn */
154
#else
155
        double jn(n,x)                  /* wrapper jn */
156
        double x; int n;
157
#endif
158
{
159
#ifdef _IEEE_LIBM
160
        return jn(n,x);
161
#else
162
        double z;
163
        struct exception exc;
164
        z = jn(n,x);
165
        if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
166
        if(fabs(x)>X_TLOSS) {
167
            /* jn(|x|>X_TLOSS) */
168
            exc.type = TLOSS;
169
            exc.name = "jn";
170
            exc.err = 0;
171
            exc.arg1 = n;
172
            exc.arg2 = x;
173
            exc.retval = 0.0;
174
            if (_LIB_VERSION == _POSIX_)
175
                errno = ERANGE;
176
            else if (!matherr(&exc)) {
177
               errno = ERANGE;
178
            }
179
            if (exc.err != 0)
180
               errno = exc.err;
181
            return exc.retval;
182
        } else
183
            return z;
184
#endif
185
}
186
 
187
#ifdef __STDC__
188
        double yn(int n, double x)      /* wrapper yn */
189
#else
190
        double yn(n,x)                  /* wrapper yn */
191
        double x; int n;
192
#endif
193
{
194
#ifdef _IEEE_LIBM
195
        return yn(n,x);
196
#else
197
        double z;
198
        struct exception exc;
199
        z = yn(n,x);
200
        if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
201
        if(x <= 0.0){
202
            /* yn(n,0) = -inf or yn(x<0) = NaN */
203
#ifndef HUGE_VAL 
204
#define HUGE_VAL inf
205
            double inf = 0.0;
206
 
207
            SET_HIGH_WORD(inf,0x7ff00000);      /* set inf to infinite */
208
#endif
209
            exc.type = DOMAIN;  /* should be SING for IEEE */
210
            exc.name = "yn";
211
            exc.err = 0;
212
            exc.arg1 = n;
213
            exc.arg2 = x;
214
            if (_LIB_VERSION == _SVID_)
215
                exc.retval = -HUGE;
216
            else
217
                exc.retval = -HUGE_VAL;
218
            if (_LIB_VERSION == _POSIX_)
219
                errno = EDOM;
220
            else if (!matherr(&exc)) {
221
                errno = EDOM;
222
            }
223
            if (exc.err != 0)
224
               errno = exc.err;
225
            return exc.retval;
226
        }
227
        if(x>X_TLOSS) {
228
            /* yn(x>X_TLOSS) */
229
            exc.type = TLOSS;
230
            exc.name = "yn";
231
            exc.err = 0;
232
            exc.arg1 = n;
233
            exc.arg2 = x;
234
            exc.retval = 0.0;
235
            if (_LIB_VERSION == _POSIX_)
236
                errno = ERANGE;
237
            else if (!matherr(&exc)) {
238
                errno = ERANGE;
239
            }
240
            if (exc.err != 0)
241
               errno = exc.err;
242
            return exc.retval;
243
        } else
244
            return z;
245
#endif
246
}
247
 
248
#endif /* defined(_DOUBLE_IS_32BITS) */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.