Skip to content

Commit 48d185f

Browse files
committed
chore: use f32 instead of float64ToFloat32
--- 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: na - task: lint_license_headers status: passed ---
1 parent 2c98ece commit 48d185f

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

lib/node_modules/@stdlib/math/base/special/spencef/lib/main.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636

3737
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
3838
var lnf = require( '@stdlib/math/base/special/lnf' );
39-
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
39+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
4040
var polyvalA = require( './polyval_a.js' );
4141
var polyvalB = require( './polyval_b.js' );
4242

4343

4444
// VARIABLES //
4545

46-
var PI2O6 = float64ToFloat32( 1.64493406684822643647 ); // π^2 / 6
46+
var PI2O6 = f32( 1.64493406684822643647 ); // π^2 / 6
4747

4848

4949
// MAIN //
@@ -100,27 +100,26 @@ function spencef( x ) {
100100
}
101101
flg = 0;
102102
if ( x > 2.0 ) {
103-
x = float64ToFloat32( 1.0 / float64ToFloat32( x ) );
103+
x = f32( 1.0 / f32( x ) );
104104
flg |= 2;
105105
}
106106
if ( x > 1.5 ) {
107-
w = float64ToFloat32( 1.0 / float64ToFloat32( x ) ) - 1.0;
107+
w = f32( 1.0 / f32( x ) ) - 1.0;
108108
flg |= 2;
109109
} else if ( x < 0.5 ) {
110-
w = float64ToFloat32( -x );
110+
w = f32( -x );
111111
flg |= 1;
112112
} else {
113-
w = float64ToFloat32( x ) - 1.0;
113+
w = f32( x ) - 1.0;
114114
}
115-
// eslint-disable-next-line max-len
116-
y = float64ToFloat32( -w * float64ToFloat32( polyvalA( w )/polyvalB( w ) ) );
115+
116+
y = f32( -w * f32( f32( polyvalA(w) ) / f32( polyvalB(w) ) ) );
117117
if ( flg & 1 ) {
118-
// eslint-disable-next-line max-len
119-
y = float64ToFloat32( PI2O6 - float64ToFloat32( lnf( x )*lnf( 1.0-x ) ) - y );
118+
y = f32( PI2O6 - f32( lnf( x )*lnf( 1.0-x ) ) - y );
120119
}
121120
if ( flg & 2 ) {
122121
z = lnf( x );
123-
y = -float64ToFloat32( float64ToFloat32( 0.5*z*z ) + y );
122+
y = -f32( f32( 0.5*z*z ) + y );
124123
}
125124
return y;
126125
}

lib/node_modules/@stdlib/math/base/special/spencef/test/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var tape = require( 'tape' );
2424
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2525
var absf = require( '@stdlib/math/base/special/absf' );
2626
var PI_SQUARED = require( '@stdlib/constants/float32/pi-squared' );
27-
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
27+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
2828
var EPS = require( '@stdlib/constants/float32/eps' );
2929
var spencef = require( './../lib' );
3030

@@ -99,7 +99,7 @@ tape( 'the function accurately computes the dilogarithm for large positive numbe
9999
for ( i = 0; i < x.length; i++ ) {
100100
v = spencef( x[ i ] );
101101
delta = absf( v - expected[ i ] );
102-
tol = EPS * absf( expected[ i ] );
102+
tol = 2.0 * EPS * absf( expected[ i ] );
103103
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. actual: ' + v + '. expected: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
104104
}
105105
t.end();
@@ -133,7 +133,7 @@ tape( 'the function returns `0.0` if provided `1.0` for `x`', function test( t )
133133

134134
tape( 'the function returns `PI^2/6` if provided `0.0` for `x`', function test( t ) {
135135
var val = spencef( 0.0 );
136-
t.strictEqual( val, float64ToFloat32( PI_SQUARED/6.0 ), 'returns expected value' );
136+
t.strictEqual( val, f32( PI_SQUARED/6.0 ), 'returns expected value' );
137137
t.end();
138138
});
139139

lib/node_modules/@stdlib/math/base/special/spencef/test/test.native.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var resolve = require( 'path' ).resolve;
2424
var tape = require( 'tape' );
2525
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2626
var absf = require( '@stdlib/math/base/special/absf' );
27-
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
27+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
2828
var PI_SQUARED = require( '@stdlib/constants/float32/pi-squared' );
2929
var EPS = require( '@stdlib/constants/float32/eps' );
3030
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -146,7 +146,7 @@ tape( 'the function returns `0.0` if provided `1.0` for `x`', opts, function tes
146146

147147
tape( 'the function returns `PI^2/6` if provided `0.0` for `x`', opts, function test( t ) {
148148
var val = spencef( 0.0 );
149-
t.strictEqual( val, float64ToFloat32( PI_SQUARED/6.0 ), 'returns expected value' );
149+
t.strictEqual( val, f32( PI_SQUARED/6.0 ), 'returns expected value' );
150150
t.end();
151151
});
152152

0 commit comments

Comments
 (0)