summaryrefslogtreecommitdiff
path: root/libm/float/jnf.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-11-22 14:04:29 +0000
committerEric Andersen <andersen@codepoet.org>2001-11-22 14:04:29 +0000
commit7ce331c01ce6eb7b3f5c715a38a24359da9c6ee2 (patch)
tree3a7e8476e868ae15f4da1b7ce26b2db6f434468c /libm/float/jnf.c
parentc117dd5fb183afb1a4790a6f6110d88704be6bf8 (diff)
Totally rework the math library, this time based on the MacOs X
math library (which is itself based on the math lib from FreeBSD). -Erik
Diffstat (limited to 'libm/float/jnf.c')
-rw-r--r--libm/float/jnf.c124
1 files changed, 0 insertions, 124 deletions
diff --git a/libm/float/jnf.c b/libm/float/jnf.c
deleted file mode 100644
index de358e0ef..000000000
--- a/libm/float/jnf.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* jnf.c
- *
- * Bessel function of integer order
- *
- *
- *
- * SYNOPSIS:
- *
- * int n;
- * float x, y, jnf();
- *
- * y = jnf( n, x );
- *
- *
- *
- * DESCRIPTION:
- *
- * Returns Bessel function of order n, where n is a
- * (possibly negative) integer.
- *
- * The ratio of jn(x) to j0(x) is computed by backward
- * recurrence. First the ratio jn/jn-1 is found by a
- * continued fraction expansion. Then the recurrence
- * relating successive orders is applied until j0 or j1 is
- * reached.
- *
- * If n = 0 or 1 the routine for j0 or j1 is called
- * directly.
- *
- *
- *
- * ACCURACY:
- *
- * Absolute error:
- * arithmetic range # trials peak rms
- * IEEE 0, 15 30000 3.6e-7 3.6e-8
- *
- *
- * Not suitable for large n or x. Use jvf() instead.
- *
- */
-
-/* jn.c
-Cephes Math Library Release 2.2: June, 1992
-Copyright 1984, 1987, 1992 by Stephen L. Moshier
-Direct inquiries to 30 Frost Street, Cambridge, MA 02140
-*/
-#include <math.h>
-
-extern float MACHEPF;
-
-float j0f(float), j1f(float);
-
-float jnf( int n, float xx )
-{
-float x, pkm2, pkm1, pk, xk, r, ans, xinv, sign;
-int k;
-
-x = xx;
-sign = 1.0;
-if( n < 0 )
- {
- n = -n;
- if( (n & 1) != 0 ) /* -1**n */
- sign = -1.0;
- }
-
-if( n == 0 )
- return( sign * j0f(x) );
-if( n == 1 )
- return( sign * j1f(x) );
-if( n == 2 )
- return( sign * (2.0 * j1f(x) / x - j0f(x)) );
-
-/*
-if( x < MACHEPF )
- return( 0.0 );
-*/
-
-/* continued fraction */
-k = 24;
-pk = 2 * (n + k);
-ans = pk;
-xk = x * x;
-
-do
- {
- pk -= 2.0;
- ans = pk - (xk/ans);
- }
-while( --k > 0 );
-/*ans = x/ans;*/
-
-/* backward recurrence */
-
-pk = 1.0;
-/*pkm1 = 1.0/ans;*/
-xinv = 1.0/x;
-pkm1 = ans * xinv;
-k = n-1;
-r = (float )(2 * k);
-
-do
- {
- pkm2 = (pkm1 * r - pk * x) * xinv;
- pk = pkm1;
- pkm1 = pkm2;
- r -= 2.0;
- }
-while( --k > 0 );
-
-r = pk;
-if( r < 0 )
- r = -r;
-ans = pkm1;
-if( ans < 0 )
- ans = -ans;
-
-if( r > ans ) /* if( fabs(pk) > fabs(pkm1) ) */
- ans = sign * j1f(x)/pk;
-else
- ans = sign * j0f(x)/pkm1;
-return( ans );
-}