Skip to content

Commit 140f6e7

Browse files
committed
refactor: apply suggestions from PR review
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent 146eecd commit 140f6e7

File tree

5 files changed

+87
-88
lines changed

5 files changed

+87
-88
lines changed

lib/node_modules/@stdlib/math/base/special/hyp2f1/docs/types/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import hyp2f1 = require( './index' );
2929
hyp2f1( 2.0, 3.0, 5.0, 0.99 ); // $ExpectType number
3030
}
3131

32-
// The compiler throws an error if the function is provided a first argument other than a number...
32+
// The compiler throws an error if the function is provided a first argument which is a not a number...
3333
{
3434
hyp2f1( true, 1.0, 1.0, 0.0 ); // $ExpectError
3535
hyp2f1( false, 7.4, -1.8, -0.99 ); // $ExpectError
@@ -39,7 +39,7 @@ import hyp2f1 = require( './index' );
3939
hyp2f1( ( x: number ): number => x, 1.0, 1.0, 0.0 ); // $ExpectError
4040
}
4141

42-
// The compiler throws an error if the function is provided a second argument other than a number...
42+
// The compiler throws an error if the function is provided a second argument which is a not a number...
4343
{
4444
hyp2f1( 1.0, true, 1.0, 0.0 ); // $ExpectError
4545
hyp2f1( 7.4, false, -1.8, -0.99 ); // $ExpectError
@@ -49,7 +49,7 @@ import hyp2f1 = require( './index' );
4949
hyp2f1( 1.0, ( x: number ): number => x, 1.0, 0.0 ); // $ExpectError
5050
}
5151

52-
// The compiler throws an error if the function is provided a third argument other than a number...
52+
// The compiler throws an error if the function is provided a third argument which is a not a number...
5353
{
5454
hyp2f1( 1.0, 1.0, true, 0.0 ); // $ExpectError
5555
hyp2f1( 7.4, -1.8, false, -0.99 ); // $ExpectError
@@ -59,7 +59,7 @@ import hyp2f1 = require( './index' );
5959
hyp2f1( 1.0, 1.0, ( x: number ): number => x, 0.0 ); // $ExpectError
6060
}
6161

62-
// The compiler throws an error if the function is provided a fourth argument other than a number...
62+
// The compiler throws an error if the function is provided a fourth argument which is a not a number...
6363
{
6464
hyp2f1( 1.0, 1.0, 0.0, true ); // $ExpectError
6565
hyp2f1( 7.4, -1.8, -0.99, false ); // $ExpectError

lib/node_modules/@stdlib/math/base/special/hyp2f1/lib/hys2f1.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ var MAX_ITERATIONS = config.MAX_ITERATIONS;
5252
/**
5353
* Evaluates the Gaussian hypergeometric function by two-term recurrence in `a`.
5454
*
55-
* This helps prevent losing accuracy in the highly alternating hypergeometric series and allows a and b to be reduced to smaller values.
55+
* ## Notes
5656
*
57-
* AMS55 #15.2.10
57+
* - This function helps prevent losing accuracy in the highly alternating hypergeometric series and allows a and b to be reduced to smaller values.
58+
*
59+
* ## References
60+
*
61+
* - AMS55 #15.2.10
5862
*
5963
* @private
6064
* @param {number} a - input value
@@ -79,14 +83,14 @@ function hyp2f1ra( a, b, c, x, loss ) {
7983
err = 0.0;
8084

8185
if ( ( c < 0.0 && a <= c ) || ( c >= 0.0 && a >= c ) ) {
82-
da = round( a - c );
86+
da = round( a-c );
8387
} else {
8488
da = round( a );
8589
}
8690

8791
t = a - da;
8892
if ( abs( da ) > MAX_ITERATIONS ) {
89-
// Too expensive to compute
93+
// Too expensive to compute, so return `NaN`:
9094
loss = 1.0;
9195
return {
9296
'value': NaN,
@@ -95,12 +99,12 @@ function hyp2f1ra( a, b, c, x, loss ) {
9599
}
96100

97101
if ( da < 0.0 ) {
98-
// Backward recurrence
102+
// Backward recurrence...
99103
f2Val = 0.0;
100104
f1 = hys2f1( t, b, c, x, err );
101105
loss += f1.error;
102106
err = f1.error;
103-
f0 = hys2f1( t - 1.0, b, c, x, err );
107+
f0 = hys2f1( t-1.0, b, c, x, err );
104108
loss += f0.error;
105109
t -= 1.0;
106110
f1Val = f1.value;
@@ -110,16 +114,16 @@ function hyp2f1ra( a, b, c, x, loss ) {
110114
f1Val = f0Val;
111115

112116
// eslint-disable-next-line max-len
113-
f0Val = -(((((2.0 * t) - c) - (t * x) + (b * x)) * f1Val) + ((t * (x - 1.0)) * f2Val)) / (c - t);
117+
f0Val = -( ( ( ( (2.0*t)-c )-( t*x )+( b*x ) ) * f1Val ) + ( ( t*(x-1.0) ) * f2Val ) ) / ( c-t );
114118
t -= 1.0;
115119
}
116120
} else {
117-
// Forward recurrence
121+
// Forward recurrence...
118122
f2Val = 0.0;
119123
f1 = hys2f1( t, b, c, x, err );
120124
loss += f1.error;
121125
err = f1.error;
122-
f0 = hys2f1( t + 1.0, b, c, x, err );
126+
f0 = hys2f1( t+1.0, b, c, x, err );
123127
loss += f0.error;
124128
t += 1.0;
125129
f1Val = f1.value;
@@ -129,7 +133,7 @@ function hyp2f1ra( a, b, c, x, loss ) {
129133
f1Val = f0Val;
130134

131135
// eslint-disable-next-line max-len
132-
f0Val = -(((((2.0 * t) - c) - (t * x) + (b * x)) * f1Val) + ((c - t) * f2Val)) / (t * (x - 1.0));
136+
f0Val = -( ( ( ( (2.0*t)-c )-( t*x )+( b*x ) ) * f1Val ) + ( (c-t)*f2Val ) ) / ( t*(x-1.0) );
133137
t += 1.0;
134138
}
135139
}
@@ -182,7 +186,7 @@ function hys2f1( a, b, c, x, loss ) {
182186
}
183187

184188
// eslint-disable-next-line max-len
185-
if ( ( ( abs( a ) > abs( c ) + 1.0 ) || intFlag ) && ( abs( c - a ) > 2.0 ) && ( abs( a ) > 2.0 ) ) {
189+
if ( ( ( abs( a ) > abs( c ) + 1.0 ) || intFlag ) && ( abs( c-a ) > 2.0 ) && ( abs( a ) > 2.0 ) ) {
186190
return hyp2f1ra( a, b, c, x, loss );
187191
}
188192

@@ -204,7 +208,7 @@ function hys2f1( a, b, c, x, loss ) {
204208
};
205209
}
206210
m = k + 1.0;
207-
u *= ( ( f + k ) * ( g + k ) * x / ( ( h + k ) * m ) );
211+
u *= ( ( f+k ) * ( g+k ) * x / ( ( h+k ) * m ) );
208212
s += u;
209213
k = abs( u );
210214
if ( k > umax ) {
@@ -219,10 +223,10 @@ function hys2f1( a, b, c, x, loss ) {
219223
'error': loss
220224
};
221225
}
222-
} while ( s === 0.0 || abs( u / s ) > MACHEP );
226+
} while ( s === 0.0 || abs( u/s ) > MACHEP );
223227

224-
// Estimate the relative error due to truncation by the series
225-
loss = ( ( MACHEP * umax ) / abs( s ) ) + ( MACHEP * i );
228+
// Estimate the relative error due to truncation by the series:
229+
loss = ( ( MACHEP*umax ) / abs( s ) ) + ( MACHEP*i );
226230
return {
227231
'value': s,
228232
'error': loss

lib/node_modules/@stdlib/math/base/special/hyp2f1/lib/hyt2f1.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var MAX_ITERATIONS = config.MAX_ITERATIONS;
6060
// MAIN //
6161

6262
/**
63-
* Applies transformations for |x| near 1 then call the power series expansion.
63+
* Applies transformations for `|x|` near unity before performing a power series expansion.
6464
*
6565
* @private
6666
* @param {number} a - input value
@@ -104,12 +104,12 @@ function hyt2f1( a, b, c, x, loss ) {
104104

105105
if ( x < -0.5 && !( negIntA || negIntB ) ) {
106106
if ( b > a ) {
107-
// Transformation based on AMS55 #15.3.4
108-
y = hys2f1( a, c - b, c, -x / s, err );
107+
// Transformation based on AMS55 #15.3.4:
108+
y = hys2f1( a, c-b, c, -x/s, err );
109109
val = pow( s, -a ) * y.value;
110110
} else {
111-
// Transformation based on AMS55 #15.3.5
112-
y = hys2f1( c - a, b, c, -x / s, err );
111+
// Transformation based on AMS55 #15.3.5:
112+
y = hys2f1( c-a, b, c, -x/s, err );
113113
val = pow( s, -b ) * y.value;
114114
}
115115
loss = y.error;
@@ -129,21 +129,21 @@ function hyt2f1( a, b, c, x, loss ) {
129129
if ( y.error < ETHRESH ) {
130130
return y;
131131
}
132-
// If the power series fails, then apply AMS55 #15.3.6
132+
// If the power series fails, then apply AMS55 #15.3.6...
133133
err = y.error;
134-
q = hys2f1( a, b, 1.0 - d, s, err );
134+
q = hys2f1( a, b, 1.0-d, s, err );
135135
qVal = q.value;
136136
err = q.error;
137137
sign = 1.0;
138138
w = gammaln( d );
139139
sign *= gammasgn( d );
140-
w -= gammaln( c - a );
141-
sign *= gammasgn( c - a );
142-
w -= gammaln( c - b );
143-
sign *= gammasgn( c - b );
140+
w -= gammaln( c-a );
141+
sign *= gammasgn( c-a );
142+
w -= gammaln( c-b );
143+
sign *= gammasgn( c-b );
144144
qVal *= sign * exp( w );
145145

146-
r = hys2f1( c - a, c - b, d + 1.0, s, err1 );
146+
r = hys2f1( c-a, c-b, d+1.0, s, err1 );
147147
err1 = r.error;
148148
rVal = pow( s, d ) * r.value;
149149
sign = 1.0;
@@ -159,7 +159,7 @@ function hyt2f1( a, b, c, x, loss ) {
159159
err += err1 + ( ( MACHEP * max( abs( qVal ), abs( rVal ) ) ) / y );
160160
y *= gamma( c );
161161
} else {
162-
// Psi function expansion, AMS55 #15.3.10, #15.3.11, #15.3.12
162+
// Psi function expansion, AMS55 #15.3.10, #15.3.11, #15.3.12...
163163
if ( id >= 0.0 ) {
164164
e = d;
165165
d1 = d;
@@ -174,17 +174,17 @@ function hyt2f1( a, b, c, x, loss ) {
174174
ax = ln( s );
175175

176176
// eslint-disable-next-line max-len
177-
y = digamma( 1.0 ) + digamma( 1.0 + e ) - digamma( a + d1 ) - digamma( b + d1 ) - ax;
178-
y /= gamma( e + 1.0 );
179-
p = ( a + d1 ) * ( b + d1 ) * s / gamma( e + 2.0 );
177+
y = digamma( 1.0 ) + digamma( 1.0+e ) - digamma( a+d1 ) - digamma( b+d1 ) - ax;
178+
y /= gamma( e+1.0 );
179+
p = ( a+d1 ) * ( b+d1 ) * s / gamma( e+2.0 );
180180
t = 1.0;
181181
do {
182182
// eslint-disable-next-line max-len
183-
r = digamma( 1.0 + t ) + digamma( 1.0 + t + e ) - digamma( a + t + d1 ) - digamma( b + t + d1 ) - ax;
183+
r = digamma( 1.0+t ) + digamma( 1.0+t+e ) - digamma( a+t+d1 ) - digamma( b+t+d1 ) - ax;
184184
q = p * r;
185185
y += q;
186-
p *= s * ( a + t + d1 ) / ( t + 1.0 );
187-
p *= ( b + t + d1 ) / ( t + 1.0 + e );
186+
p *= s * ( a+t+d1 ) / ( t+1.0 );
187+
p *= ( b+t+d1 ) / ( t+1.0+e );
188188
t += 1.0;
189189
if ( t > MAX_ITERATIONS ) {
190190
loss = 1.0;
@@ -193,7 +193,7 @@ function hyt2f1( a, b, c, x, loss ) {
193193
'error': loss
194194
};
195195
}
196-
} while ( y === 0.0 || abs( q / y ) > EPS );
196+
} while ( y === 0.0 || abs( q/y ) > EPS );
197197

198198
if ( id === 0.0 ) {
199199
y *= gamma( c ) / ( gamma( a ) * gamma( b ) );
@@ -209,29 +209,29 @@ function hyt2f1( a, b, c, x, loss ) {
209209
p = 1.0;
210210
for ( i = 1; i < aid; i++ ) {
211211
r = 1.0 - e + t;
212-
p *= s * ( a + t + d2 ) * ( b + t + d2 ) / r;
212+
p *= s * ( a+t+d2 ) * ( b+t+d2 ) / r;
213213
t += 1.0;
214214
p /= t;
215215
y1 += p;
216216
}
217217
}
218218

219219
p = gamma( c );
220-
y1 *= gamma( e ) * p / ( gamma( a + d1 ) * gamma( b + d1 ) );
221-
y *= p / ( gamma( a + d2 ) * gamma( b + d2 ) );
220+
y1 *= gamma( e ) * p / ( gamma( a+d1 ) * gamma( b+d1 ) );
221+
y *= p / ( gamma( a+d2 ) * gamma( b+d2 ) );
222222
if ( aid % 2.0 !== 0.0 ) {
223223
y = -y;
224224
}
225225
q = pow( s, id );
226-
y = ( id > 0.0 ) ? y * q : y1 * q;
226+
y = ( id > 0.0 ) ? y*q : y1*q;
227227
y += y1;
228228
}
229229
return {
230230
'value': y,
231231
'error': err
232232
};
233233
}
234-
// Use defining power series if no special cases
234+
// Perform power series if no special cases:
235235
y = hys2f1( a, b, c, x, err );
236236
return y;
237237
}

0 commit comments

Comments
 (0)