|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 545 (0x221)
Types: TextFile
Notes: UNIX file
Names: »jn.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦f4b8d8c84⟧ UNIX Filesystem
└─⟦this⟧ »libm/jn.c«
/*
* Evaluate the Bessel function of the first kind for the
* n'th order.
*/
#include <math.h>
double
jn(n, x)
register int n;
double x;
{
double r, ja, jb;
register int m, i;
if (x == 0.0)
return (0.0);
m = 0;
if (x < 0.0) {
x = -x;
m = 1;
}
if (n < 0) {
n = -n;
if (n&1)
m ^= 1;
}
switch (n) {
case 0:
r = j0(x);
break;
case 1:
r = j1(x);
break;
default:
jb = j0(x);
ja = j1(x);
for (i=1; i<n; i++) {
r = (2.0*i/x)*ja - jb;
jb = ja;
ja = r;
}
break;
}
if (m)
r = -r;
return (r);
}