From 9d466bedcda8d51c1a3ec5dbfb4c445d5cef9484 Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Wed, 30 Sep 2026 14:28:26 +0530 Subject: [PATCH 1/3] refactor: add support for descending order in blas/ext/base/gindex-of-greater-than-sorted --- 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_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../gindex-of-greater-than-sorted/README.md | 7 +- .../docs/repl.txt | 6 +- .../docs/types/index.d.ts | 6 +- .../lib/accessors.js | 13 ++ .../gindex-of-greater-than-sorted/lib/main.js | 2 +- .../lib/ndarray.js | 15 +- .../test/test.main.js | 158 +++++++++++++++ .../test/test.ndarray.js | 182 ++++++++++++++++++ 8 files changed, 382 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/README.md index 8b66c4b544aa..3e91d358ea43 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/README.md @@ -49,6 +49,11 @@ var x = [ 1.0, 2.0, 2.0, 3.0 ]; var idx = gindexOfGreaterThanSorted( x.length, 2.0, x, 1 ); // returns 3 + +x = [ 3.0, 2.0, 2.0, 1.0 ]; + +idx = gindexOfGreaterThanSorted( x.length, 2.0, x, 1 ); +// returns 0 ``` The function has the following parameters: @@ -126,7 +131,7 @@ var idx = gindexOfGreaterThanSorted.ndarray( 3, 1.0, x, 1, x.length-3 ); ## Notes -- The input strided array **must** be sorted in ascending order. +- The input strided array **must** be sorted in either ascending or descending order. - If `N <= 0`, both functions return `-1`. - When comparing elements, both functions use the less-than operator `<`. As a consequence, comparisons involving `NaN` always evaluate to `false`, and `-0` and `+0` are considered the same. - Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/repl.txt index 9efe02b6d8ef..ba2c49930e80 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/repl.txt @@ -9,7 +9,8 @@ Indexing is relative to the first index. To introduce an offset, use a typed array view. - The input strided array must be sorted in ascending order. + The input strided array must be sorted in either ascending or descending + order. If unable to find an element which is greater than the search element, the function returns `-1`. @@ -41,6 +42,9 @@ > var x = [ 1.0, 2.0, 2.0, 3.0 ]; > var idx = {{alias}}( x.length, 2.0, x, 1 ) 3 + > x = [ 3.0, 2.0, 2.0, 1.0 ]; + > idx = {{alias}}( x.length, 2.0, x, 1 ) + 0 // Using `N` and stride parameters: > x = [ 1.0, 9.0, 2.0, 9.0, 3.0, 9.0 ]; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/types/index.d.ts index e36da1a78ef6..2747842b9a70 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/types/index.d.ts @@ -36,7 +36,7 @@ interface Routine { * * ## Notes * - * - The input strided array must be sorted in ascending order. + * - The input strided array must be sorted in either ascending or descending order. * - If the function is unable to find an element which is greater than a search element, the function returns `-1`. * * @param N - number of indexed elements @@ -58,7 +58,7 @@ interface Routine { * * ## Notes * - * - The input strided array must be sorted in ascending order. + * - The input strided array must be sorted in either ascending or descending order. * - If the function is unable to find an element which is greater than a search element, the function returns `-1`. * * @param N - number of indexed elements @@ -82,7 +82,7 @@ interface Routine { * * ## Notes * -* - The input strided array must be sorted in ascending order. +* - The input strided array must be sorted in either ascending or descending order. * - If the function is unable to find an element which is greater than a search element, the function returns `-1`. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/accessors.js index 6aac2863c759..e1676bc8442b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/accessors.js @@ -53,6 +53,8 @@ function gindexOfGreaterThanSorted( N, searchElement, x, strideX, offsetX ) { var mid; var lo; var hi; + var v1; + var v2; // Cache reference to array data: xbuf = x.data; @@ -60,6 +62,17 @@ function gindexOfGreaterThanSorted( N, searchElement, x, strideX, offsetX ) { // Cache a reference to the element accessors: get = x.accessors[ 0 ]; + v1 = get( xbuf, offsetX ); + v2 = get( xbuf, offsetX + ( ( N - 1 ) * strideX ) ); + + // Descending order: elements which are greater than the search element form a prefix, so only the first indexed element needs to be checked... + if ( v1 > v2 ) { + if ( v1 > searchElement ) { + return 0; + } + return -1; + } + // Ascending order: perform a binary search for the first element which is greater than the search element... lo = 0; hi = N; while ( lo < hi ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/main.js index 5eec29a2f95f..01f8f5b3da95 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/main.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - The input strided array must be sorted in ascending order. +* - The input strided array must be sorted in either ascending or descending order. * - If unable to find an element which is greater than the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js index 36fbd7c09d2b..c6c5f5cefdcd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js @@ -32,7 +32,7 @@ var accessors = require( './accessors.js' ); * * ## Notes * -* - The input strided array must be sorted in ascending order. +* - The input strided array must be sorted in either ascending or descending order. * - If unable to find an element which is greater than the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements @@ -52,6 +52,8 @@ function gindexOfGreaterThanSorted( N, searchElement, x, strideX, offsetX ) { var mid; var lo; var hi; + var v1; + var v2; var o; if ( N <= 0 ) { @@ -61,6 +63,17 @@ function gindexOfGreaterThanSorted( N, searchElement, x, strideX, offsetX ) { if ( o.accessorProtocol ) { return accessors( N, searchElement, o, strideX, offsetX ); } + v1 = x[ offsetX ]; + v2 = x[ offsetX + ( ( N - 1 ) * strideX ) ]; + + // Descending order: elements which are greater than the search element form a prefix, so only the first indexed element needs to be checked... + if ( v1 > v2 ) { + if ( v1 > searchElement ) { + return 0; + } + return -1; + } + // Ascending order: perform a binary search for the first element which is greater than the search element... lo = 0; hi = N; while ( lo < hi ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/test/test.main.js index 9f1a67a4f1ef..95a9c0f21bf7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/test/test.main.js @@ -310,3 +310,161 @@ tape( 'the function supports view offsets', function test( t ) { t.end(); }); + +tape( 'the function returns the index of the first element in a sorted strided array which is greater than a provided search element (descending order)', function test( t ) { + var actual; + var x; + + x = [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ]; + + actual = gindexOfGreaterThanSorted( x.length, 2.0, x, 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the index of the first element in a sorted strided array which is greater than a provided search element (descending order) (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] ); + + actual = gindexOfGreaterThanSorted( x.length, 2.0, x, 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the index of the first element in a sorted strided array which is greater than a provided search element when the search element is not present in the strided array (descending order)', function test( t ) { + var actual; + var x; + + x = [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ]; + + actual = gindexOfGreaterThanSorted( x.length, 2.5, x, 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the index of the first element in a sorted strided array which is greater than a provided search element when the search element is not present in the strided array (descending order) (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] ); + + actual = gindexOfGreaterThanSorted( x.length, 2.5, x, 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if every indexed element in the array is less than or equal to the search element (descending order)', function test( t ) { + var actual; + var x; + + x = [ 3.0, 2.0, 1.0 ]; + + actual = gindexOfGreaterThanSorted( x.length, 3.0, x, 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if every indexed element in the array is less than or equal to the search element (descending order) (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray( [ 3.0, 2.0, 1.0 ] ); + + actual = gindexOfGreaterThanSorted( x.length, 3.0, x, 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (descending order)', function test( t ) { + var actual; + var x; + + x = [ + 3.0, // 0 + 9.0, + 2.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfGreaterThanSorted( 3, 2.0, x, 2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (descending order) (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 3.0, // 0 + 9.0, + 2.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfGreaterThanSorted( 3, 2.0, toAccessorArray( x ), 2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (descending order)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 2 + 9.0, + 2.0, // 1 + 9.0, + 3.0 // 0 + ]; + + actual = gindexOfGreaterThanSorted( 3, 2.0, x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (descending order) (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 2 + 9.0, + 2.0, // 1 + 9.0, + 3.0 // 0 + ]; + + actual = gindexOfGreaterThanSorted( 3, 2.0, toAccessorArray( x ), -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets (descending order)', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array( [ 9.0, 4.0, 3.0, 2.0, 1.0 ] ); + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = gindexOfGreaterThanSorted( 3, 2.0, x1, 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/test/test.ndarray.js index 9e8e634b0fe1..217b405fb9a0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/test/test.ndarray.js @@ -335,3 +335,185 @@ tape( 'the function supports complex access patterns (accessors)', function test t.end(); }); + +tape( 'the function returns the index of the first element in a sorted strided array which is greater than a provided search element (descending order)', function test( t ) { + var actual; + var x; + + x = [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ]; + + actual = gindexOfGreaterThanSorted( x.length, 2.0, x, 1, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the index of the first element in a sorted strided array which is greater than a provided search element (descending order) (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] ); + + actual = gindexOfGreaterThanSorted( x.length, 2.0, x, 1, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the index of the first element in a sorted strided array which is greater than a provided search element when the search element is not present in the strided array (descending order)', function test( t ) { + var actual; + var x; + + x = [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ]; + + actual = gindexOfGreaterThanSorted( x.length, 2.5, x, 1, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the index of the first element in a sorted strided array which is greater than a provided search element when the search element is not present in the strided array (descending order) (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] ); + + actual = gindexOfGreaterThanSorted( x.length, 2.5, x, 1, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if every indexed element in the array is less than or equal to the search element (descending order)', function test( t ) { + var actual; + var x; + + x = [ 3.0, 2.0, 1.0 ]; + + actual = gindexOfGreaterThanSorted( x.length, 3.0, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if every indexed element in the array is less than or equal to the search element (descending order) (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray( [ 3.0, 2.0, 1.0 ] ); + + actual = gindexOfGreaterThanSorted( x.length, 3.0, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (descending order)', function test( t ) { + var actual; + var x; + + x = [ + 3.0, // 0 + 9.0, + 2.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfGreaterThanSorted( 3, 2.0, x, 2, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (descending order) (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 3.0, // 0 + 9.0, + 2.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfGreaterThanSorted( 3, 2.0, toAccessorArray( x ), 2, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (descending order)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 2 + 9.0, + 2.0, // 1 + 9.0, + 3.0 // 0 + ]; + + actual = gindexOfGreaterThanSorted( 3, 2.0, x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (descending order) (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 2 + 9.0, + 2.0, // 1 + 9.0, + 3.0 // 0 + ]; + + actual = gindexOfGreaterThanSorted( 3, 2.0, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset (descending order)', function test( t ) { + var actual; + var x; + + x = [ + 9.0, + 3.0, // 0 + 9.0, + 2.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfGreaterThanSorted( 3, 2.0, x, 2, 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset (descending order) (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 9.0, + 3.0, // 0 + 9.0, + 2.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfGreaterThanSorted( 3, 2.0, toAccessorArray( x ), 2, 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); From ed9805ffe130a19e11344aad228ba2b539d146fb Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 30 Sep 2026 02:30:33 -0700 Subject: [PATCH 2/3] Apply batched suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../blas/ext/base/gindex-of-greater-than-sorted/README.md | 2 +- .../blas/ext/base/gindex-of-greater-than-sorted/docs/repl.txt | 4 ++-- .../base/gindex-of-greater-than-sorted/docs/types/index.d.ts | 3 --- .../blas/ext/base/gindex-of-greater-than-sorted/lib/main.js | 1 - .../ext/base/gindex-of-greater-than-sorted/lib/ndarray.js | 1 - 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/README.md index 3e91d358ea43..d5dd6cb4b809 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/README.md @@ -131,7 +131,7 @@ var idx = gindexOfGreaterThanSorted.ndarray( 3, 1.0, x, 1, x.length-3 ); ## Notes -- The input strided array **must** be sorted in either ascending or descending order. +- The input strided array must be sorted in either **strictly** ascending or descending order. - If `N <= 0`, both functions return `-1`. - When comparing elements, both functions use the less-than operator `<`. As a consequence, comparisons involving `NaN` always evaluate to `false`, and `-0` and `+0` are considered the same. - Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/repl.txt index ba2c49930e80..5bdc474f7d8a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/repl.txt @@ -9,8 +9,8 @@ Indexing is relative to the first index. To introduce an offset, use a typed array view. - The input strided array must be sorted in either ascending or descending - order. + The input strided array must be sorted in either strictly ascending or + descending order. If unable to find an element which is greater than the search element, the function returns `-1`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/types/index.d.ts index 2747842b9a70..333405799731 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/docs/types/index.d.ts @@ -36,7 +36,6 @@ interface Routine { * * ## Notes * - * - The input strided array must be sorted in either ascending or descending order. * - If the function is unable to find an element which is greater than a search element, the function returns `-1`. * * @param N - number of indexed elements @@ -58,7 +57,6 @@ interface Routine { * * ## Notes * - * - The input strided array must be sorted in either ascending or descending order. * - If the function is unable to find an element which is greater than a search element, the function returns `-1`. * * @param N - number of indexed elements @@ -82,7 +80,6 @@ interface Routine { * * ## Notes * -* - The input strided array must be sorted in either ascending or descending order. * - If the function is unable to find an element which is greater than a search element, the function returns `-1`. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/main.js index 01f8f5b3da95..dd36359509aa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/main.js @@ -31,7 +31,6 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - The input strided array must be sorted in either ascending or descending order. * - If unable to find an element which is greater than the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js index c6c5f5cefdcd..42a95cada8e3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js @@ -32,7 +32,6 @@ var accessors = require( './accessors.js' ); * * ## Notes * -* - The input strided array must be sorted in either ascending or descending order. * - If unable to find an element which is greater than the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements From e0cb0692d514b188e3ed7c7c91c0fcb8d7e13b35 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 30 Sep 2026 02:33:06 -0700 Subject: [PATCH 3/3] Apply batched suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../ext/base/gindex-of-greater-than-sorted/lib/accessors.js | 2 +- .../blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/accessors.js index e1676bc8442b..2189c70e9c8a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/accessors.js @@ -66,7 +66,7 @@ function gindexOfGreaterThanSorted( N, searchElement, x, strideX, offsetX ) { v2 = get( xbuf, offsetX + ( ( N - 1 ) * strideX ) ); // Descending order: elements which are greater than the search element form a prefix, so only the first indexed element needs to be checked... - if ( v1 > v2 ) { + if ( v1 >= v2 ) { if ( v1 > searchElement ) { return 0; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js index 42a95cada8e3..38f777a247bd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-sorted/lib/ndarray.js @@ -66,7 +66,7 @@ function gindexOfGreaterThanSorted( N, searchElement, x, strideX, offsetX ) { v2 = x[ offsetX + ( ( N - 1 ) * strideX ) ]; // Descending order: elements which are greater than the search element form a prefix, so only the first indexed element needs to be checked... - if ( v1 > v2 ) { + if ( v1 >= v2 ) { if ( v1 > searchElement ) { return 0; }