Skip to content

Commit d16677b

Browse files
committed
refactor: fix JS implementation
--- 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: na - 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 fe5ece6 commit d16677b

File tree

6 files changed

+42
-24
lines changed

6 files changed

+42
-24
lines changed

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Compute `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`.
22+
* Compute `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]` as a single-precision floating-point number.
2323
*
2424
* @module @stdlib/math/base/special/kernel-log1pf
2525
*

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/main.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* ## Notice
2020
*
21-
* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/k_log.h}. The implementation follows the original, but has been modified for JavaScript.
21+
* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/k_logf.h}. The implementation follows the original, but has been modified for JavaScript.
2222
*
2323
* ```text
2424
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -34,15 +34,21 @@
3434

3535
// MODULES //
3636

37-
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
37+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
3838
var polyvalP = require( './polyval_p.js' );
3939
var polyvalQ = require( './polyval_q.js' );
4040

4141

42+
// VARIABLES //
43+
44+
var HALF = f32( 0.5 );
45+
var TWO = f32( 2.0 );
46+
47+
4248
// MAIN //
4349

4450
/**
45-
* Computes `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`.
51+
* Computes `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]` as a single-precision floating-point number.
4652
*
4753
* ## Method
4854
*
@@ -125,7 +131,7 @@ var polyvalQ = require( './polyval_q.js' );
125131
* // returns ~0.1931
126132
*
127133
* @example
128-
* var v = kernelLog1pf( 1.4142135 );
134+
* var v = kernelLog1pf( 1.4142135381698608 );
129135
* // returns ~0.4672
130136
*
131137
* @example
@@ -141,14 +147,15 @@ function kernelLog1pf( f ) {
141147
var R;
142148
var w;
143149

144-
s = float64ToFloat32( f / float64ToFloat32( 2.0 + f ) );
145-
z = float64ToFloat32( s * s );
146-
w = float64ToFloat32( z * z );
147-
t1 = float64ToFloat32( w * polyvalP( w ) );
148-
t2 = float64ToFloat32( z * polyvalQ( w ) );
149-
R = float64ToFloat32( t2 + t1 );
150-
hfsq = float64ToFloat32( 0.5 * float64ToFloat32( f * f ) );
151-
return float64ToFloat32( s * float64ToFloat32( hfsq + R ) );
150+
f = f32( f );
151+
s = f32( f / f32( TWO + f ) );
152+
z = f32( s * s );
153+
w = f32( z * z );
154+
t1 = f32( w * polyvalP( w ) );
155+
t2 = f32( z * polyvalQ( w ) );
156+
R = f32( t2 + t1 );
157+
hfsq = f32( HALF * f32( f * f ) );
158+
return f32( s * f32( hfsq + R ) );
152159
}
153160

154161

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/native.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' );
2626
// MAIN //
2727

2828
/**
29-
* Computes `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`.
29+
* Computes `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]` as a single-precision floating-point number.
3030
*
3131
* @private
3232
* @param {number} f - input value
@@ -37,7 +37,7 @@ var addon = require( './../src/addon.node' );
3737
* // returns ~0.1931
3838
*
3939
* @example
40-
* var v = kernelLog1pf( 1.4142135 );
40+
* var v = kernelLog1pf( 1.4142135381698608 );
4141
* // returns ~0.4672
4242
*
4343
* @example

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/polyval_p.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
/* This is a generated file. Do not edit directly. */
2020
'use strict';
2121

22+
// MODULES //
23+
24+
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
25+
26+
2227
// MAIN //
2328

2429
/**
@@ -36,9 +41,9 @@
3641
*/
3742
function evalpoly( x ) {
3843
if ( x === 0.0 ) {
39-
return 0.40000972152;
44+
return 0.40000972151756287;
4045
}
41-
return 0.40000972152 + (x * 0.24279078841);
46+
return float64ToFloat32(0.40000972151756287 + float64ToFloat32(x * 0.24279078841209412)); // eslint-disable-line max-len
4247
}
4348

4449

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/polyval_q.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
/* This is a generated file. Do not edit directly. */
2020
'use strict';
2121

22+
// MODULES //
23+
24+
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
25+
26+
2227
// MAIN //
2328

2429
/**
@@ -36,9 +41,9 @@
3641
*/
3742
function evalpoly( x ) {
3843
if ( x === 0.0 ) {
39-
return 0.66666662693;
44+
return 0.6666666269302368;
4045
}
41-
return 0.66666662693 + (x * 0.28498786688);
46+
return float64ToFloat32(0.6666666269302368 + float64ToFloat32(x * 0.2849878668785095)); // eslint-disable-line max-len
4247
}
4348

4449

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/scripts/evalpoly.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ var resolve = require( 'path' ).resolve;
2727
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
2828
var writeFileSync = require( '@stdlib/fs/write-file' ).sync;
2929
var currentYear = require( '@stdlib/time/current-year' );
30-
var substringBefore = require( '@stdlib/string/substring-before' );
31-
var substringAfter = require( '@stdlib/string/substring-after' );
32-
var format = require( '@stdlib/string/format' );
3330
var licenseHeader = require( '@stdlib/_tools/licenses/header' );
3431
var compile = require( '@stdlib/math/base/tools/evalpoly-compile' );
3532
var compileC = require( '@stdlib/math/base/tools/evalpoly-compile-c' );
33+
var substringBefore = require( '@stdlib/string/substring-before' );
34+
var substringAfter = require( '@stdlib/string/substring-after' );
35+
var format = require( '@stdlib/string/format' );
3636

3737

3838
// VARIABLES //
@@ -97,15 +97,16 @@ function main() {
9797
var str;
9898

9999
opts = {
100+
'dtype': 'float32',
100101
'encoding': 'utf8'
101102
};
102103

103104
fpath = resolve( __dirname, '..', 'lib', 'polyval_p.js' );
104-
str = header + compile( P );
105+
str = header + compile( P, opts );
105106
writeFileSync( fpath, str, opts );
106107

107108
fpath = resolve( __dirname, '..', 'lib', 'polyval_q.js' );
108-
str = header + compile( Q );
109+
str = header + compile( Q, opts );
109110
writeFileSync( fpath, str, opts );
110111

111112
copts = {

0 commit comments

Comments
 (0)