From f54b8358cd9c29d770e82a5cb242b4786c75e5cd Mon Sep 17 00:00:00 2001 From: Abdul Kaium Date: Tue, 21 Apr 2026 19:45:48 +0600 Subject: [PATCH 1/5] bench: update random number generation in `number/int32/base/muldw` --- .../int32/base/muldw/benchmark/benchmark.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/number/int32/base/muldw/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/int32/base/muldw/benchmark/benchmark.js index fe8c46b6afc7..0bc6b81bb2b1 100644 --- a/lib/node_modules/@stdlib/number/int32/base/muldw/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/number/int32/base/muldw/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var minstd = require( '@stdlib/random/base/minstd' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -33,12 +33,17 @@ var imuldw = require( './../lib' ); bench( pkg, function benchmark( b ) { var x; var y; + var z; var i; + x = discreteUniform( 100, 0x10000, 0x10000000, { + 'dtype': 'int32' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = minstd(); - y = imuldw( x, x ); + z = x[ i%x.length ]; + y = imuldw( z, z ); if ( isnan( y[ 0 ] ) ) { b.fail( 'should not return NaN' ); } @@ -55,14 +60,19 @@ bench( format( '%s:assign', pkg ), function benchmark( b ) { var out; var x; var y; + var z; var i; + x = discreteUniform( 100, 0x10000, 0x7fffffff, { + 'dtype': 'int32' + }); + out = [ 0.0, 0.0 ]; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = minstd(); - y = imuldw.assign( x, x, out, 1, 0 ); + z = x[ i%x.length ]; + y = imuldw.assign( z, z, out, 1, 0 ); if ( isnan( y[ 0 ] ) ) { b.fail( 'should not return NaN' ); } From e8f539df2d2b4dd52718b042fac033436ad25fd1 Mon Sep 17 00:00:00 2001 From: Abdul Kaium Date: Tue, 21 Apr 2026 20:27:16 +0600 Subject: [PATCH 2/5] refactor: move `isnan` check from assign.js into main.js and utilize `imul` --- 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: na - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../number/int32/base/muldw/lib/assign.js | 11 ++------ .../number/int32/base/muldw/lib/main.js | 5 ++++ .../int32/base/muldw/test/test.assign.js | 26 ------------------- 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/lib/node_modules/@stdlib/number/int32/base/muldw/lib/assign.js b/lib/node_modules/@stdlib/number/int32/base/muldw/lib/assign.js index 06b77e37b54a..f95cf27803bb 100644 --- a/lib/node_modules/@stdlib/number/int32/base/muldw/lib/assign.js +++ b/lib/node_modules/@stdlib/number/int32/base/muldw/lib/assign.js @@ -20,7 +20,7 @@ // MODULES // -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var imul = require( '@stdlib/number/int32/base/mul' ); // VARIABLES // @@ -48,7 +48,6 @@ var LOW_WORD_MASK = 0x0000ffff>>>0; // asm type annotation function imuldw( a, b, out, stride, offset ) { var w1; var w2; - var w3; var ha; var hb; var la; @@ -56,11 +55,6 @@ function imuldw( a, b, out, stride, offset ) { var t; var k; - if ( isnan( a ) || isnan( b ) ) { - out[ offset ] = NaN; - out[ offset + stride ] = NaN; - return out; - } a |= 0; // asm type annotation b |= 0; // asm type annotation @@ -71,7 +65,6 @@ function imuldw( a, b, out, stride, offset ) { lb = ( b & LOW_WORD_MASK ) >>> 0; t = ( la*lb ) >>> 0; - w3 = ( t & LOW_WORD_MASK ) >>> 0; k = ( t >>> 16 ) >>> 0; t = ( ( ha*lb ) + k ) >>> 0; @@ -82,7 +75,7 @@ function imuldw( a, b, out, stride, offset ) { k = ( t >> 16 ) >>> 0; out[ offset ] = ( ( ha*hb ) + w1 + k ) | 0; // compute the higher 32 bits and cast to a signed 32-bit integer - out[ offset + stride ] = ( ( t << 16 ) + w3 ) | 0; // compute the lower 32 bits and cast to a signed 32-bit integer + out[ offset + stride ] = imul( a, b ) | 0; // compute the lower 32 bits and cast to a signed 32-bit integer return out; } diff --git a/lib/node_modules/@stdlib/number/int32/base/muldw/lib/main.js b/lib/node_modules/@stdlib/number/int32/base/muldw/lib/main.js index 81bb71cc2dcb..66919675a957 100644 --- a/lib/node_modules/@stdlib/number/int32/base/muldw/lib/main.js +++ b/lib/node_modules/@stdlib/number/int32/base/muldw/lib/main.js @@ -20,6 +20,7 @@ // MODULES // +var isnan = require( '@stdlib/math/base/assert/is-nan' ); var fcn = require( './assign.js' ); @@ -37,6 +38,10 @@ var fcn = require( './assign.js' ); * // returns [ -477218589, 1908874354 ] */ function imuldw( a, b ) { + if ( isnan( a ) || isnan( b ) ) { + return [ NaN, NaN ]; + } + return fcn( a, b, [ 0, 0 ], 1, 0 ); } diff --git a/lib/node_modules/@stdlib/number/int32/base/muldw/test/test.assign.js b/lib/node_modules/@stdlib/number/int32/base/muldw/test/test.assign.js index a8eaf1613e75..f651767031e4 100644 --- a/lib/node_modules/@stdlib/number/int32/base/muldw/test/test.assign.js +++ b/lib/node_modules/@stdlib/number/int32/base/muldw/test/test.assign.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var imuldw = require( './../lib/assign.js' ); @@ -39,31 +38,6 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { - var out; - var v; - - out = [ 0, 0 ]; - v = imuldw( NaN, 1, out, 1, 0 ); - t.strictEqual( v, out, 'returns output array' ); - t.strictEqual( isnan( v[0] ), true, 'returns expected value' ); - t.strictEqual( isnan( v[1] ), true, 'returns expected value' ); - - out = [ 0, 0 ]; - v = imuldw( 1, NaN, out, 1, 0 ); - t.strictEqual( v, out, 'returns output array' ); - t.strictEqual( isnan( v[0] ), true, 'returns expected value' ); - t.strictEqual( isnan( v[1] ), true, 'returns expected value' ); - - out = [ 0, 0 ]; - v = imuldw( NaN, NaN, out, 1, 0 ); - t.strictEqual( v, out, 'returns output array' ); - t.strictEqual( isnan( v[0] ), true, 'returns expected value' ); - t.strictEqual( isnan( v[1] ), true, 'returns expected value' ); - - t.end(); -}); - tape( 'the function computes the double word product of two (signed) words', function test( t ) { var expected; var actual; From e8de3814a068343bf0e39e0eba461533e1a539ff Mon Sep 17 00:00:00 2001 From: Abdul Kaium Date: Wed, 22 Apr 2026 00:30:56 +0600 Subject: [PATCH 3/5] bench: minor refactor --- 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: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/number/int32/base/muldw/benchmark/benchmark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/number/int32/base/muldw/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/int32/base/muldw/benchmark/benchmark.js index 0bc6b81bb2b1..6edb20a4caba 100644 --- a/lib/node_modules/@stdlib/number/int32/base/muldw/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/number/int32/base/muldw/benchmark/benchmark.js @@ -63,7 +63,7 @@ bench( format( '%s:assign', pkg ), function benchmark( b ) { var z; var i; - x = discreteUniform( 100, 0x10000, 0x7fffffff, { + x = discreteUniform( 100, 0x10000, 0x10000000, { 'dtype': 'int32' }); From 8f8f5090d5b82689bacefbb3a1a45e0a542da4b2 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 22 Apr 2026 02:30:04 -0700 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/number/int32/base/muldw/lib/main.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/node_modules/@stdlib/number/int32/base/muldw/lib/main.js b/lib/node_modules/@stdlib/number/int32/base/muldw/lib/main.js index 66919675a957..81bb71cc2dcb 100644 --- a/lib/node_modules/@stdlib/number/int32/base/muldw/lib/main.js +++ b/lib/node_modules/@stdlib/number/int32/base/muldw/lib/main.js @@ -20,7 +20,6 @@ // MODULES // -var isnan = require( '@stdlib/math/base/assert/is-nan' ); var fcn = require( './assign.js' ); @@ -38,10 +37,6 @@ var fcn = require( './assign.js' ); * // returns [ -477218589, 1908874354 ] */ function imuldw( a, b ) { - if ( isnan( a ) || isnan( b ) ) { - return [ NaN, NaN ]; - } - return fcn( a, b, [ 0, 0 ], 1, 0 ); } From d3f40b065845778d1ecf5afaff13745538b7ef5d Mon Sep 17 00:00:00 2001 From: Abdul Kaium Date: Wed, 22 Apr 2026 16:53:55 +0600 Subject: [PATCH 5/5] test: remove isnan checks from test.main.js --- 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: na - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../number/int32/base/muldw/test/test.main.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/lib/node_modules/@stdlib/number/int32/base/muldw/test/test.main.js b/lib/node_modules/@stdlib/number/int32/base/muldw/test/test.main.js index 55b967f645c7..add55d5d3c3f 100644 --- a/lib/node_modules/@stdlib/number/int32/base/muldw/test/test.main.js +++ b/lib/node_modules/@stdlib/number/int32/base/muldw/test/test.main.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); var imuldw = require( './../lib/main.js' ); @@ -38,24 +37,6 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { - var v; - - v = imuldw( NaN, 1 ); - t.strictEqual( isnan( v[0] ), true, 'returns expected value' ); - t.strictEqual( isnan( v[1] ), true, 'returns expected value' ); - - v = imuldw( 1, NaN ); - t.strictEqual( isnan( v[0] ), true, 'returns expected value' ); - t.strictEqual( isnan( v[1] ), true, 'returns expected value' ); - - v = imuldw( NaN, NaN ); - t.strictEqual( isnan( v[0] ), true, 'returns expected value' ); - t.strictEqual( isnan( v[1] ), true, 'returns expected value' ); - - t.end(); -}); - tape( 'the function computes the double word product of two (signed) words', function test( t ) { var expected; var actual;