@@ -67,7 +67,6 @@ static const double x22 = -6.4592058648672279948e-06;
6767* @param x value at which to evaluate the rational function
6868* @return evaluated rational function
6969*/
70-
7170static double rational_p1q1 ( const double x ) {
7271 double ax ;
7372 double ix ;
@@ -87,7 +86,7 @@ static double rational_p1q1( const double x ) {
8786 } else {
8887 ix = 1.0 / x ;
8988 s1 = -317.1442466004613 + (ix * (221579.5322228026 + (ix * (-59157479.9974084 + (ix * (7214454821.450256 + (ix * (-375959744978.196 + (ix * (5470861171652.543 + (ix * 40535726612579.55 )))))))))));
90- s2 = 1.0 + (x * (820.7990816839387 + (x * (381364.70753052575 + (x * (122504351.22182964 + (x * (27800352738.690586 + (x * (4127228620040.646 + (x * 307378739210792.9 )))))))))));
89+ s2 = 1.0 + (ix * (820.7990816839387 + (ix * (381364.70753052575 + (ix * (122504351.22182964 + (ix * (27800352738.690586 + (ix * (4127228620040.646 + (ix * 307378739210792.9 )))))))))));
9190 }
9291 return s1 / s2 ;
9392}
@@ -97,7 +96,7 @@ static double rational_p1q1( const double x ) {
9796// BEGIN: rational_p2q2
9897
9998/**
100- * Evaluates a rational function, i.e., the ratio of two polynomials described by the coefficients stored in \\(P\\) and \\(Q\\).
99+ * Evaluates a rational function ( i.e., the ratio of two polynomials described by the coefficients stored in \\(P\\) and \\(Q\\) ).
101100*
102101* ## Notes
103102*
@@ -106,9 +105,8 @@ static double rational_p1q1( const double x ) {
106105*
107106* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method
108107*
109- * @private
110- * @param {number} x - value at which to evaluate the rational function
111- * @returns {number} evaluated rational function
108+ * @param x value at which to evaluate the rational function
109+ * @return evaluated rational function
112110*/
113111static double rational_p2q2 ( const double x ) {
114112 double ax ;
@@ -139,7 +137,7 @@ static double rational_p2q2( const double x ) {
139137// BEGIN: rational_pcqc
140138
141139/**
142- * Evaluates a rational function, i.e., the ratio of two polynomials described by the coefficients stored in \\(P\\) and \\(Q\\).
140+ * Evaluates a rational function ( i.e., the ratio of two polynomials described by the coefficients stored in \\(P\\) and \\(Q\\) ).
143141*
144142* ## Notes
145143*
@@ -148,9 +146,8 @@ static double rational_p2q2( const double x ) {
148146*
149147* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method
150148*
151- * @private
152- * @param {number} x - value at which to evaluate the rational function
153- * @returns {number} evaluated rational function
149+ * @param x value at which to evaluate the rational function
150+ * @return evaluated rational function
154151*/
155152static double rational_pcqc ( const double x ) {
156153 double ax ;
@@ -181,7 +178,7 @@ static double rational_pcqc( const double x ) {
181178// BEGIN: rational_psqs
182179
183180/**
184- * Evaluates a rational function, i.e., the ratio of two polynomials described by the coefficients stored in \\(P\\) and \\(Q\\).
181+ * Evaluates a rational function ( i.e., the ratio of two polynomials described by the coefficients stored in \\(P\\) and \\(Q\\) ).
185182*
186183* ## Notes
187184*
@@ -190,9 +187,8 @@ static double rational_pcqc( const double x ) {
190187*
191188* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method
192189*
193- * @private
194- * @param {number} x - value at which to evaluate the rational function
195- * @returns {number} evaluated rational function
190+ * @param x value at which to evaluate the rational function
191+ * @return evaluated rational function
196192*/
197193static double rational_psqs ( const double x ) {
198194 double ax ;
@@ -233,63 +229,59 @@ static double rational_psqs( const double x ) {
233229* @return evaluated Bessel function
234230*
235231* @example
236- * double v = y1 ( 0.0 );
232+ * double v = stdlib_base_bessely1 ( 0.0 );
237233* // returns -Infinity
238234*/
239-
240235double stdlib_base_bessely1 ( double x ) {
241236 double rc ;
242237 double rs ;
243- double y ;
238+ double y2 ;
244239 double r ;
240+ double y ;
245241 double s ;
246242 double c ;
247243 double z ;
248244 double f ;
249- double y2 ;
250- double xc ;
251245
252- if (x < 0.0 ) {
253- return NAN ;
246+ if ( x < 0.0 ) {
247+ return 0.0 / 0.0 ; // NaN
254248 }
255- if (x == 0.0 ) {
256- return - INFINITY ;
249+ if ( x == 0.0 ) {
250+ return STDLIB_CONSTANT_FLOAT64_NINF ;
257251 }
258- if (x == INFINITY ) {
252+ if ( x == STDLIB_CONSTANT_FLOAT64_PINF ) {
259253 return 0.0 ;
260254 }
261- xc = x ;
262- if (xc <= 4.0 ) {
263- y = xc * xc ;
264- z = ( stdlib_base_ln ( xc / x1 ) * stdlib_base_besselj1 ( xc ) ) * TWO_DIV_PI ;
255+ if ( x <= 4.0 ) {
256+ y = x * x ;
257+ z = ( stdlib_base_ln ( x / x1 ) * stdlib_base_besselj1 ( x ) ) * TWO_DIV_PI ;
265258 r = rational_p1q1 ( y );
266- f = ( ( xc + x1 ) * ( ( xc - ( x11 / 256.0 ) ) - x12 ) ) / xc ;
267- return z + ( f * r );
259+ f = ( ( x + x1 ) * ( (x - (x11 / 256.0 )) - x12 ) ) / x ;
260+ return z + ( f * r );
268261 }
269- if ( xc <= 8.0 ) {
270- y = xc * xc ;
271- z = ( stdlib_base_ln ( xc / x2 ) * stdlib_base_besselj1 ( xc ) ) * TWO_DIV_PI ;
262+ if ( x <= 8.0 ) {
263+ y = x * x ;
264+ z = ( stdlib_base_ln ( x / x2 ) * stdlib_base_besselj1 ( x ) ) * TWO_DIV_PI ;
272265 r = rational_p2q2 ( y );
273- f = ( ( xc + x2 ) * ( ( xc - ( x21 / 256.0 ) ) - x22 ) ) / xc ;
274- return z + ( f * r );
266+ f = ( ( x + x2 ) * ( (x - (x21 / 256.0 ) ) - x22 ) ) / x ;
267+ return z + ( f * r );
275268 }
276-
277- y = 8.0 / xc ;
269+ y = 8.0 / x ;
278270 y2 = y * y ;
279271 rc = rational_pcqc ( y2 );
280272 rs = rational_psqs ( y2 );
281- f = ONE_DIV_SQRT_PI / stdlib_base_sqrt ( xc );
273+ f = ONE_DIV_SQRT_PI / stdlib_base_sqrt ( x );
282274
283275 /*
284276 * This code is really just:
285277 *
286278 * ```
287- * z = x - 0.75 * pi ;
279+ * z = x - 0.75 * PI ;
288280 * return f * (rc * sin(z) + y * rs * cos(z));
289281 * ```
290282 *
291283 * But using the sin/cos addition rules, plus constants for sin/cos of `3π/4` which then cancel out with corresponding terms in "f".
292284 */
293- stdlib_base_sincos ( xc , & s , & c );
294- return f * ( ( ( y * rs ) * ( s - c ) ) - ( rc * ( s + c ) ) );
285+ stdlib_base_sincos ( x , & s , & c );
286+ return f * ( ( ( ( y * rs ) * (s - c ) ) - ( rc * (s + c ) ) ) );
295287}
0 commit comments