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

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [newlib/] [libm/] [math/] [w_j0.c] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
 
2
/* @(#)w_j0.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
@ifinfo
95
.  2               2    2
96
. x  y'' + xy' + (x  - p )y  = 0
97
@end ifinfo
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 j0(double x), y0(double x)
123
 */
124
 
125
#include "fdlibm.h"
126
#include <errno.h>
127
 
128
#ifndef _DOUBLE_IS_32BITS
129
 
130
#ifdef __STDC__
131
        double j0(double x)             /* wrapper j0 */
132
#else
133
        double j0(x)                    /* wrapper j0 */
134
        double x;
135
#endif
136
{
137
#ifdef _IEEE_LIBM
138
        return __ieee754_j0(x);
139
#else
140
        struct exception exc;
141
        double z = __ieee754_j0(x);
142
        if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
143
        if(fabs(x)>X_TLOSS) {
144
            /* j0(|x|>X_TLOSS) */
145
            exc.type = TLOSS;
146
            exc.name = "j0";
147
            exc.retval = 0.0;
148
            if (_LIB_VERSION == _POSIX_)
149
               errno = ERANGE;
150
            else if (!matherr(&exc)) {
151
               errno = ERANGE;
152
            }
153
            if (exc.err != 0)
154
               errno = exc.err;
155
            return exc.retval;
156
        } else
157
            return z;
158
#endif
159
}
160
 
161
#ifdef __STDC__
162
        double y0(double x)             /* wrapper y0 */
163
#else
164
        double y0(x)                    /* wrapper y0 */
165
        double x;
166
#endif
167
{
168
#ifdef _IEEE_LIBM
169
        return __ieee754_y0(x);
170
#else
171
        double z;
172
        struct exception exc;
173
        z = __ieee754_y0(x);
174
        if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
175
        if(x <= 0.0){
176
#ifndef HUGE_VAL 
177
#define HUGE_VAL inf
178
            double inf = 0.0;
179
 
180
            SET_HIGH_WORD(inf,0x7ff00000);      /* set inf to infinite */
181
#endif
182
            /* y0(0) = -inf or y0(x<0) = NaN */
183
            exc.type = DOMAIN;  /* should be SING for IEEE y0(0) */
184
            exc.name = "y0";
185
            if (_LIB_VERSION == _SVID_)
186
               exc.retval = -HUGE;
187
            else
188
               exc.retval = -HUGE_VAL;
189
            if (_LIB_VERSION == _POSIX_)
190
               errno = EDOM;
191
            else if (!matherr(&exc)) {
192
               errno = EDOM;
193
            }
194
            if (exc.err != 0)
195
               errno = exc.err;
196
            return exc.retval;
197
        }
198
        if(x>X_TLOSS) {
199
            /* y0(x>X_TLOSS) */
200
            exc.type = TLOSS;
201
            exc.name = "y0";
202
            exc.retval = 0.0;
203
            if (_LIB_VERSION == _POSIX_)
204
               errno = ERANGE;
205
            else if (!matherr(&exc)) {
206
               errno = ERANGE;
207
            }
208
            if (exc.err != 0)
209
               errno = exc.err;
210
            return exc.retval;
211
        } else
212
            return z;
213
#endif
214
}
215
 
216
#endif /* defined(_DOUBLE_IS_32BITS) */
217
 
218
 
219
 
220
 
221
 
222
 
223
 

powered by: WebSVN 2.1.0

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