From 22f1654a33224c8a5bfd3bfc11379e8ac4b96249 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 5 Apr 2025 11:58:39 -0700 Subject: [PATCH 01/16] test: add tests for IEEE 754-2019 compliance --- 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/ln/test/test.js | 10 +++++- .../math/base/special/ln/test/test.native.js | 10 +++++- .../math/base/special/lnf/test/test.js | 10 +++++- .../math/base/special/lnf/test/test.native.js | 10 +++++- .../math/base/special/log/test/test.js | 32 +++++++++++++++++++ .../math/base/special/log/test/test.native.js | 32 +++++++++++++++++++ .../math/base/special/log10/test/test.js | 3 +- .../base/special/log10/test/test.native.js | 3 +- .../math/base/special/log2/test/test.js | 3 +- .../base/special/log2/test/test.native.js | 3 +- 10 files changed, 108 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ln/test/test.js b/lib/node_modules/@stdlib/math/base/special/ln/test/test.js index 95e8806ae848..7ac300933beb 100644 --- a/lib/node_modules/@stdlib/math/base/special/ln/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/ln/test/test.js @@ -26,6 +26,7 @@ var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var EPS = require( '@stdlib/constants/float64/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var ln = require( './../lib' ); @@ -209,8 +210,9 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)', t.end(); }); -tape( 'the function returns `-infinity` if provided `0`', function test( t ) { +tape( 'the function returns `-infinity` if provided `+-0`', function test( t ) { t.equal( ln( 0.0 ), NINF, 'equals -infinity' ); + t.equal( ln( -0.0 ), NINF, 'equals -infinity' ); t.end(); }); @@ -224,3 +226,9 @@ tape( 'the function returns `NaN` if provided a negative number', function test( t.equal( isnan( v ), true, 'returns NaN' ); t.end(); }); + +tape( 'the function returns positive zero if provided `1.0`', function test( t ) { + var v = ln( 1.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/ln/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/ln/test/test.native.js index 52daca776f22..368504390f85 100644 --- a/lib/node_modules/@stdlib/math/base/special/ln/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/ln/test/test.native.js @@ -27,6 +27,7 @@ var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var EPS = require( '@stdlib/constants/float64/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -218,8 +219,9 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)', t.end(); }); -tape( 'the function returns `-infinity` if provided `0`', opts, function test( t ) { +tape( 'the function returns `-infinity` if provided `+-0`', opts, function test( t ) { t.equal( ln( 0.0 ), NINF, 'equals -infinity' ); + t.equal( ln( -0.0 ), NINF, 'equals -infinity' ); t.end(); }); @@ -233,3 +235,9 @@ tape( 'the function returns `NaN` if provided a negative number', opts, function t.equal( isnan( v ), true, 'returns NaN' ); t.end(); }); + +tape( 'the function returns positive zero if provided `1.0`', opts, function test( t ) { + var v = ln( 1.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/lnf/test/test.js b/lib/node_modules/@stdlib/math/base/special/lnf/test/test.js index 58a1ece044c9..41ece95f37bd 100644 --- a/lib/node_modules/@stdlib/math/base/special/lnf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/lnf/test/test.js @@ -27,6 +27,7 @@ var NINF = require( '@stdlib/constants/float32/ninf' ); var EPS = require( '@stdlib/constants/float32/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var lnf = require( './../lib' ); @@ -224,8 +225,9 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)', t.end(); }); -tape( 'the function returns `-infinity` if provided `0`', function test( t ) { +tape( 'the function returns `-infinity` if provided `+-0`', function test( t ) { t.equal( lnf( 0.0 ), NINF, 'returns expected value' ); + t.equal( lnf( -0.0 ), NINF, 'returns expected value' ); t.end(); }); @@ -239,3 +241,9 @@ tape( 'the function returns `NaN` if provided a negative number', function test( t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); + +tape( 'the function returns positive zero if provided `1.0`', function test( t ) { + var v = lnf( 1.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/lnf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/lnf/test/test.native.js index f1f6c7d08154..9d01c148267a 100644 --- a/lib/node_modules/@stdlib/math/base/special/lnf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/lnf/test/test.native.js @@ -28,6 +28,7 @@ var NINF = require( '@stdlib/constants/float32/ninf' ); var EPS = require( '@stdlib/constants/float32/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -233,8 +234,9 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)', t.end(); }); -tape( 'the function returns `-infinity` if provided `0`', opts, function test( t ) { +tape( 'the function returns `-infinity` if provided `+-0`', opts, function test( t ) { t.equal( lnf( 0.0 ), NINF, 'returns expected value' ); + t.equal( lnf( -0.0 ), NINF, 'returns expected value' ); t.end(); }); @@ -248,3 +250,9 @@ tape( 'the function returns `NaN` if provided a negative number', opts, function t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); + +tape( 'the function returns positive zero if provided `1.0`', opts, function test( t ) { + var v = lnf( 1.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/log/test/test.js b/lib/node_modules/@stdlib/math/base/special/log/test/test.js index 30c32561a725..02896cf51b6d 100644 --- a/lib/node_modules/@stdlib/math/base/special/log/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/log/test/test.js @@ -26,6 +26,9 @@ var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); var ln = require( '@stdlib/math/base/special/ln' ); var EPS = require( '@stdlib/constants/float64/eps' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var log = require( './../lib' ); @@ -68,6 +71,35 @@ tape( 'the function returns `1.0` if provided `x` and `b` such that `x = b` (exc t.end(); }); +tape( 'the function returns `+infinity` if provided `x = +infinity` and a valid `b`', function test( t ) { + t.equal( log( PINF, 1.0 ), PINF, 'returns expected value' ); + t.equal( log( PINF, 2.0 ), PINF, 'returns expected value' ); + t.equal( log( PINF, 10.0 ), PINF, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `-infinity` if provided `x = +-0` and a valid `b`', function test( t ) { + t.equal( log( 0.0, 1.0 ), NINF, 'returns expected value' ); + t.equal( log( 0.0, 2.0 ), NINF, 'returns expected value' ); + t.equal( log( 0.0, 10.0 ), NINF, 'returns expected value' ); + t.equal( log( -0.0, 1.0 ), NINF, 'returns expected value' ); + t.equal( log( -0.0, 2.0 ), NINF, 'returns expected value' ); + t.equal( log( -0.0, 10.0 ), NINF, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns positive zero if provided `x = 1.0` and a valid `b`', function test( t ) { + var v; + + v = log( 1.0, 2.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + + v = log( 1.0, 10.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns `ln(x) / ln(b)`', function test( t ) { var b; var x; diff --git a/lib/node_modules/@stdlib/math/base/special/log/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/log/test/test.native.js index 266cfead0a3c..2cf820559d08 100644 --- a/lib/node_modules/@stdlib/math/base/special/log/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/log/test/test.native.js @@ -27,6 +27,9 @@ var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); var ln = require( '@stdlib/math/base/special/ln' ); var EPS = require( '@stdlib/constants/float64/eps' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -77,6 +80,35 @@ tape( 'the function returns `1.0` if provided `x` and `b` such that `x = b` (exc t.end(); }); +tape( 'the function returns `+infinity` if provided `x = +infinity` and a valid `b`', opts, function test( t ) { + t.equal( log( PINF, 1.0 ), PINF, 'returns expected value' ); + t.equal( log( PINF, 2.0 ), PINF, 'returns expected value' ); + t.equal( log( PINF, 10.0 ), PINF, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `-infinity` if provided `x = +-0` and a valid `b`', opts, function test( t ) { + t.equal( log( 0.0, 1.0 ), NINF, 'returns expected value' ); + t.equal( log( 0.0, 2.0 ), NINF, 'returns expected value' ); + t.equal( log( 0.0, 10.0 ), NINF, 'returns expected value' ); + t.equal( log( -0.0, 1.0 ), NINF, 'returns expected value' ); + t.equal( log( -0.0, 2.0 ), NINF, 'returns expected value' ); + t.equal( log( -0.0, 10.0 ), NINF, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns positive zero if provided `x = 1.0` and a valid `b`', opts, function test( t ) { + var v; + + v = log( 1.0, 2.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + + v = log( 1.0, 10.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns `ln(x) / ln(b)`', opts, function test( t ) { var b; var x; diff --git a/lib/node_modules/@stdlib/math/base/special/log10/test/test.js b/lib/node_modules/@stdlib/math/base/special/log10/test/test.js index 66805bcf9cae..1f91530f3091 100644 --- a/lib/node_modules/@stdlib/math/base/special/log10/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/log10/test/test.js @@ -210,8 +210,9 @@ tape( 'the function evaluates the common logarithm of `x` (subnormal values)', f t.end(); }); -tape( 'the function returns `-infinity` if provided `0`', function test( t ) { +tape( 'the function returns `-infinity` if provided `+-0`', function test( t ) { t.equal( log10( 0.0 ), NINF, 'returns expected value' ); + t.equal( log10( -0.0 ), NINF, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/log10/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/log10/test/test.native.js index 0fe0b180bf3e..2fa86fae1d9e 100644 --- a/lib/node_modules/@stdlib/math/base/special/log10/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/log10/test/test.native.js @@ -219,8 +219,9 @@ tape( 'the function evaluates the common logarithm of `x` (subnormal values)', o t.end(); }); -tape( 'the function returns `-infinity` if provided `0`', opts, function test( t ) { +tape( 'the function returns `-infinity` if provided `+-0`', opts, function test( t ) { t.equal( log10( 0.0 ), NINF, 'returns expected value' ); + t.equal( log10( -0.0 ), NINF, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/log2/test/test.js b/lib/node_modules/@stdlib/math/base/special/log2/test/test.js index f87ef530a3e7..e3f77d67caf5 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/log2/test/test.js @@ -210,8 +210,9 @@ tape( 'the function evaluates the binary logarithm of `x` (subnormal values)', f t.end(); }); -tape( 'the function returns `-infinity` if provided `0`', function test( t ) { +tape( 'the function returns `-infinity` if provided `+-0`', function test( t ) { t.equal( log2( 0.0 ), NINF, 'returns expected value' ); + t.equal( log2( -0.0 ), NINF, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/log2/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/log2/test/test.native.js index fe115c3d93b1..f9fa960d854b 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/log2/test/test.native.js @@ -219,8 +219,9 @@ tape( 'the function evaluates the binary logarithm of `x` (subnormal values)', o t.end(); }); -tape( 'the function returns `-infinity` if provided `0`', opts, function test( t ) { +tape( 'the function returns `-infinity` if provided `+-0`', opts, function test( t ) { t.equal( log2( 0.0 ), NINF, 'returns expected value' ); + t.equal( log2( -0.0 ), NINF, 'returns expected value' ); t.end(); }); From b9f6678f1486727d8bf8c29af45e2d15ae920595 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 5 Apr 2025 12:00:48 -0700 Subject: [PATCH 02/16] refactor: test messages --- 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/math/base/special/ln/test/test.js | 4 ++-- .../@stdlib/math/base/special/ln/test/test.native.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ln/test/test.js b/lib/node_modules/@stdlib/math/base/special/ln/test/test.js index 7ac300933beb..d2aed0c1b352 100644 --- a/lib/node_modules/@stdlib/math/base/special/ln/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/ln/test/test.js @@ -211,8 +211,8 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)', }); tape( 'the function returns `-infinity` if provided `+-0`', function test( t ) { - t.equal( ln( 0.0 ), NINF, 'equals -infinity' ); - t.equal( ln( -0.0 ), NINF, 'equals -infinity' ); + t.equal( ln( 0.0 ), NINF, 'returns expected value' ); + t.equal( ln( -0.0 ), NINF, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/ln/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/ln/test/test.native.js index 368504390f85..55ff7629251d 100644 --- a/lib/node_modules/@stdlib/math/base/special/ln/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/ln/test/test.native.js @@ -220,8 +220,8 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)', }); tape( 'the function returns `-infinity` if provided `+-0`', opts, function test( t ) { - t.equal( ln( 0.0 ), NINF, 'equals -infinity' ); - t.equal( ln( -0.0 ), NINF, 'equals -infinity' ); + t.equal( ln( 0.0 ), NINF, 'returns expected value' ); + t.equal( ln( -0.0 ), NINF, 'returns expected value' ); t.end(); }); From c9143a4ad754954f58fc4bb0c606f2d8bd9e71b4 Mon Sep 17 00:00:00 2001 From: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Date: Mon, 7 Apr 2025 16:42:55 -0700 Subject: [PATCH 03/16] test: add tests for IEEE 754-2019 compliance PR-URL: https://github.com/stdlib-js/stdlib/pull/6599 Ref: https://github.com/stdlib-js/stdlib/issues/365 Reviewed-by: Philipp Burckhardt --- .../@stdlib/math/base/special/acosd/test/test.js | 6 ++++++ .../@stdlib/math/base/special/acosd/test/test.native.js | 6 ++++++ .../@stdlib/math/base/special/acosdf/test/test.js | 6 ++++++ .../@stdlib/math/base/special/acosdf/test/test.native.js | 6 ++++++ .../@stdlib/math/base/special/acosf/test/test.js | 6 ++++++ .../@stdlib/math/base/special/acosf/test/test.native.js | 6 ++++++ 6 files changed, 36 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/special/acosd/test/test.js b/lib/node_modules/@stdlib/math/base/special/acosd/test/test.js index 0b1822c91909..dbf14a8c64e2 100644 --- a/lib/node_modules/@stdlib/math/base/special/acosd/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/acosd/test/test.js @@ -25,6 +25,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var abs = require( '@stdlib/math/base/special/abs' ); var randu = require( '@stdlib/random/base/randu' ); var EPS = require( '@stdlib/constants/float64/eps' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var acosd = require( './../lib' ); @@ -117,3 +118,8 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', functi } t.end(); }); + +tape( 'the function returns `0` if provided `1`', function test( t ) { + t.strictEqual( isPositiveZero( acosd( 1.0 ) ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/acosd/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/acosd/test/test.native.js index f374595a7792..68ab900f9b37 100644 --- a/lib/node_modules/@stdlib/math/base/special/acosd/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/acosd/test/test.native.js @@ -26,6 +26,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var abs = require( '@stdlib/math/base/special/abs' ); var randu = require( '@stdlib/random/base/randu' ); var EPS = require( '@stdlib/constants/float64/eps' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -126,3 +127,8 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', opts, } t.end(); }); + +tape( 'the function returns `0` if provided `1`', opts, function test( t ) { + t.strictEqual( isPositiveZero( acosd( 1.0 ) ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/acosdf/test/test.js b/lib/node_modules/@stdlib/math/base/special/acosdf/test/test.js index ff3e76f561dc..84e3b52b0877 100644 --- a/lib/node_modules/@stdlib/math/base/special/acosdf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/acosdf/test/test.js @@ -25,6 +25,7 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var absf = require( '@stdlib/math/base/special/absf' ); var randu = require( '@stdlib/random/base/randu' ); var EPS = require( '@stdlib/constants/float32/eps' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var acosdf = require( './../lib' ); @@ -117,3 +118,8 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', functi } t.end(); }); + +tape( 'the function returns `0` if provided `1`', function test( t ) { + t.strictEqual( isPositiveZero( acosdf( 1.0 ) ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/acosdf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/acosdf/test/test.native.js index 387eafd7823c..1fe883c99694 100644 --- a/lib/node_modules/@stdlib/math/base/special/acosdf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/acosdf/test/test.native.js @@ -26,6 +26,7 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var absf = require( '@stdlib/math/base/special/absf' ); var randu = require( '@stdlib/random/base/randu' ); var EPS = require( '@stdlib/constants/float32/eps' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -126,3 +127,8 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', opts, } t.end(); }); + +tape( 'the function returns `0` if provided `1`', opts, function test( t ) { + t.strictEqual( isPositiveZero( acosdf( 1.0 ) ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/acosf/test/test.js b/lib/node_modules/@stdlib/math/base/special/acosf/test/test.js index 391dddcbd8c2..70ae766c8e07 100644 --- a/lib/node_modules/@stdlib/math/base/special/acosf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/acosf/test/test.js @@ -27,6 +27,7 @@ var uniform = require( '@stdlib/random/base/uniform' ); var abs = require( '@stdlib/math/base/special/abs' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var PI = require( '@stdlib/constants/float32/pi' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var acosf = require( './../lib' ); @@ -162,3 +163,8 @@ tape( 'the function returns `PI` if provided a value equal to `-1`', function te t.strictEqual( v, PI, 'returns expected value' ); t.end(); }); + +tape( 'the function returns `0` if provided `1`', function test( t ) { + t.strictEqual( isPositiveZero( acosf( 1.0 ) ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/acosf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/acosf/test/test.native.js index 8e493222047f..fb79ac291541 100644 --- a/lib/node_modules/@stdlib/math/base/special/acosf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/acosf/test/test.native.js @@ -28,6 +28,7 @@ var uniform = require( '@stdlib/random/base/uniform' ); var abs = require( '@stdlib/math/base/special/abs' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var PI = require( '@stdlib/constants/float32/pi' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -171,3 +172,8 @@ tape( 'the function returns `PI` if provided a value equal to `-1`', opts, funct t.strictEqual( v, PI, 'returns expected value' ); t.end(); }); + +tape( 'the function returns `0` if provided `1`', opts, function test( t ) { + t.strictEqual( isPositiveZero( acosf( 1.0 ) ), true, 'returns expected value' ); + t.end(); +}); From fdba081cb8ffeb1b6589fab84412ac263d0b2a20 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:18:47 -0400 Subject: [PATCH 04/16] docs: update list of contributors PR-URL: https://github.com/stdlib-js/stdlib/pull/6590 Reviewed-by: Philipp Burckhardt Signed-off-by: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 2d37c54d6313..c9a6e7d007e5 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -77,6 +77,7 @@ Joris Labie Justin Dennison Justyn Shelby <96994781+ShelbyJustyn@users.noreply.github.com> Karan Anand +Karan Yadav <77043443+karanBRAVO@users.noreply.github.com> Karthik Prakash <116057817+skoriop@users.noreply.github.com> Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com> Kavyansh-Bagdi <153486713+Kavyansh-Bagdi@users.noreply.github.com> From 8e6d16f2c34fbf891b2f7cd506fdc7d0e1e15820 Mon Sep 17 00:00:00 2001 From: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:19:08 -0700 Subject: [PATCH 05/16] test: add tests for IEEE 754-2019 compliance PR-URL: https://github.com/stdlib-js/stdlib/pull/6595 Ref: https://github.com/stdlib-js/stdlib/issues/365 Reviewed-by: Philipp Burckhardt --- .../@stdlib/math/base/special/asind/test/test.js | 14 ++++++++++++++ .../math/base/special/asind/test/test.native.js | 14 ++++++++++++++ .../@stdlib/math/base/special/asindf/test/test.js | 14 ++++++++++++++ .../math/base/special/asindf/test/test.native.js | 14 ++++++++++++++ .../@stdlib/math/base/special/asinf/test/test.js | 14 ++++++++++++++ .../math/base/special/asinf/test/test.native.js | 14 ++++++++++++++ 6 files changed, 84 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/special/asind/test/test.js b/lib/node_modules/@stdlib/math/base/special/asind/test/test.js index a3b4c2927e14..da2c323e19fa 100644 --- a/lib/node_modules/@stdlib/math/base/special/asind/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/asind/test/test.js @@ -25,6 +25,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var uniform = require( '@stdlib/random/base/uniform' ); var abs = require( '@stdlib/math/base/special/abs' ); var EPS = require( '@stdlib/constants/float64/eps' ); +var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var asind = require( './../lib' ); @@ -117,3 +119,15 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', functi } t.end(); }); + +tape( 'the function returns `-0` if provided `-0`', function test( t ) { + var v = asind( -0.0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var v = asind( 0.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/asind/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/asind/test/test.native.js index 1205b8543eb1..243613ba27cb 100644 --- a/lib/node_modules/@stdlib/math/base/special/asind/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/asind/test/test.native.js @@ -26,6 +26,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var uniform = require( '@stdlib/random/base/uniform' ); var abs = require( '@stdlib/math/base/special/abs' ); var EPS = require( '@stdlib/constants/float64/eps' ); +var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -126,3 +128,15 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', opts, } t.end(); }); + +tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { + var v = asind( -0.0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { + var v = asind( 0.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/asindf/test/test.js b/lib/node_modules/@stdlib/math/base/special/asindf/test/test.js index 0f4ae96e9757..0d69adcee8b9 100644 --- a/lib/node_modules/@stdlib/math/base/special/asindf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/asindf/test/test.js @@ -26,6 +26,8 @@ var uniform = require( '@stdlib/random/base/uniform' ); var abs = require( '@stdlib/math/base/special/abs' ); var EPS = require( '@stdlib/constants/float32/eps' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var asindf = require( './../lib' ); @@ -122,3 +124,15 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', functi } t.end(); }); + +tape( 'the function returns `-0` if provided `-0`', function test( t ) { + var v = asindf( -0.0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var v = asindf( 0.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/asindf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/asindf/test/test.native.js index 52f5e697d927..23f9d842b937 100644 --- a/lib/node_modules/@stdlib/math/base/special/asindf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/asindf/test/test.native.js @@ -27,6 +27,8 @@ var uniform = require( '@stdlib/random/base/uniform' ); var abs = require( '@stdlib/math/base/special/abs' ); var EPS = require( '@stdlib/constants/float32/eps' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -131,3 +133,15 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', opts, } t.end(); }); + +tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { + var v = asindf( -0.0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { + var v = asindf( 0.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/asinf/test/test.js b/lib/node_modules/@stdlib/math/base/special/asinf/test/test.js index b3716537db79..ab81b4613c5c 100644 --- a/lib/node_modules/@stdlib/math/base/special/asinf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/asinf/test/test.js @@ -26,6 +26,8 @@ var EPS = require( '@stdlib/constants/float32/eps' ); var uniform = require( '@stdlib/random/base/uniform' ); var abs = require( '@stdlib/math/base/special/abs' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var asinf = require( './../lib' ); @@ -149,3 +151,15 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', functi } t.end(); }); + +tape( 'the function returns `-0` if provided `-0`', function test( t ) { + var v = asinf( -0.0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var v = asinf( 0.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/asinf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/asinf/test/test.native.js index 0ca21b086340..03aa94bf5cc0 100644 --- a/lib/node_modules/@stdlib/math/base/special/asinf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/asinf/test/test.native.js @@ -27,6 +27,8 @@ var EPS = require( '@stdlib/constants/float32/eps' ); var uniform = require( '@stdlib/random/base/uniform' ); var abs = require( '@stdlib/math/base/special/abs' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -158,3 +160,15 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', opts, } t.end(); }); + +tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { + var v = asinf( -0.0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { + var v = asinf( 0.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + t.end(); +}); From 262c80be5503ef0ce72c0fa6f9267b08d013ba15 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Tue, 8 Apr 2025 23:29:49 -0400 Subject: [PATCH 06/16] docs: update REPL namespace documentation PR-URL: https://github.com/stdlib-js/stdlib/pull/6591 Reviewed-by: Athan Reines --- lib/node_modules/@stdlib/repl/data/contributor.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/repl/data/contributor.json b/lib/node_modules/@stdlib/repl/data/contributor.json index 83164a92a821..66e03e6b948c 100644 --- a/lib/node_modules/@stdlib/repl/data/contributor.json +++ b/lib/node_modules/@stdlib/repl/data/contributor.json @@ -1 +1 @@ -["Aadish Jain","Aarya Balwadkar","Aayush Khanna","Abdelrahman Samir","Abdul Kaium","Abhay Punia","Abhijit Raut","Abhishek Jain","Adarsh Palaskar","Aditya Sapra","Ahmed Atwa","Ahmed Kashkoush","Ahmed Khaled","Aksshay Balasubramanian","Aleksandr","Ali Salesi","AlyAbdelmoneim","Aman Bhansali","AmanBhadkariya","Amit Jimiwal","Anshu Kumar","Anshu Kumar","Anudeep Sanapala","Athan Reines","Ayaka","Bhavishy Agrawal","Brendan Graetz","Bruno Fenzl","Bryan Elee","Chinmay Joshi","Christopher Dambamuromo","Dan Rose","Daniel Killenberger","Daniel Yu","Debashis Maharana","Deep Trivedi","Desh Deepak Kant","Dev Goel","Dhanyabad behera","Dhruv Arvind Singh","Dhruvil Mehta","Divyansh Seth","Dominic Lim","Dominik Moritz","Dorrin Sotoudeh","EuniceSim142","Frank Kovacs","GK Bishnoi","Gaurav","Gautam sharma","Golden Kumar","Gunj Joshi","Gururaj Gurram","Haroon Rasheed","Harsh","HarshaNP","Harshita Kalani","Hemant M Mehta","Hridyanshu","Jaimin Godhani","Jaison D Souza","Jalaj Kumar","James Gelok","Jay Soni","Jaysukh Makvana","Jenish Thapa","Jithin KS","Joel Mathew Koshy","Joey Reed","Jordan Gallivan","Joris Labie","Justin Dennison","Justyn Shelby","Karan Anand","Karthik Prakash","Kaushikgtm","Kavyansh-Bagdi","Kohantika Nath","Krishnam Agarwal","Krishnendu Das","Kshitij-Dale","Lovelin Dhoni J B","MANI","Manik Sharma","Manvith M","Marcus Fantham","Matt Cochrane","Mihir Pandit","Milan Raj","Mohammad Bin Aftab","Mohammad Kaif","Momtchil Momtchev","Muhammad Haris","Muhammad Taaha Tariq","Muhmmad Saad","Naresh Jagadeesan","Naveen Kumar","Neeraj Pathak","NirvedMishra","Nishant Shinde","Nishchay Rajput","Nithin Katta","Nourhan Hasan","Ognjen Jevremović","Oneday12323","Ori Miles","Philipp Burckhardt","Prajjwal Bajpai","Prajwal Kulkarni","Pranav Goswami","Pranjal Jha","Prashant Kumar Yadav","Pratik Singh","Pratyush Kumar Chouhan","Priyansh Prajapati","Priyanshu Agarwal","Pulkit Gupta","Pushpendra Chandravanshi","Rahul Kumar","Raunak Kumar Gupta","Rejoan Sardar","Ricky Reusser","Ridam Garg","Rishav","Rishav Tarway","Robert Gislason","Roman Stetsyk","Rupa","Rutam Kathale","Ruthwik Chikoti","Ryan Seal","Rylan Yang","SAHIL KUMAR","SHIVAM YADAV","Sahil Goyal","Sai Avinash","Sai Srikar Dumpeti","Sanchay Ketan Sinha","Sarthak Paandey","Saurabh Singh","Seyyed Parsa Neshaei","Shabareesh Shetty","Shashank Shekhar Singh","Shivam Ahir","Shraddheya Shendre","Shubh Mehta","Shubham Mishra","Sivam Das","Snehil Shah","Soumajit Chatterjee","Spandan Barve","Stephannie Jiménez Gacha","Suhaib Ilahi","Suraj Kumar","Tanishq Ahuja","Tirtadwipa Manunggal","Tudor Pagu","Tufailahmed Bargir","Utkarsh","Utkarsh Raj","UtkershBasnet","Vaibhav Patel","Varad Gupta","Vinit Pandit","Vivek Maurya","Xiaochuan Ye","Yaswanth Kosuru","Yernar Yergaziyev","Yugal Kaushik","Yuvi Mittal","ditsu","ekambains","fadiothman22","lohithganni","olenkabilonizhka","pranav-1720","rahulrangers","rainn","rei2hu"] +["Aadish Jain","Aarya Balwadkar","Aayush Khanna","Abdelrahman Samir","Abdul Kaium","Abhay Punia","Abhijit Raut","Abhishek Jain","Adarsh Palaskar","Aditya Sapra","Ahmed Atwa","Ahmed Kashkoush","Ahmed Khaled","Aksshay Balasubramanian","Aleksandr","Ali Salesi","AlyAbdelmoneim","Aman Bhansali","AmanBhadkariya","Amit Jimiwal","Anshu Kumar","Anshu Kumar","Anudeep Sanapala","Athan Reines","Ayaka","Bhavishy Agrawal","Brendan Graetz","Bruno Fenzl","Bryan Elee","Chinmay Joshi","Christopher Dambamuromo","Dan Rose","Daniel Killenberger","Daniel Yu","Debashis Maharana","Deep Trivedi","Desh Deepak Kant","Dev Goel","Dhanyabad behera","Dhruv Arvind Singh","Dhruvil Mehta","Dipjyoti Das","Divyansh Seth","Dominic Lim","Dominik Moritz","Dorrin Sotoudeh","EuniceSim142","Frank Kovacs","GK Bishnoi","Gaurav","Gautam sharma","Golden Kumar","Gunj Joshi","Gururaj Gurram","Haroon Rasheed","Harsh","HarshaNP","Harshita Kalani","Hemant M Mehta","Hridyanshu","Jaimin Godhani","Jaison D Souza","Jalaj Kumar","James Gelok","Jay Soni","Jaysukh Makvana","Jenish Thapa","Jithin KS","Joel Mathew Koshy","Joey Reed","Jordan Gallivan","Joris Labie","Justin Dennison","Justyn Shelby","Karan Anand","Karan Yadav","Karthik Prakash","Kaushikgtm","Kavyansh-Bagdi","Kohantika Nath","Krishnam Agarwal","Krishnendu Das","Kshitij-Dale","Lovelin Dhoni J B","MANI","Manik Sharma","Manvith M","Marcus Fantham","Matt Cochrane","Mihir Pandit","Milan Raj","Mohammad Bin Aftab","Mohammad Kaif","Momtchil Momtchev","Muhammad Haris","Muhammad Taaha Tariq","Muhmmad Saad","Naresh Jagadeesan","Naveen Kumar","Neeraj Pathak","NirvedMishra","Nishant Shinde","Nishchay Rajput","Nithin Katta","Nourhan Hasan","Ognjen Jevremović","Oneday12323","Ori Miles","Philipp Burckhardt","Prajjwal Bajpai","Prajwal Kulkarni","Pranav Goswami","Pranjal Jha","Prashant Kumar Yadav","PrathamBhamare","Pratik Singh","Pratyush Kumar Chouhan","Priyansh Prajapati","Priyanshu Agarwal","Pulkit Gupta","Pushpendra Chandravanshi","Rahul Kumar","Raunak Kumar Gupta","Rejoan Sardar","Ricky Reusser","Ridam Garg","Rishav","Rishav Tarway","Robert Gislason","Roman Stetsyk","Rupa","Rutam Kathale","Ruthwik Chikoti","Ryan Seal","Rylan Yang","SAHIL KUMAR","SHIVAM YADAV","Sahil Goyal","Sai Avinash","Sai Srikar Dumpeti","Sanchay Ketan Sinha","Sarthak Paandey","Saurabh Singh","Seyyed Parsa Neshaei","Shabareesh Shetty","Shashank Shekhar Singh","Shivam Ahir","Shraddheya Shendre","Shubh Mehta","Shubham Mishra","Sivam Das","Snehil Shah","Soumajit Chatterjee","Spandan Barve","Stephannie Jiménez Gacha","Suhaib Ilahi","Suraj Kumar","Tanishq Ahuja","Tirtadwipa Manunggal","Tudor Pagu","Tufailahmed Bargir","Utkarsh","Utkarsh Raj","UtkershBasnet","Vaibhav Patel","Varad Gupta","Vinit Pandit","Vivek Maurya","Xiaochuan Ye","Yaswanth Kosuru","Yernar Yergaziyev","Yugal Kaushik","Yuvi Mittal","ditsu","ekambains","fadiothman22","lohithganni","olenkabilonizhka","pranav-1720","rahulrangers","rainn","rei2hu"] From f33351a8e4a9e1cb8a36cad61c125843f64d1aeb Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Tue, 8 Apr 2025 23:30:21 -0400 Subject: [PATCH 07/16] docs: update related packages sections PR-URL: https://github.com/stdlib-js/stdlib/pull/6617 Reviewed-by: Athan Reines --- lib/node_modules/@stdlib/math/base/special/sincospi/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/sincospi/README.md b/lib/node_modules/@stdlib/math/base/special/sincospi/README.md index 80887205249a..06adafc353f9 100644 --- a/lib/node_modules/@stdlib/math/base/special/sincospi/README.md +++ b/lib/node_modules/@stdlib/math/base/special/sincospi/README.md @@ -189,7 +189,7 @@ int main( void ) { ## See Also - [`@stdlib/math/base/special/cospi`][@stdlib/math/base/special/cospi]: compute cos(πx). -- [`@stdlib/math/base/special/sincos`][@stdlib/math/base/special/sincos]: simultaneously compute the sine and cosine of a number. +- [`@stdlib/math/base/special/sincos`][@stdlib/math/base/special/sincos]: simultaneously compute the sine and cosine of an angle measured in radians. - [`@stdlib/math/base/special/sinpi`][@stdlib/math/base/special/sinpi]: compute sin(πx). From d31fbf29e925f9ae64bec1ac0fe19b17be265612 Mon Sep 17 00:00:00 2001 From: Harsh <149176984+hrshya@users.noreply.github.com> Date: Wed, 9 Apr 2025 09:03:01 +0530 Subject: [PATCH 08/16] docs: replace manual `for` loop in examples PR-URL: https://github.com/stdlib-js/stdlib/pull/6612 Reviewed-by: Athan Reines --- .../@stdlib/math/base/special/cosm1/README.md | 13 +++++++------ .../math/base/special/cosm1/examples/index.js | 13 +++++++------ .../@stdlib/math/base/special/cospi/README.md | 13 +++++++------ .../math/base/special/cospi/examples/index.js | 13 +++++++------ .../@stdlib/math/base/special/cot/README.md | 13 +++++++------ .../@stdlib/math/base/special/cot/examples/index.js | 13 +++++++------ .../@stdlib/math/base/special/cotd/README.md | 13 +++++++------ .../math/base/special/cotd/examples/index.js | 13 +++++++------ .../@stdlib/math/base/special/coth/README.md | 13 +++++++------ .../math/base/special/coth/examples/index.js | 13 +++++++------ 10 files changed, 70 insertions(+), 60 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cosm1/README.md b/lib/node_modules/@stdlib/math/base/special/cosm1/README.md index e958e18d4c3e..200f79b7ad85 100644 --- a/lib/node_modules/@stdlib/math/base/special/cosm1/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cosm1/README.md @@ -61,16 +61,17 @@ v = cosm1( NaN ); ```javascript -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var PI = require( '@stdlib/constants/float64/pi' ); var cosm1 = require( '@stdlib/math/base/special/cosm1' ); -var x = linspace( 0.0, 2.0*PI, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, 0.0, 2.0*PI, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( cosm1( x[ i ] ) ); -} +logEachMap( 'cos(%0.4f) - 1 = %0.4f', x, cosm1 ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/cosm1/examples/index.js b/lib/node_modules/@stdlib/math/base/special/cosm1/examples/index.js index e21ac10f8689..8d00eaece73f 100644 --- a/lib/node_modules/@stdlib/math/base/special/cosm1/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/cosm1/examples/index.js @@ -18,13 +18,14 @@ 'use strict'; -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var PI = require( '@stdlib/constants/float64/pi' ); var cosm1 = require( './../lib' ); -var x = linspace( 0.0, 2.0*PI, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, 0.0, 2.0*PI, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( 'cos(%d) - 1 = %d', x[ i ], cosm1( x[ i ] ) ); -} +logEachMap( 'cos(%0.4f) - 1 = %0.4f', x, cosm1 ); diff --git a/lib/node_modules/@stdlib/math/base/special/cospi/README.md b/lib/node_modules/@stdlib/math/base/special/cospi/README.md index ee4799f30f52..45e09dd1aa80 100644 --- a/lib/node_modules/@stdlib/math/base/special/cospi/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cospi/README.md @@ -59,15 +59,16 @@ y = cospi( NaN ); ```javascript -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cospi = require( '@stdlib/math/base/special/cospi' ); -var x = linspace( -100.0, 100.0, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -100.0, 100.0, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( cospi( x[ i ] ) ); -} +logEachMap( 'cos( π * %0.4f ) = %0.4f', x, cospi ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/cospi/examples/index.js b/lib/node_modules/@stdlib/math/base/special/cospi/examples/index.js index 1be10bbed7e4..ac88304fa1a1 100644 --- a/lib/node_modules/@stdlib/math/base/special/cospi/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/cospi/examples/index.js @@ -18,12 +18,13 @@ 'use strict'; -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cospi = require( './../lib' ); -var x = linspace( -100.0, 100.0, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -100.0, 100.0, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( 'cos( π * %d ) = %d', x[ i ], cospi( x[ i ] ) ); -} +logEachMap( 'cos( π * %0.4f ) = %0.4f', x, cospi ); diff --git a/lib/node_modules/@stdlib/math/base/special/cot/README.md b/lib/node_modules/@stdlib/math/base/special/cot/README.md index cb710799146a..023d258d622c 100644 --- a/lib/node_modules/@stdlib/math/base/special/cot/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cot/README.md @@ -66,16 +66,17 @@ v = cot( NaN ); ```javascript -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var PI = require( '@stdlib/constants/float64/pi' ); var cot = require( '@stdlib/math/base/special/cot' ); -var x = linspace( -PI/2.0, PI/2.0, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -PI/2.0, PI/2.0, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( cot( x[ i ] ) ); -} +logEachMap( 'cot(%0.4f) = %0.4f', x, cot ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/cot/examples/index.js b/lib/node_modules/@stdlib/math/base/special/cot/examples/index.js index 87dea3f5ccc9..e71fa6d5f1c6 100644 --- a/lib/node_modules/@stdlib/math/base/special/cot/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/cot/examples/index.js @@ -18,13 +18,14 @@ 'use strict'; -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var PI = require( '@stdlib/constants/float64/pi' ); var cot = require( './../lib' ); -var x = linspace( -PI, PI, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -PI/2.0, PI/2.0, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( 'cot(%d) = %d', x[ i ], cot( x[ i ] ) ); -} +logEachMap( 'cot(%0.4f) = %0.4f', x, cot ); diff --git a/lib/node_modules/@stdlib/math/base/special/cotd/README.md b/lib/node_modules/@stdlib/math/base/special/cotd/README.md index f7d9201c3bb9..35831810d23d 100644 --- a/lib/node_modules/@stdlib/math/base/special/cotd/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cotd/README.md @@ -63,15 +63,16 @@ v = cotd( NaN ); ```javascript -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cotd = require( '@stdlib/math/base/special/cotd' ); -var x = linspace( -180, 180, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -180.0, 180.0, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( cotd( x[ i ] ) ); -} +logEachMap( 'cotd(%0.4f) = %0.4f', x, cotd ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/cotd/examples/index.js b/lib/node_modules/@stdlib/math/base/special/cotd/examples/index.js index 196b00701217..a77f5d7e9d39 100644 --- a/lib/node_modules/@stdlib/math/base/special/cotd/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/cotd/examples/index.js @@ -18,12 +18,13 @@ 'use strict'; -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cotd = require( './../lib' ); -var x = linspace( -180, 180, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -180.0, 180.0, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( 'cotd(%d) = %d', x[ i ], cotd( x[ i ] ) ); -} +logEachMap( 'cotd(%0.4f) = %0.4f', x, cotd ); diff --git a/lib/node_modules/@stdlib/math/base/special/coth/README.md b/lib/node_modules/@stdlib/math/base/special/coth/README.md index 9eb1a8b104fd..188a9adc0cd0 100644 --- a/lib/node_modules/@stdlib/math/base/special/coth/README.md +++ b/lib/node_modules/@stdlib/math/base/special/coth/README.md @@ -59,15 +59,16 @@ v = coth( NaN ); ```javascript -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var coth = require( '@stdlib/math/base/special/coth' ); -var x = linspace( -10.0, 10.0, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -10.0, 10.0, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( coth( x[ i ] ) ); -} +logEachMap( 'coth(%0.4f) = %0.4f', x, coth ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/coth/examples/index.js b/lib/node_modules/@stdlib/math/base/special/coth/examples/index.js index e329150fb00f..77502c68a122 100644 --- a/lib/node_modules/@stdlib/math/base/special/coth/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/coth/examples/index.js @@ -18,12 +18,13 @@ 'use strict'; -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var coth = require( './../lib' ); -var x = linspace( -10.0, 10.0, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -10.0, 10.0, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( 'coth(%d) = %d', x[ i ], coth( x[ i ] ) ); -} +logEachMap( 'coth(%0.4f) = %0.4f', x, coth ); From 484bcb1db84b0f3ddd216fe35389a773706caee4 Mon Sep 17 00:00:00 2001 From: Harsh <149176984+hrshya@users.noreply.github.com> Date: Wed, 9 Apr 2025 09:30:48 +0530 Subject: [PATCH 09/16] docs: replace manual `for` loop in examples PR-URL: https://github.com/stdlib-js/stdlib/pull/6611 Reviewed-by: Athan Reines --- .../math/base/special/copysign/README.md | 19 ++++++++----------- .../base/special/copysign/examples/index.js | 19 ++++++++----------- .../math/base/special/copysignf/README.md | 19 ++++++++----------- .../base/special/copysignf/examples/index.js | 19 ++++++++----------- .../@stdlib/math/base/special/cos/README.md | 13 +++++++------ .../math/base/special/cos/examples/index.js | 13 +++++++------ .../@stdlib/math/base/special/cosd/README.md | 13 +++++++------ .../math/base/special/cosd/examples/index.js | 13 +++++++------ .../@stdlib/math/base/special/cosh/README.md | 13 +++++++------ .../math/base/special/cosh/examples/index.js | 13 +++++++------ 10 files changed, 74 insertions(+), 80 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/copysign/README.md b/lib/node_modules/@stdlib/math/base/special/copysign/README.md index 9cba72585a3b..8f574b9a45c8 100644 --- a/lib/node_modules/@stdlib/math/base/special/copysign/README.md +++ b/lib/node_modules/@stdlib/math/base/special/copysign/README.md @@ -72,21 +72,18 @@ z = copysign( -0.0, 1.0 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var copysign = require( '@stdlib/math/base/special/copysign' ); -var x; -var y; -var z; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); +var y = uniform( 100, -5.0, 5.0, opts ); // Generate random double-precision floating-point numbers `x` and `y` and copy the sign of `y` to `x`... -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - y = (randu()*10.0) - 5.0; - z = copysign( x, y ); - console.log( 'x: %d, y: %d => %d', x, y, z ); -} +logEachMap( 'x: %0.4f, y: %0.4f => %0.4f', x, y, copysign ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/copysign/examples/index.js b/lib/node_modules/@stdlib/math/base/special/copysign/examples/index.js index a752e5139467..4318e88b7a90 100644 --- a/lib/node_modules/@stdlib/math/base/special/copysign/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/copysign/examples/index.js @@ -18,18 +18,15 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var copysign = require( './../lib' ); -var x; -var y; -var z; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); +var y = uniform( 100, -5.0, 5.0, opts ); // Generate random double-precision floating-point numbers `x` and `y` and copy the sign of `y` to `x`... -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - y = (randu()*10.0) - 5.0; - z = copysign( x, y ); - console.log( 'x: %d, y: %d => %d', x, y, z ); -} +logEachMap( 'x: %0.4f, y: %0.4f => %0.4f', x, y, copysign ); diff --git a/lib/node_modules/@stdlib/math/base/special/copysignf/README.md b/lib/node_modules/@stdlib/math/base/special/copysignf/README.md index 040248563f6e..e623fd31548f 100644 --- a/lib/node_modules/@stdlib/math/base/special/copysignf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/copysignf/README.md @@ -72,21 +72,18 @@ z = copysignf( -0.0, 1.0 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var copysignf = require( '@stdlib/math/base/special/copysignf' ); -var x; -var y; -var z; -var i; +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -50.0, 50.0, opts ); +var y = uniform( 100, -5.0, 5.0, opts ); // Generate random numbers `x` and `y` and copy the sign of `y` to `x`... -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - y = (randu()*10.0) - 5.0; - z = copysignf( x, y ); - console.log( 'x: %d, y: %d => %d', x, y, z ); -} +logEachMap( 'x: %0.4f, y: %0.4f => %0.4f', x, y, copysignf ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/copysignf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/copysignf/examples/index.js index d1c28fa1a771..9758df4ddb19 100644 --- a/lib/node_modules/@stdlib/math/base/special/copysignf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/copysignf/examples/index.js @@ -18,18 +18,15 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var copysignf = require( './../lib' ); -var x; -var y; -var z; -var i; +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -50.0, 50.0, opts ); +var y = uniform( 100, -5.0, 5.0, opts ); // Generate random numbers `x` and `y` and copy the sign of `y` to `x`... -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - y = (randu()*10.0) - 5.0; - z = copysignf( x, y ); - console.log( 'x: %d, y: %d => %d', x, y, z ); -} +logEachMap( 'x: %0.4f, y: %0.4f => %0.4f', x, y, copysignf ); diff --git a/lib/node_modules/@stdlib/math/base/special/cos/README.md b/lib/node_modules/@stdlib/math/base/special/cos/README.md index d0abf8af4039..7b42e9c49373 100644 --- a/lib/node_modules/@stdlib/math/base/special/cos/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cos/README.md @@ -59,16 +59,17 @@ v = cos( NaN ); ```javascript -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var TWO_PI = require( '@stdlib/constants/float64/two-pi' ); var cos = require( '@stdlib/math/base/special/cos' ); -var x = linspace( 0.0, TWO_PI, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, 0.0, TWO_PI, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( cos( x[ i ] ) ); -} +logEachMap( 'cos(%0.4f) = %0.4f', x, cos ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/cos/examples/index.js b/lib/node_modules/@stdlib/math/base/special/cos/examples/index.js index 293006402478..1732dfc8eb9e 100644 --- a/lib/node_modules/@stdlib/math/base/special/cos/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/cos/examples/index.js @@ -18,13 +18,14 @@ 'use strict'; -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var TWO_PI = require( '@stdlib/constants/float64/two-pi' ); var cos = require( './../lib' ); -var x = linspace( 0.0, TWO_PI, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, 0.0, TWO_PI, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( 'cos(%d) = %d', x[ i ], cos( x[ i ] ) ); -} +logEachMap( 'cos(%0.4f) = %0.4f', x, cos ); diff --git a/lib/node_modules/@stdlib/math/base/special/cosd/README.md b/lib/node_modules/@stdlib/math/base/special/cosd/README.md index d2663660456f..5374b68a8355 100644 --- a/lib/node_modules/@stdlib/math/base/special/cosd/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cosd/README.md @@ -63,15 +63,16 @@ v = cosd( NaN ); ```javascript -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cosd = require( '@stdlib/math/base/special/cosd' ); -var x = linspace( -180, 180, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -180, 180, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( cosd( x[ i ] ) ); -} +logEachMap( 'cosd(%0.4f) = %0.4f', x, cosd ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/cosd/examples/index.js b/lib/node_modules/@stdlib/math/base/special/cosd/examples/index.js index 2684fa18be4a..53aa4f225931 100644 --- a/lib/node_modules/@stdlib/math/base/special/cosd/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/cosd/examples/index.js @@ -18,12 +18,13 @@ 'use strict'; -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cosd = require( './../lib' ); -var x = linspace( -180, 180, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -180.0, 180.0, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( 'cosd(%d) = %d', x[ i ], cosd( x[ i ] ) ); -} +logEachMap( 'cosd(%0.4f) = %0.4f', x, cosd ); diff --git a/lib/node_modules/@stdlib/math/base/special/cosh/README.md b/lib/node_modules/@stdlib/math/base/special/cosh/README.md index e0d222d6e260..26eb5d368587 100644 --- a/lib/node_modules/@stdlib/math/base/special/cosh/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cosh/README.md @@ -62,15 +62,16 @@ v = cosh( NaN ); ```javascript -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cosh = require( '@stdlib/math/base/special/cosh' ); -var x = linspace( -5.0, 5.0, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -5.0, 5.0, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( cosh( x[ i ] ) ); -} +logEachMap( 'cosh(%0.4f) = %0.4f', x, cosh ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/cosh/examples/index.js b/lib/node_modules/@stdlib/math/base/special/cosh/examples/index.js index 146f25af25fa..a9cbf49a73bf 100644 --- a/lib/node_modules/@stdlib/math/base/special/cosh/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/cosh/examples/index.js @@ -18,12 +18,13 @@ 'use strict'; -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cosh = require( './../lib' ); -var x = linspace( -5.0, 5.0, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -5.0, 5.0, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( 'cosh(%d) = %d', x[ i ], cosh( x[ i ] ) ); -} +logEachMap( 'cosh(%0.4f) = %0.4f', x, cosh ); From 79ba3b49cd4356627aa4609eb3e566ec174faa4a Mon Sep 17 00:00:00 2001 From: Harsh <149176984+hrshya@users.noreply.github.com> Date: Wed, 9 Apr 2025 09:38:49 +0530 Subject: [PATCH 10/16] docs: replace manual `for` loop in examples PR-URL: https://github.com/stdlib-js/stdlib/pull/6607 Reviewed-by: Athan Reines --- .../@stdlib/math/base/special/cbrt/README.md | 14 +++++++------- .../math/base/special/cbrt/examples/index.js | 14 +++++++------- .../@stdlib/math/base/special/cbrtf/README.md | 14 +++++++------- .../math/base/special/cbrtf/examples/index.js | 14 +++++++------- .../@stdlib/math/base/special/ceil/README.md | 14 +++++++------- .../math/base/special/ceil/examples/index.js | 14 +++++++------- .../@stdlib/math/base/special/ceilf/README.md | 14 +++++++------- .../math/base/special/ceilf/examples/index.js | 14 +++++++------- 8 files changed, 56 insertions(+), 56 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cbrt/README.md b/lib/node_modules/@stdlib/math/base/special/cbrt/README.md index 9ea5db243a15..07232414ee46 100644 --- a/lib/node_modules/@stdlib/math/base/special/cbrt/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cbrt/README.md @@ -65,16 +65,16 @@ v = cbrt( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cbrt = require( '@stdlib/math/base/special/cbrt' ); -var x; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -100.0, 100.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*200.0) - 100.0; - console.log( 'cbrt(%d) = %d', x, cbrt( x ) ); -} +logEachMap( 'cbrt(%0.4f) = %0.4f', x, cbrt ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/cbrt/examples/index.js b/lib/node_modules/@stdlib/math/base/special/cbrt/examples/index.js index e50e06dde35d..8564b11af309 100644 --- a/lib/node_modules/@stdlib/math/base/special/cbrt/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/cbrt/examples/index.js @@ -18,13 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cbrt = require( './../lib' ); -var x; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -100.0, 100.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*200.0) - 100.0; - console.log( 'cbrt(%d) = %d', x, cbrt( x ) ); -} +logEachMap( 'cbrt(%0.4f) = %0.4f', x, cbrt ); diff --git a/lib/node_modules/@stdlib/math/base/special/cbrtf/README.md b/lib/node_modules/@stdlib/math/base/special/cbrtf/README.md index 9c3789627d5b..cdc81a512ab4 100644 --- a/lib/node_modules/@stdlib/math/base/special/cbrtf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cbrtf/README.md @@ -65,16 +65,16 @@ v = cbrtf( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cbrtf = require( '@stdlib/math/base/special/cbrtf' ); -var x; -var i; +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -100.0, 100.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*200.0) - 100.0; - console.log( 'cbrt(%d) = %d', x, cbrtf( x ) ); -} +logEachMap( 'cbrt(%0.4f) = %0.4f', x, cbrtf ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/cbrtf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/cbrtf/examples/index.js index 4d002eccdd7f..840a078a3ff6 100644 --- a/lib/node_modules/@stdlib/math/base/special/cbrtf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/cbrtf/examples/index.js @@ -18,13 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var cbrtf = require( './../lib' ); -var x; -var i; +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -100.0, 100.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*200.0) - 100.0; - console.log( 'cbrt(%d) = %d', x, cbrtf( x ) ); -} +logEachMap( 'cbrt(%0.4f) = %0.4f', x, cbrtf ); diff --git a/lib/node_modules/@stdlib/math/base/special/ceil/README.md b/lib/node_modules/@stdlib/math/base/special/ceil/README.md index a05b90c5d67f..3efaa939ac4e 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceil/README.md +++ b/lib/node_modules/@stdlib/math/base/special/ceil/README.md @@ -59,16 +59,16 @@ v = ceil( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var ceil = require( '@stdlib/math/base/special/ceil' ); -var x; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - console.log( 'ceil(%d) = %d', x, ceil( x ) ); -} +logEachMap( 'ceil(%0.4f) = %0.4f', x, ceil ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/ceil/examples/index.js b/lib/node_modules/@stdlib/math/base/special/ceil/examples/index.js index 9311890f8b21..9cc739df51a8 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceil/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/ceil/examples/index.js @@ -18,13 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var ceil = require( './../lib' ); -var x; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - console.log( 'ceil(%d) = %d', x, ceil( x ) ); -} +logEachMap( 'ceil(%0.4f) = %0.4f', x, ceil ); diff --git a/lib/node_modules/@stdlib/math/base/special/ceilf/README.md b/lib/node_modules/@stdlib/math/base/special/ceilf/README.md index 04164dc74507..6562c36127a9 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/ceilf/README.md @@ -59,16 +59,16 @@ v = ceilf( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var ceilf = require( '@stdlib/math/base/special/ceilf' ); -var x; -var i; +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - console.log( 'ceilf(%d) = %d', x, ceilf( x ) ); -} +logEachMap( 'ceilf(%0.4f) = %0.4f', x, ceilf ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/ceilf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/ceilf/examples/index.js index 6b03e6a04962..4b29773d2984 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilf/examples/index.js @@ -18,13 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var ceilf = require( './../lib' ); -var x; -var i; +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - console.log( 'ceilf(%d) = %d', x, ceilf( x ) ); -} +logEachMap( 'ceilf(%0.4f) = %0.4f', x, ceilf ); From 97d8fd3b3abdc28215328ee49db8c079097b4b41 Mon Sep 17 00:00:00 2001 From: Harsh <149176984+hrshya@users.noreply.github.com> Date: Wed, 9 Apr 2025 09:41:28 +0530 Subject: [PATCH 11/16] docs: replace manual `for` loop in examples PR-URL: https://github.com/stdlib-js/stdlib/pull/6608 Co-authored-by: Athan Reines Reviewed-by: Athan Reines Signed-off-by: Athan Reines --- .../math/base/special/ceil10/README.md | 16 +++++++-------- .../base/special/ceil10/examples/index.js | 16 +++++++-------- .../@stdlib/math/base/special/ceil2/README.md | 16 +++++++-------- .../math/base/special/ceil2/examples/index.js | 16 +++++++-------- .../math/base/special/ceilsd/README.md | 16 +++++++-------- .../base/special/ceilsd/examples/index.js | 16 +++++++-------- .../@stdlib/math/base/special/clamp/README.md | 20 +++++++++---------- .../math/base/special/clamp/examples/index.js | 20 +++++++++---------- .../math/base/special/clampf/README.md | 20 +++++++++---------- .../base/special/clampf/examples/index.js | 20 +++++++++---------- 10 files changed, 78 insertions(+), 98 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ceil10/README.md b/lib/node_modules/@stdlib/math/base/special/ceil10/README.md index 538ba1c3541c..a702a97f1635 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceil10/README.md +++ b/lib/node_modules/@stdlib/math/base/special/ceil10/README.md @@ -98,18 +98,16 @@ v = ceil10( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var ceil10 = require( '@stdlib/math/base/special/ceil10' ); -var x; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - v = ceil10( x ); - console.log( 'Value: %d. Rounded: %d.', x, v ); -} +logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, ceil10 ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/ceil10/examples/index.js b/lib/node_modules/@stdlib/math/base/special/ceil10/examples/index.js index 616433ed6f17..4aa0f9da13ff 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceil10/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/ceil10/examples/index.js @@ -18,15 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var ceil10 = require( './../lib' ); -var x; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - v = ceil10( x ); - console.log( 'x: %d. Rounded: %d.', x, v ); -} +logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, ceil10 ); diff --git a/lib/node_modules/@stdlib/math/base/special/ceil2/README.md b/lib/node_modules/@stdlib/math/base/special/ceil2/README.md index 8a4ccf519524..d4b9fe956e23 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceil2/README.md +++ b/lib/node_modules/@stdlib/math/base/special/ceil2/README.md @@ -83,18 +83,16 @@ v = ceil2( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var ceil2 = require( '@stdlib/math/base/special/ceil2' ); -var x; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - v = ceil2( x ); - console.log( 'Value: %d. Rounded: %d.', x, v ); -} +logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, ceil2 ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/ceil2/examples/index.js b/lib/node_modules/@stdlib/math/base/special/ceil2/examples/index.js index d37f2a7d3c09..f643937aa367 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceil2/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/ceil2/examples/index.js @@ -18,15 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var ceil2 = require( './../lib' ); -var x; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - v = ceil2( x ); - console.log( 'x: %d. Rounded: %d.', x, v ); -} +logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, ceil2 ); diff --git a/lib/node_modules/@stdlib/math/base/special/ceilsd/README.md b/lib/node_modules/@stdlib/math/base/special/ceilsd/README.md index 3a60c3bab29a..290cc248de47 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilsd/README.md +++ b/lib/node_modules/@stdlib/math/base/special/ceilsd/README.md @@ -65,18 +65,16 @@ v = ceilsd( 0.0313, 2, 2 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var ceilsd = require( '@stdlib/math/base/special/ceilsd' ); -var x; -var y; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -5000.0, 5000.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*10000.0) - 5000.0; - y = ceilsd( x, 5, 10 ); - console.log( 'x: %d. Rounded: %d.', x, y ); -} +logEachMap( 'x: %0.4f. y: %d. z: %d. Rounded: %0.4f.', x, 5, 10, ceilsd ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/ceilsd/examples/index.js b/lib/node_modules/@stdlib/math/base/special/ceilsd/examples/index.js index c963430fa476..d088d04e0d1e 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilsd/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilsd/examples/index.js @@ -18,15 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var ceilsd = require( './../lib' ); -var x; -var y; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -5000.0, 5000.0, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*10000.0) - 5000.0; - y = ceilsd( x, 5, 10 ); - console.log( 'x: %d. Rounded: %d.', x, y ); -} +logEachMap( 'x: %0.4f. y: %d. z: %d. Rounded: %0.4f.', x, 5, 10, ceilsd ); diff --git a/lib/node_modules/@stdlib/math/base/special/clamp/README.md b/lib/node_modules/@stdlib/math/base/special/clamp/README.md index a2fde4940bbe..ddd660b5d93e 100644 --- a/lib/node_modules/@stdlib/math/base/special/clamp/README.md +++ b/lib/node_modules/@stdlib/math/base/special/clamp/README.md @@ -95,20 +95,18 @@ v = clamp( 3.14, 0.0, NaN ); ```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var clamp = require( '@stdlib/math/base/special/clamp' ); -var min; -var max; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var min = discreteUniform( 100, 0, 10, opts ); +var max = discreteUniform( 100, 5, 15, opts ); +var v = discreteUniform( 100, -20, 20, opts ); -for ( i = 0; i < 100; i++ ) { - min = discreteUniform( 0.0, 10.0 ); - max = discreteUniform( 5.0, 15.0 ); - v = discreteUniform( -20.0, 20.0 ); - console.log( 'clamp(%d,%d,%d) => %d', v, min, max, clamp( v, min, max ) ); -} +logEachMap( 'clamp(%d,%d,%d) => %d', v, min, max, clamp ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/clamp/examples/index.js b/lib/node_modules/@stdlib/math/base/special/clamp/examples/index.js index 5cd50db98ca0..50989fc0d6cc 100644 --- a/lib/node_modules/@stdlib/math/base/special/clamp/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/clamp/examples/index.js @@ -18,17 +18,15 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var clamp = require( './../lib' ); -var min; -var max; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var min = discreteUniform( 100, 0, 10, opts ); +var max = discreteUniform( 100, 5, 15, opts ); +var v = discreteUniform( 100, -20, 20, opts ); -for ( i = 0; i < 100; i++ ) { - min = discreteUniform( 0.0, 10.0 ); - max = discreteUniform( 5.0, 15.0 ); - v = discreteUniform( -20.0, 20.0 ); - console.log( 'clamp(%d,%d,%d) => %d', v, min, max, clamp( v, min, max ) ); -} +logEachMap( 'clamp(%d,%d,%d) => %d', v, min, max, clamp ); diff --git a/lib/node_modules/@stdlib/math/base/special/clampf/README.md b/lib/node_modules/@stdlib/math/base/special/clampf/README.md index 6d106b3cb4f5..13fa954c468f 100644 --- a/lib/node_modules/@stdlib/math/base/special/clampf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/clampf/README.md @@ -95,20 +95,18 @@ v = clampf( 3.14, 0.0, NaN ); ```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var clampf = require( '@stdlib/math/base/special/clampf' ); -var min; -var max; -var v; -var i; +var opts = { + 'dtype': 'float32' +}; +var min = discreteUniform( 100, 0, 10, opts ); +var max = discreteUniform( 100, 5, 15, opts ); +var v = discreteUniform( 100, -20, 20, opts ); -for ( i = 0; i < 100; i++ ) { - min = discreteUniform( 0.0, 10.0 ); - max = discreteUniform( 5.0, 15.0 ); - v = discreteUniform( -20.0, 20.0 ); - console.log( 'clampf(%d,%d,%d) => %d', v, min, max, clampf( v, min, max ) ); -} +logEachMap( 'clampf(%d,%d,%d) => %d', v, min, max, clampf ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/clampf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/clampf/examples/index.js index 84b49bcc1dc0..2ab85bfad6a5 100644 --- a/lib/node_modules/@stdlib/math/base/special/clampf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/clampf/examples/index.js @@ -18,17 +18,15 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var clampf = require( './../lib' ); -var min; -var max; -var v; -var i; +var opts = { + 'dtype': 'float32' +}; +var min = discreteUniform( 100, 0, 10, opts ); +var max = discreteUniform( 100, 5, 15, opts ); +var v = discreteUniform( 100, -20, 20, opts ); -for ( i = 0; i < 100; i++ ) { - min = discreteUniform( 0.0, 10.0 ); - max = discreteUniform( 5.0, 15.0 ); - v = discreteUniform( -20.0, 20.0 ); - console.log( 'clampf(%d,%d,%d) => %d', v, min, max, clampf( v, min, max ) ); -} +logEachMap( 'clampf(%d,%d,%d) => %d', v, min, max, clampf ); From 58b9836eee1b584b89a20e2e4852ca5d76219e91 Mon Sep 17 00:00:00 2001 From: Harsh <149176984+hrshya@users.noreply.github.com> Date: Wed, 9 Apr 2025 09:44:41 +0530 Subject: [PATCH 12/16] docs: replace manual `for` loop in examples PR-URL: https://github.com/stdlib-js/stdlib/pull/6587 Reviewed-by: Athan Reines --- .../math/base/special/vercos/README.md | 13 ++++++------ .../base/special/vercos/examples/index.js | 13 ++++++------ .../math/base/special/versin/README.md | 13 ++++++------ .../base/special/versin/examples/index.js | 13 ++++++------ .../@stdlib/math/base/special/wrap/README.md | 20 +++++++++---------- .../math/base/special/wrap/examples/index.js | 20 +++++++++---------- 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/vercos/README.md b/lib/node_modules/@stdlib/math/base/special/vercos/README.md index 4513ae9d5db9..2f9f067cba96 100644 --- a/lib/node_modules/@stdlib/math/base/special/vercos/README.md +++ b/lib/node_modules/@stdlib/math/base/special/vercos/README.md @@ -77,16 +77,17 @@ v = vercos( -3.141592653589793/6.0 ); ```javascript -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var TWO_PI = require( '@stdlib/constants/float64/two-pi' ); var vercos = require( '@stdlib/math/base/special/vercos' ); -var x = linspace( 0.0, TWO_PI, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, 0.0, TWO_PI, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( vercos( x[ i ] ) ); -} +logEachMap( 'vercos(%0.4f) = %0.4f', x, vercos ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/vercos/examples/index.js b/lib/node_modules/@stdlib/math/base/special/vercos/examples/index.js index a52c4ab703b2..e975b845f0fc 100644 --- a/lib/node_modules/@stdlib/math/base/special/vercos/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/vercos/examples/index.js @@ -18,13 +18,14 @@ 'use strict'; -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var TWO_PI = require( '@stdlib/constants/float64/two-pi' ); var vercos = require( './../lib' ); -var x = linspace( 0.0, TWO_PI, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, 0.0, TWO_PI, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( 'vercos(%d) = %d', x[ i ], vercos( x[ i ] ) ); -} +logEachMap( 'vercos(%0.4f) = %0.4f', x, vercos ); diff --git a/lib/node_modules/@stdlib/math/base/special/versin/README.md b/lib/node_modules/@stdlib/math/base/special/versin/README.md index eda8c5d75290..174f202cbf41 100644 --- a/lib/node_modules/@stdlib/math/base/special/versin/README.md +++ b/lib/node_modules/@stdlib/math/base/special/versin/README.md @@ -77,16 +77,17 @@ v = versin( -3.141592653589793/6.0 ); ```javascript -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var TWO_PI = require( '@stdlib/constants/float64/two-pi' ); var versin = require( '@stdlib/math/base/special/versin' ); -var x = linspace( 0.0, TWO_PI, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, 0.0, TWO_PI, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( versin( x[ i ] ) ); -} +logEachMap( 'versin(%0.4f) = %0.4f', x, versin ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/versin/examples/index.js b/lib/node_modules/@stdlib/math/base/special/versin/examples/index.js index b951c38a121e..74976df24231 100644 --- a/lib/node_modules/@stdlib/math/base/special/versin/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/versin/examples/index.js @@ -18,13 +18,14 @@ 'use strict'; -var linspace = require( '@stdlib/array/base/linspace' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var TWO_PI = require( '@stdlib/constants/float64/two-pi' ); var versin = require( './../lib' ); -var x = linspace( 0.0, TWO_PI, 100 ); +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, 0.0, TWO_PI, opts ); -var i; -for ( i = 0; i < x.length; i++ ) { - console.log( 'versin(%d) = %d', x[ i ], versin( x[ i ] ) ); -} +logEachMap( 'versin(%0.4f) = %0.4f', x, versin ); diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/README.md b/lib/node_modules/@stdlib/math/base/special/wrap/README.md index 668ff8d7704f..116f97133fd8 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/README.md +++ b/lib/node_modules/@stdlib/math/base/special/wrap/README.md @@ -106,20 +106,18 @@ var v = wrap( 3.14, 3.0, 3.0 ); ```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var wrap = require( '@stdlib/math/base/special/wrap' ); -var min; -var max; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var min = discreteUniform( 100, 0, 10, opts ); +var max = discreteUniform( 100, 5, 15, opts ); +var v = discreteUniform( 100, -20, 20, opts ); -for ( i = 0; i < 100; i++ ) { - min = discreteUniform( 0.0, 10.0 ); - max = discreteUniform( 5.0, 15.0 ); - v = discreteUniform( -20.0, 20.0 ); - console.log( 'wrap(%d,%d,%d) => %d', v, min, max, wrap( v, min, max ) ); -} +logEachMap( 'wrap(%d,%d,%d) => %0.4f', v, min, max, wrap ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/examples/index.js b/lib/node_modules/@stdlib/math/base/special/wrap/examples/index.js index 9453f131a00b..efbdf4170506 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/wrap/examples/index.js @@ -18,17 +18,15 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var wrap = require( './../lib' ); -var min; -var max; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var min = discreteUniform( 100, 0, 10, opts ); +var max = discreteUniform( 100, 5, 15, opts ); +var v = discreteUniform( 100, -20, 20, opts ); -for ( i = 0; i < 100; i++ ) { - min = discreteUniform( 0.0, 10.0 ); - max = discreteUniform( 5.0, 15.0 ); - v = discreteUniform( -20.0, 20.0 ); - console.log( 'wrap(%d,%d,%d) => %d', v, min, max, wrap( v, min, max ) ); -} +logEachMap( 'wrap(%d,%d,%d) => %0.4f', v, min, max, wrap ); From 6df53761a10132f6e53a7d4daabcc4614524600b Mon Sep 17 00:00:00 2001 From: Mahfuza Humayra Mohona Date: Wed, 9 Apr 2025 10:15:47 +0600 Subject: [PATCH 13/16] chore: fix EditorConfig lint errors PR-URL: https://github.com/stdlib-js/stdlib/pull/6596 Closes: https://github.com/stdlib-js/stdlib/issues/6588 Co-authored-by: Athan Reines Reviewed-by: Athan Reines Signed-off-by: Mahfuza Humayra Mohona Signed-off-by: Athan Reines --- .../number/float64/reviver/docs/types/test.ts | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/number/float64/reviver/docs/types/test.ts b/lib/node_modules/@stdlib/number/float64/reviver/docs/types/test.ts index 9d1e7ca071ac..19e701b65d58 100644 --- a/lib/node_modules/@stdlib/number/float64/reviver/docs/types/test.ts +++ b/lib/node_modules/@stdlib/number/float64/reviver/docs/types/test.ts @@ -23,25 +23,25 @@ import reviveNumber = require( '../../lib/main' ); // The function revives a JSON-serialized number... { - const o = { - 'type': 'float64', - 'value': 'NaN' - }; - reviveNumber( 'key', o ); // $ExpectType any + const o = { + 'type': 'float64', + 'value': 'NaN' + }; + reviveNumber( 'key', o ); // $ExpectType any } // The compiler throws an error if the function is provided a first argument that is not a string or number... { - reviveNumber( true, 1 ); // $ExpectError - reviveNumber( false, 1 ); // $ExpectError - reviveNumber( null, 1 ); // $ExpectError - reviveNumber( undefined, 1 ); // $ExpectError - reviveNumber( [], 1 ); // $ExpectError - reviveNumber( {}, 1 ); // $ExpectError + reviveNumber( true, 1 ); // $ExpectError + reviveNumber( false, 1 ); // $ExpectError + reviveNumber( null, 1 ); // $ExpectError + reviveNumber( undefined, 1 ); // $ExpectError + reviveNumber( [], 1 ); // $ExpectError + reviveNumber( {}, 1 ); // $ExpectError } // The compiler throws an error if the function is provided insufficient arguments... { - reviveNumber(); // $ExpectError - reviveNumber( 'foo' ); // $ExpectError + reviveNumber(); // $ExpectError + reviveNumber( 'foo' ); // $ExpectError } From 7a51d81789d40c6fdb292d90cb3ecfd643e2b430 Mon Sep 17 00:00:00 2001 From: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Date: Tue, 8 Apr 2025 21:17:11 -0700 Subject: [PATCH 14/16] test: add tests for IEEE 754-2019 compliance PR-URL: https://github.com/stdlib-js/stdlib/pull/6597 Ref: https://github.com/stdlib-js/stdlib/issues/365 Reviewed-by: Athan Reines Signed-off-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> --- .../@stdlib/math/base/special/cosd/test/test.js | 12 ++++++++++++ .../math/base/special/cosd/test/test.native.js | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/special/cosd/test/test.js b/lib/node_modules/@stdlib/math/base/special/cosd/test/test.js index bb4a31ed9bc3..6e9affb0a345 100644 --- a/lib/node_modules/@stdlib/math/base/special/cosd/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cosd/test/test.js @@ -114,3 +114,15 @@ tape( 'if provided `90.0`, the function returns `0.0`', function test( t ) { t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); }); + +tape( 'the function returns `1` if provided `+-0`', function test( t ) { + var v; + + v = cosd( -0.0 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + v = cosd( +0.0 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/cosd/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cosd/test/test.native.js index 45e500584d46..49e355c87cb4 100644 --- a/lib/node_modules/@stdlib/math/base/special/cosd/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cosd/test/test.native.js @@ -123,3 +123,15 @@ tape( 'if provided `90.0`, the function returns `0.0`', opts, function test( t ) t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); }); + +tape( 'the function returns `1` if provided `+-0`', opts, function test( t ) { + var v; + + v = cosd( -0.0 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + v = cosd( +0.0 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); From e9cd399c14186c518a2e4ec40f1b50c637c93a19 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Wed, 9 Apr 2025 10:42:32 +0500 Subject: [PATCH 15/16] feat: add `array/base/reshape` PR-URL: https://github.com/stdlib-js/stdlib/pull/5639 Closes: https://github.com/stdlib-js/metr-issue-tracker/issues/20 Co-authored-by: Athan Reines Reviewed-by: Athan Reines Signed-off-by: Muhammad Haris Signed-off-by: Athan Reines --- .../@stdlib/array/base/reshape/README.md | 122 +++++ .../array/base/reshape/benchmark/benchmark.js | 206 ++++++++ .../@stdlib/array/base/reshape/docs/repl.txt | 35 ++ .../array/base/reshape/docs/types/index.d.ts | 55 +++ .../array/base/reshape/docs/types/test.ts | 97 ++++ .../array/base/reshape/examples/index.js | 43 ++ .../@stdlib/array/base/reshape/lib/index.js | 42 ++ .../@stdlib/array/base/reshape/lib/main.js | 94 ++++ .../@stdlib/array/base/reshape/package.json | 64 +++ .../@stdlib/array/base/reshape/test/test.js | 457 ++++++++++++++++++ 10 files changed, 1215 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/base/reshape/README.md create mode 100644 lib/node_modules/@stdlib/array/base/reshape/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/array/base/reshape/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/array/base/reshape/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/array/base/reshape/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/array/base/reshape/examples/index.js create mode 100644 lib/node_modules/@stdlib/array/base/reshape/lib/index.js create mode 100644 lib/node_modules/@stdlib/array/base/reshape/lib/main.js create mode 100644 lib/node_modules/@stdlib/array/base/reshape/package.json create mode 100644 lib/node_modules/@stdlib/array/base/reshape/test/test.js diff --git a/lib/node_modules/@stdlib/array/base/reshape/README.md b/lib/node_modules/@stdlib/array/base/reshape/README.md new file mode 100644 index 000000000000..e747f6cc0fc6 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/reshape/README.md @@ -0,0 +1,122 @@ + + +# reshape + +> Reshape a nested array into another nested array having a desired shape. + +
+ +## Usage + +```javascript +var reshape = require( '@stdlib/array/base/reshape' ); +``` + +#### reshape( x, fromShape, toShape, colexicographic ) + +Reshapes a nested array into another nested array having a desired shape. + +```javascript +var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; + +var out = reshape( x, [ 2, 3 ], [ 3, 2 ], false ); +// returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] +``` + +- **x**: input array. +- **fromShape**: input array shape. +- **toShape**: output array shape. +- **colexicographic**: boolean indicating whether to reshape the array in colexicographic order. + +To reshape in colexicographic order, set the `colexicographic` argument to `true`. + +```javascript +var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; + +var out = reshape( x, [ 2, 3 ], [ 3, 2 ], true ); +// [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] +``` + +
+ + + +
+ +## Notes + +- The function assumes that `fromShape` and `toShape` describe arrays having the same number of elements. + +
+ + + +
+ +## Examples + + + +```javascript +var reshape = require( '@stdlib/array/base/reshape' ); + +var x = [ + [ 1, 2, 3, 4 ], + [ 5, 6, 7, 8 ], + [ 9, 10, 11, 12 ] +]; + +var out = reshape( x, [ 3, 4 ], [ 4, 3 ], false ); +// returns [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ], [ 10, 11, 12 ] ] + +out = reshape( x, [ 3, 4 ], [ 6, 2 ], false ); +// returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ], [ 9, 10 ], [ 11, 12 ] ] + +out = reshape( x, [ 3, 4 ], [ 1, 12 ], false ); +// returns [ [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] ] + +out = reshape( x, [ 3, 4 ], [ 12, 1 ], false ); +// returns [ [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ], [ 11 ], [ 12 ] ] +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/array/base/reshape/benchmark/benchmark.js b/lib/node_modules/@stdlib/array/base/reshape/benchmark/benchmark.js new file mode 100644 index 000000000000..bfb7e88f8ad3 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/reshape/benchmark/benchmark.js @@ -0,0 +1,206 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isArray = require( '@stdlib/assert/is-array' ); +var onesnd = require( '@stdlib/array/base/onesnd' ); +var pkg = require( './../package.json' ).name; +var reshape = require( './../lib' ); + + +// MAIN // + +bench( pkg+':ndims=2,size=100,lexicographic', function benchmark( b ) { + var x; + var i; + var v; + + x = onesnd( [ 10, 10 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = reshape( x, [ 10, 10 ], [ 1, 100 ], false ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isArray( v ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':ndims=2,size=100,colexicographic', function benchmark( b ) { + var x; + var i; + var v; + + x = onesnd( [ 10, 10 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = reshape( x, [ 10, 10 ], [ 1, 100 ], true ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isArray( v ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':ndims=3,size=100,lexicographic', function benchmark( b ) { + var x; + var i; + var v; + + x = onesnd( [ 4, 5, 5 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = reshape( x, [ 4, 5, 5 ], [ 1, 1, 100 ], false ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isArray( v ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':ndims=3,size=100,colexicographic', function benchmark( b ) { + var x; + var i; + var v; + + x = onesnd( [ 4, 5, 5 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = reshape( x, [ 4, 5, 5 ], [ 1, 1, 100 ], true ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isArray( v ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':ndims=4,size=100,lexicographic', function benchmark( b ) { + var x; + var i; + var v; + + x = onesnd( [ 5, 2, 5, 2 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = reshape( x, [ 5, 2, 5, 2 ], [ 1, 1, 1, 100 ], false ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isArray( v ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':ndims=4,size=100,colexicographic', function benchmark( b ) { + var x; + var i; + var v; + + x = onesnd( [ 5, 2, 5, 2 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = reshape( x, [ 5, 2, 5, 2 ], [ 1, 1, 1, 100 ], true ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isArray( v ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':ndims=5,size=100,lexicographic', function benchmark( b ) { + var x; + var i; + var v; + + x = onesnd( [ 5, 2, 1, 5, 2 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = reshape( x, [ 5, 2, 1, 5, 2 ], [ 1, 1, 1, 1, 100 ], false ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isArray( v ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':ndims=5,size=100,colexicographic', function benchmark( b ) { + var x; + var i; + var v; + + x = onesnd( [ 5, 2, 1, 5, 2 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = reshape( x, [ 5, 2, 1, 5, 2 ], [ 1, 1, 1, 1, 100 ], true ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isArray( v ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/base/reshape/docs/repl.txt b/lib/node_modules/@stdlib/array/base/reshape/docs/repl.txt new file mode 100644 index 000000000000..a01bac3a5083 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/reshape/docs/repl.txt @@ -0,0 +1,35 @@ + +{{alias}}( x, fromShape, toShape, colexicographic ) + Reshapes a nested array into another nested array having a desired shape. + + Parameters + ---------- + x: Array + Input n-dimensional nested array. + + fromShape: Array + Input array shape. + + toShape: Array + Output array shape. + + colexicographic: boolean + Specifies whether to reshape the array in colexicographic order. + + Returns + ------- + out: Array + Output array. + + Examples + -------- + > var x = [ [ 1, 2 ], [ 3, 4 ] ]; + > var out = {{alias}}( x, [ 2, 2 ], [ 4, 1 ], false ) + [ [ 1 ], [ 2 ], [ 3 ], [ 4 ] ] + + > var x = [ [ 1, 2 ], [ 3, 4 ] ]; + > var out = {{alias}}( x, [ 2, 2 ], [ 4, 1 ], true ) + [ [ 1 ], [ 3 ], [ 2 ], [ 4 ] ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/array/base/reshape/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/reshape/docs/types/index.d.ts new file mode 100644 index 000000000000..40bf2afd07ab --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/reshape/docs/types/index.d.ts @@ -0,0 +1,55 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Array1D, Array2D, Array3D, Array4D, Array5D, Array6D, Array7D, Array8D, Array9D, Array10D } from '@stdlib/types/array'; +import { Shape } from '@stdlib/types/ndarray'; + +/** +* Nested array. +*/ +type ArrayND = Array1D | Array2D | Array3D | Array4D | Array5D | Array6D | Array7D | Array8D | Array9D | Array10D; // WARNING: arbitrarily limited to 10 dimensions, which should be fine for most practical purposes + +/** +* Reshape a nested array into another nested array having a desired shape. +* +* ## Notes +* +* - The function assumes that `fromShape` and `toShape` describe arrays have same the number of elements. +* +* @param x - input nested array +* @param fromShape - shape of the input array +* @param toShape - shape of the output array +* @param colexicographic - specifies whether to reshape the array in colexicographic order +* @returns output nested array +* +* @example +* var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; +* +* var out = reshape( x, [ 2, 3 ], [ 3, 2 ], false ); +* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] +*/ +declare function reshape( x: ArrayND, fromShape: Shape, toShape: Shape, colexicographic: boolean ): ArrayND; + + +// EXPORTS // + +export = reshape; diff --git a/lib/node_modules/@stdlib/array/base/reshape/docs/types/test.ts b/lib/node_modules/@stdlib/array/base/reshape/docs/types/test.ts new file mode 100644 index 000000000000..099c56515b9a --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/reshape/docs/types/test.ts @@ -0,0 +1,97 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import reshape = require( './index' ); + + +// TESTS // + +// The function returns an array... +{ + const x = [ [ 1, 2 ], [ 3, 4 ] ]; + + reshape( x, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectType ArrayND + reshape( x, [ 2, 2 ], [ 4, 1 ], true ); // $ExpectType ArrayND + + reshape( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], [ 4, 1 ], false ); // $ExpectType ArrayND + reshape( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], [ 4, 1 ], true ); // $ExpectType ArrayND +} + +// The compiler throws an error if the function is provided a first argument which is not an array-like object... +{ + reshape( 1, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError + reshape( true, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError + reshape( false, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError + reshape( null, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError + reshape( void 0, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError + reshape( {}, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... +{ + const x = [ [ 1, 2 ], [ 3, 4 ] ]; + + reshape( x, '', [ 4, 1 ], false ); // $ExpectError + reshape( x, 1, [ 4, 1 ], false ); // $ExpectError + reshape( x, true, [ 4, 1 ], false ); // $ExpectError + reshape( x, false, [ 4, 1 ], false ); // $ExpectError + reshape( x, null, [ 4, 1 ], false ); // $ExpectError + reshape( x, void 0, [ 4, 1 ], false ); // $ExpectError + reshape( x, {}, [ 4, 1 ], false ); // $ExpectError + reshape( x, [ 1, '2', 3 ], [ 4, 1 ], false ); // $ExpectError + reshape( x, ( x: number ): number => x, [ 4, 1 ], false ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... +{ + const x = [ [ 1, 2 ], [ 3, 4 ] ]; + + reshape( x, [ 2, 2 ], '', false ); // $ExpectError + reshape( x, [ 2, 2 ], 1, false ); // $ExpectError + reshape( x, [ 2, 2 ], true, false ); // $ExpectError + reshape( x, [ 2, 2 ], false, false ); // $ExpectError + reshape( x, [ 2, 2 ], null, false ); // $ExpectError + reshape( x, [ 2, 2 ], void 0, false ); // $ExpectError + reshape( x, [ 2, 2 ], {}, false ); // $ExpectError + reshape( x, [ 2, 2 ], [ 4, '1' ], false ); // $ExpectError + reshape( x, [ 2, 2 ], ( x: number ): number => x, false ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a boolean... +{ + const x = [ [ 1, 2 ], [ 3, 4 ] ]; + + reshape( x, [ 2, 2 ], [ 4, 1 ], '' ); // $ExpectError + reshape( x, [ 2, 2 ], [ 4, 1], 1 ); // $ExpectError + reshape( x, [ 2, 2 ], [ 4, 1], null ); // $ExpectError + reshape( x, [ 2, 2 ], [ 4, 1], void 0 ); // $ExpectError + reshape( x, [ 2, 2 ], [ 4, 1], {} ); // $ExpectError + reshape( x, [ 2, 2 ], [ 4, 1], [] ); // $ExpectError + reshape( x, [ 2, 2 ], [ 4, 1], ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = [ [ 1, 2 ], [ 3, 4 ] ]; + + reshape(); // $ExpectError + reshape( x ); // $ExpectError + reshape( x, [ 2, 2 ] ); // $ExpectError + reshape( x, [ 2, 2 ], [ 4, 1 ] ); // $ExpectError + reshape( x, [ 2, 2 ], [ 4, 1 ], false, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/array/base/reshape/examples/index.js b/lib/node_modules/@stdlib/array/base/reshape/examples/index.js new file mode 100644 index 000000000000..af5b88494084 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/reshape/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var reshape = require( './../lib' ); + +var x = [ + [ 1, 2, 3, 4 ], + [ 5, 6, 7, 8 ], + [ 9, 10, 11, 12 ] +]; + +var out = reshape( x, [ 3, 4 ], [ 4, 3 ], false ); +console.log( out ); +// => [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ], [ 10, 11, 12 ] ] + +out = reshape( x, [ 3, 4 ], [ 6, 2 ], false ); +console.log( out ); +// => [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ], [ 9, 10 ], [ 11, 12 ] ] + +out = reshape( x, [ 3, 4 ], [ 1, 12 ], false ); +console.log( out ); +// => [ [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] ] + +out = reshape( x, [ 3, 4 ], [ 12, 1 ], false ); +console.log( out ); +// => [ [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ], [ 11 ], [ 12 ] ] diff --git a/lib/node_modules/@stdlib/array/base/reshape/lib/index.js b/lib/node_modules/@stdlib/array/base/reshape/lib/index.js new file mode 100644 index 000000000000..8b01ceb84f23 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/reshape/lib/index.js @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Reshape a nested array into another nested array having a desired shape. +* +* @module @stdlib/array/base/reshape +* +* @example +* var reshape = require( '@stdlib/array/base/reshape' ); +* +* var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; +* +* var out = reshape( x, [ 2, 3 ], [ 3, 2 ], false ); +* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/array/base/reshape/lib/main.js b/lib/node_modules/@stdlib/array/base/reshape/lib/main.js new file mode 100644 index 000000000000..9483f6c2eadf --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/reshape/lib/main.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var flatten = require( '@stdlib/array/base/flatten' ); +var slice = require( '@stdlib/array/base/slice' ); + + +// FUNCTIONS // + +/** +* Recursive reshapes an array. +* +* @private +* @param {Array} array - input n-dimensional nested array +* @param {NonNegativeInteger} ndims - number of dimensions +* @param {NonNegativeIntegerArray} shape - array shape +* @param {NonNegativeInteger} dim - dimension index +* @param {NonNegativeInteger} index - sub-array index +* @returns {Array} output m-dimensional nested array +*/ +function recurse( array, ndims, shape, dim, index ) { + var stepSize; + var subArray; + var out; + var d; + var S; + var i; + + S = shape[ dim ]; + if ( dim === ndims - 1 ) { + return slice( array, index, index + S ); + } + + d = dim + 1; + stepSize = 1; + for ( i = d; i < shape.length; i++ ) { + stepSize *= shape[ i ]; + } + + out = []; + for ( i = 0; i < S; i++ ) { + subArray = recurse( array, ndims, shape, d, index ); + out.push( subArray ); + index += stepSize; + } + return out; +} + + +// MAIN // + +/** +* Reshape a nested array into another nested array having a desired shape. +* +* @param {Array} x - input nested array +* @param {NonNegativeIntegerArray} fromShape - shape of the input array +* @param {NonNegativeIntegerArray} toShape - shape of the output array +* @param {boolean} colexicographic - specifies whether to reshape the array in colexicographic order +* @returns {Array} output nested array +* +* @example +* var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; +* +* var out = reshape( x, [ 2, 3 ], [ 3, 2 ], false ); +* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] +*/ +function reshape( x, fromShape, toShape, colexicographic ) { + var f = flatten( x, fromShape, colexicographic ); + return recurse( f, toShape.length, toShape, 0, 0 ); +} + + +// EXPORTS // + +module.exports = reshape; diff --git a/lib/node_modules/@stdlib/array/base/reshape/package.json b/lib/node_modules/@stdlib/array/base/reshape/package.json new file mode 100644 index 000000000000..5f754287b4ff --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/reshape/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/array/base/reshape", + "version": "0.0.0", + "description": "Reshape a nested array into another nested array having a desired shape.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "array", + "generic", + "reshape", + "nested", + "transform", + "shape" + ] +} diff --git a/lib/node_modules/@stdlib/array/base/reshape/test/test.js b/lib/node_modules/@stdlib/array/base/reshape/test/test.js new file mode 100644 index 000000000000..aeafec2350bd --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/reshape/test/test.js @@ -0,0 +1,457 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var reshape = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof reshape, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns a reshaped nested array (2d, lexicographic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; + + expected = [ 1, 2, 3, 4, 5, 6 ]; + actual = reshape( x, [ 2, 3 ], [ 6 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; + actual = reshape( x, [ 2, 3 ], [ 3, 2 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ [ 1, 2, 3, 4, 5, 6 ] ]; + actual = reshape( x, [ 2, 3 ], [ 1, 6 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]; + actual = reshape( x, [ 2, 3 ], [ 1, 3, 2 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ [ [ [ 1, 2 ] ], [ [ 3, 4 ] ], [ [ 5, 6 ] ] ] ]; + actual = reshape( x, [ 2, 3 ], [ 1, 3, 1, 2 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reshaped nested array (3d, lexicographic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ + [ + [ 1, 2 ], + [ 3, 4 ] + ], + [ + [ 5, 6 ], + [ 7, 8 ] + ] + ]; + + expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; + actual = reshape( x, [ 2, 2, 2 ], [ 8 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ] ]; + actual = reshape( x, [ 2, 2, 2 ], [ 4, 2 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ 1, 2 ] + ], + [ + [ 3, 4 ] + ], + [ + [ 5, 6 ] + ], + [ + [ 7, 8 ] + ] + ]; + actual = reshape( x, [ 2, 2, 2 ], [ 4, 1, 2 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ 1, 2, 3, 4 ] + ], + [ + [ 5, 6, 7, 8 ] + ] + ]; + actual = reshape( x, [ 2, 2, 2 ], [ 2, 1, 4 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ 1, 2 ], + [ 3, 4 ], + [ 5, 6 ], + [ 7, 8 ] + ] + ]; + actual = reshape( x, [ 2, 2, 2 ], [ 1, 4, 2 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ + [ 1, 2 ], + [ 3, 4 ], + [ 5, 6 ], + [ 7, 8 ] + ] + ] + ]; + actual = reshape( x, [ 2, 2, 2 ], [ 1, 1, 4, 2 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled nested array (4d, lexicographic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ + [ + [ + [ 1, 2, 3, 4 ] + ], + [ + [ 5, 6, 7, 8 ] + ] + ] + ]; + + expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 8 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 4 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ 1, 2, 3, 4 ], + [ 5, 6, 7, 8 ] + ] + ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 1, 2, 4 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ + [ 1, 2 ], + [ 3, 4 ] + ], + [ + [ 5, 6 ], + [ 7, 8 ] + ] + ] + ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 1, 2, 2, 2 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ + [ 1, 2 ], + [ 3, 4 ] + ] + ], + [ + [ + [ 5, 6 ], + [ 7, 8 ] + ] + ] + ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 1, 2, 2 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ + [ 1 ], + [ 2 ] + ], + [ + [ 3 ], + [ 4 ] + ] + ], + [ + [ + [ 5 ], + [ 6 ] + ], + [ + [ 7 ], + [ 8 ] + ] + ] + ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 2, 2, 1 ], false ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reshaped nested array (2d, colexicographic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; + + expected = [ 1, 4, 2, 5, 3, 6 ]; + actual = reshape( x, [ 2, 3 ], [ 6 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]; + actual = reshape( x, [ 2, 3 ], [ 3, 2 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ [ 1, 4, 2, 5, 3, 6 ] ]; + actual = reshape( x, [ 2, 3 ], [ 1, 6 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ 1, 4, 2 ], + [ 5, 3, 6 ] + ] + ]; + actual = reshape( x, [ 2, 3 ], [ 1, 2, 3 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ + [ 1, 4, 2 ] + ], + [ + [ 5, 3, 6 ] + ] + ] + ]; + actual = reshape( x, [ 2, 3 ], [ 1, 2, 1, 3 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reshaped nested array (3d, colexicographic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ + [ + [ 1, 2 ], + [ 3, 4 ] + ], + [ + [ 5, 6 ], + [ 7, 8 ] + ] + ]; + + expected = [ 1, 5, 3, 7, 2, 6, 4, 8]; + actual = reshape( x, [ 2, 2, 2 ], [ 8 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ [ 1, 5, 3, 7 ], [ 2, 6, 4, 8 ] ]; + actual = reshape( x, [ 2, 2, 2 ], [ 2, 4 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ 1, 5 ] + ], + [ + [ 3, 7 ] + ], + [ + [ 2, 6 ] + ], + [ + [ 4, 8 ] + ] + ]; + actual = reshape( x, [ 2, 2, 2 ], [ 4, 1, 2 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ 1, 5, 3, 7 ] + ], + [ + [ 2, 6, 4, 8 ] + ] + ]; + actual = reshape( x, [ 2, 2, 2 ], [ 2, 1, 4 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ 1, 5 ], + [ 3, 7 ], + [ 2, 6 ], + [ 4, 8 ] + ] + ]; + actual = reshape( x, [ 2, 2, 2 ], [ 1, 4, 2 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ + [ 1, 5 ] + ], + [ + [ 3, 7 ] + ], + [ + [ 2, 6 ] + ], + [ + [ 4, 8 ] + ] + ] + ]; + actual = reshape( x, [ 2, 2, 2 ], [ 1, 4, 1, 2 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled nested array (4d, colexicographic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ + [ + [ + [ 1, 2, 3, 4 ] + ], + [ + [ 5, 6, 7, 8 ] + ] + ] + ]; + + expected = [ 1, 5, 2, 6, 3, 7, 4, 8 ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 8 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ [ 1, 5, 2, 6 ], [ 3, 7, 4, 8 ] ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 4 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ 1, 5, 2, 6 ], + [ 3, 7, 4, 8 ] + ] + ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 1, 2, 4 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ + [ 1, 5 ], + [ 2, 6 ] + ], + [ + [ 3, 7 ], + [ 4, 8 ] + ] + ] + ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 1, 2, 2, 2 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ + [ 1, 5 ], + [ 2, 6 ] + ] + ], + [ + [ + [ 3, 7 ], + [ 4, 8 ] + ] + ] + ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 1, 2, 2 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + expected = [ + [ + [ + [ 1 ], + [ 5 ] + ], + [ + [ 2 ], + [ 6 ] + ] + ], + [ + [ + [ 3 ], + [ 7 ] + ], + [ + [ 4 ], + [ 8 ] + ] + ] + ]; + actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 2, 2, 1 ], true ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); From fcfbddfbbb872a6e213cba0591f7955042b2845d Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Wed, 9 Apr 2025 00:27:14 -0700 Subject: [PATCH 16/16] fix: use asm type annotation --- 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 --- --- lib/node_modules/@stdlib/math/base/special/log10/lib/main.js | 4 ++-- lib/node_modules/@stdlib/math/base/special/log2/lib/main.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/log10/lib/main.js b/lib/node_modules/@stdlib/math/base/special/log10/lib/main.js index ace00b03412d..7ef530d2d296 100644 --- a/lib/node_modules/@stdlib/math/base/special/log10/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/log10/lib/main.js @@ -119,7 +119,7 @@ function log10( x ) { return NaN; } toWords.assign( x, WORDS, 1, 0 ); - hx = WORDS[ 0 ]; + hx = WORDS[ 0 ] | 0; // asm type annotation lx = WORDS[ 1 ]; k = 0|0; // asm type annotation @@ -132,7 +132,7 @@ function log10( x ) { // Subnormal number, scale up x: x *= TWO54; - hx = getHighWord( x ); + hx = getHighWord( x ) | 0; // asm type annotation } if ( hx >= HIGH_MAX_NORMAL_EXP ) { return x + x; diff --git a/lib/node_modules/@stdlib/math/base/special/log2/lib/main.js b/lib/node_modules/@stdlib/math/base/special/log2/lib/main.js index 7860d7af1f6b..80019d4c6cb1 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/log2/lib/main.js @@ -116,7 +116,7 @@ function log2( x ) { return NaN; } toWords.assign( x, WORDS, 1, 0 ); - hx = WORDS[ 0 ]; + hx = WORDS[ 0 ] | 0; // asm type annotation lx = WORDS[ 1 ]; k = 0|0; // asm type annotation if ( hx < HIGH_MIN_NORMAL_EXP ) { @@ -128,7 +128,7 @@ function log2( x ) { // Subnormal number, scale up x: x *= TWO54; - hx = getHighWord( x ); + hx = getHighWord( x ) | 0; // asm type annotation } if ( hx >= HIGH_MAX_NORMAL_EXP ) { return x + x;