Back to index

glibc  2.9
w_jnl.c
Go to the documentation of this file.
00001 /* w_jnl.c -- long double version of w_jn.c.
00002  * Conversion to long double by Ulrich Drepper,
00003  * Cygnus Support, drepper@cygnus.com.
00004  */
00005 
00006 /*
00007  * ====================================================
00008  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00009  *
00010  * Developed at SunPro, a Sun Microsystems, Inc. business.
00011  * Permission to use, copy, modify, and distribute this
00012  * software is freely granted, provided that this notice
00013  * is preserved.
00014  * ====================================================
00015  */
00016 
00017 #if defined(LIBM_SCCS) && !defined(lint)
00018 static char rcsid[] = "$NetBSD: $";
00019 #endif
00020 
00021 /*
00022  * wrapper jn(int n, double x), yn(int n, double x)
00023  * floating point Bessel's function of the 1st and 2nd kind
00024  * of order n
00025  *
00026  * Special cases:
00027  *     y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal;
00028  *     y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal.
00029  * Note 2. About jn(n,x), yn(n,x)
00030  *     For n=0, j0(x) is called,
00031  *     for n=1, j1(x) is called,
00032  *     for n<x, forward recursion us used starting
00033  *     from values of j0(x) and j1(x).
00034  *     for n>x, a continued fraction approximation to
00035  *     j(n,x)/j(n-1,x) is evaluated and then backward
00036  *     recursion is used starting from a supposed value
00037  *     for j(n,x). The resulting value of j(0,x) is
00038  *     compared with the actual value to correct the
00039  *     supposed value of j(n,x).
00040  *
00041  *     yn(n,x) is similar in all respects, except
00042  *     that forward recursion is used for all
00043  *     values of n>1.
00044  *
00045  */
00046 
00047 #include <math.h>
00048 #include "math_private.h"
00049 
00050 #ifdef __STDC__
00051        long double __jnl(int n, long double x)   /* wrapper jnl */
00052 #else
00053        long double __jnl(n,x)                    /* wrapper jnl */
00054        long double x; int n;
00055 #endif
00056 {
00057 #ifdef _IEEE_LIBM
00058        return __ieee754_jnl(n,x);
00059 #else
00060        long double z;
00061        z = __ieee754_jnl(n,x);
00062        if(_LIB_VERSION == _IEEE_ || __isnanl(x) ) return z;
00063        if(fabsl(x)>X_TLOSS) {
00064            return __kernel_standard((double)n,x,238); /* jn(|x|>X_TLOSS,n) */
00065        } else
00066            return z;
00067 #endif
00068 }
00069 weak_alias (__jnl, jnl)
00070 
00071 #ifdef __STDC__
00072        long double __ynl(int n, long double x)   /* wrapper ynl */
00073 #else
00074        long double __ynl(n,x)                    /* wrapper ynl */
00075        long double x; int n;
00076 #endif
00077 {
00078 #ifdef _IEEE_LIBM
00079        return __ieee754_ynl(n,x);
00080 #else
00081        long double z;
00082        z = __ieee754_ynl(n,x);
00083        if(_LIB_VERSION == _IEEE_ || __isnanl(x) ) return z;
00084         if(x <= 0.0){
00085                 if(x==0.0)
00086                     /* d= -one/(x-x); */
00087                     return __kernel_standard((double)n,x,212);
00088                 else
00089                     /* d = zero/(x-x); */
00090                     return __kernel_standard((double)n,x,213);
00091         }
00092        if(x>X_TLOSS) {
00093            return __kernel_standard((double)n,x,239); /* yn(x>X_TLOSS,n) */
00094        } else
00095            return z;
00096 #endif
00097 }
00098 weak_alias (__ynl, ynl)