DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦e3a3a1e63⟧ TextFile

    Length: 545 (0x221)
    Types: TextFile
    Notes: UNIX file
    Names: »jn.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »libm/jn.c« 

TextFile

/*
 * 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);
}