Annotation of coherent/b/lib/libm/jn.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Evaluate the Bessel function of the first kind for the
        !             3:  * n'th order.
        !             4:  */
        !             5: #include <math.h>
        !             6: 
        !             7: double
        !             8: jn(n, x)
        !             9: register int n;
        !            10: double x;
        !            11: {
        !            12:        double r, ja, jb;
        !            13:        register int m, i;
        !            14: 
        !            15:        if (x == 0.0)
        !            16:                return (0.0);
        !            17:        m = 0;
        !            18:        if (x < 0.0) {
        !            19:                x = -x;
        !            20:                m = 1;
        !            21:        }
        !            22:        if (n < 0) {
        !            23:                n = -n;
        !            24:                if (n&1)
        !            25:                        m ^= 1;
        !            26:        }
        !            27:        switch (n) {
        !            28:        case 0:
        !            29:                r = j0(x);
        !            30:                break;
        !            31:        case 1:
        !            32:                r = j1(x);
        !            33:                break;
        !            34:        default:
        !            35:                jb = j0(x);
        !            36:                ja = j1(x);
        !            37:                for (i=1; i<n; i++) {
        !            38:                        r = (2.0*i/x)*ja - jb;
        !            39:                        jb = ja;
        !            40:                        ja = r;
        !            41:                }
        !            42:                break;
        !            43:        }
        !            44:        if (m)
        !            45:                r = -r;
        !            46:        return (r);
        !            47: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.