From e0c0786d59720fd3ea23b9e81284279032f4dc05 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 9 Sep 2026 21:38:24 +0500 Subject: [PATCH 01/68] fix: refactor `index-of` --- .../blas/ext/base/cindex-of/docs/repl.txt | 21 +++ .../blas/ext/base/cindex-of/lib/cindex_of.js | 4 + .../blas/ext/base/cindex-of/lib/ndarray.js | 4 + .../ext/base/cindex-of/test/test.cindex_of.js | 93 +++++++--- .../cindex-of/test/test.cindex_of.native.js | 93 +++++++--- .../ext/base/cindex-of/test/test.ndarray.js | 116 +++++++------ .../cindex-of/test/test.ndarray.native.js | 116 +++++++------ .../blas/ext/base/dindex-of/docs/repl.txt | 18 ++ .../ext/base/dindex-of/docs/types/test.ts | 9 + .../blas/ext/base/dindex-of/lib/dindex_of.js | 4 + .../blas/ext/base/dindex-of/lib/ndarray.js | 4 + .../ext/base/dindex-of/test/test.dindex_of.js | 79 ++++++--- .../dindex-of/test/test.dindex_of.native.js | 79 ++++++--- .../ext/base/dindex-of/test/test.ndarray.js | 76 ++++++--- .../dindex-of/test/test.ndarray.native.js | 76 ++++++--- .../blas/ext/base/gindex-of/docs/repl.txt | 18 ++ .../ext/base/gindex-of/docs/types/test.ts | 15 +- .../blas/ext/base/gindex-of/lib/accessors.js | 4 + .../blas/ext/base/gindex-of/lib/main.js | 4 + .../blas/ext/base/gindex-of/lib/ndarray.js | 4 + .../blas/ext/base/gindex-of/test/test.main.js | 141 ++++++++++----- .../ext/base/gindex-of/test/test.ndarray.js | 160 ++++++++++++------ .../blas/ext/base/sindex-of/docs/repl.txt | 18 ++ .../ext/base/sindex-of/docs/types/test.ts | 9 + .../blas/ext/base/sindex-of/lib/ndarray.js | 4 + .../blas/ext/base/sindex-of/lib/sindex_of.js | 4 + .../ext/base/sindex-of/test/test.ndarray.js | 76 ++++++--- .../sindex-of/test/test.ndarray.native.js | 76 ++++++--- .../ext/base/sindex-of/test/test.sindex_of.js | 79 ++++++--- .../sindex-of/test/test.sindex_of.native.js | 79 ++++++--- .../blas/ext/base/zindex-of/docs/repl.txt | 21 +++ .../blas/ext/base/zindex-of/lib/ndarray.js | 4 + .../blas/ext/base/zindex-of/lib/zindex_of.js | 4 + .../ext/base/zindex-of/test/test.ndarray.js | 116 +++++++------ .../zindex-of/test/test.ndarray.native.js | 116 +++++++------ .../ext/base/zindex-of/test/test.zindex_of.js | 93 +++++++--- .../zindex-of/test/test.zindex_of.native.js | 93 +++++++--- 37 files changed, 1372 insertions(+), 558 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/repl.txt index 0833aee84650..e462a3dfe693 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/repl.txt @@ -32,11 +32,25 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var s = new {{alias:@stdlib/complex/float32/ctor}}( 3.0, 4.0 ); > var idx = {{alias}}( x.length, s, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var s = new {{alias:@stdlib/complex/float32/ctor}}( 5.0, 6.0 ); + > var idx = {{alias}}( 2, s, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var s = new {{alias:@stdlib/complex/float32/ctor}}( 7.0, 8.0 ); + > var idx = {{alias}}( 2, s, x1, 2 ) + 1 + {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) Returns the first index of a specified search element in a single-precision @@ -70,10 +84,17 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var s = new {{alias:@stdlib/complex/float32/ctor}}( 3.0, 4.0 ); > var idx = {{alias}}.ndarray( x.length, s, x, 1, 0 ) 1 + // Using an index offset: + > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var s = new {{alias:@stdlib/complex/float32/ctor}}( 7.0, 8.0 ); + > var idx = {{alias}}.ndarray( 2, s, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.js index 436862ac4fe5..8e9250fa7e20 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the first index of a specified search element in a single-precision complex floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex64} searchElement - search element * @param {Complex64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.js index 0e306a326f64..d8bd609bd0d8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.js @@ -30,6 +30,10 @@ var imagf = require( '@stdlib/complex/float32/imag' ); /** * Returns the first index of a specified search element in a single-precision complex floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex64} searchElement - search element * @param {Complex64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.js index 4eaa52ffbdff..d252e76eadda 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.js @@ -53,32 +53,9 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = cindexOf( x.length, new Complex64( 3.0, 4.0 ), x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 5.0, 6.0 ), x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 3.0, 4.0 ), x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 5.0, 6.0 ), x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -143,3 +120,73 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = cindexOf( 3, new Complex64( 9.0, 10.0 ), x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOf( 2, new Complex64( 7.0, 8.0 ), x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.native.js index 9dce9436b253..1a2684f20b64 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.native.js @@ -62,32 +62,9 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = cindexOf( x.length, new Complex64( 3.0, 4.0 ), x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 5.0, 6.0 ), x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 3.0, 4.0 ), x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 5.0, 6.0 ), x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -152,3 +129,73 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = cindexOf( 3, new Complex64( 9.0, 10.0 ), x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOf( 2, new Complex64( 7.0, 8.0 ), x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.js index 8ee27573db63..a3530800b752 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.js @@ -53,36 +53,13 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = cindexOf( x.length-1, new Complex64( 3.0, 4.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( x.length-2, new Complex64( 5.0, 6.0 ), x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length-2, new Complex64( 7.0, 8.0 ), x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 3.0, 4.0 ), x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 1.0, 2.0 ), x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -104,30 +81,6 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { - var actual; - var x; - - x = new Complex64Array([ - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0 - ]); - - actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 1.0, 2.0 ), x, 1, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports a stride length equal to zero', function test( t ) { var actual; var x; @@ -170,3 +123,70 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = cindexOf( 3, new Complex64( 9.0, 10.0 ), x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + actual = cindexOf( 2, new Complex64( 7.0, 8.0 ), x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.native.js index 341e3cd9da8f..adc305612d84 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.native.js @@ -62,36 +62,13 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = cindexOf( x.length-1, new Complex64( 3.0, 4.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( x.length-2, new Complex64( 5.0, 6.0 ), x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length-2, new Complex64( 7.0, 8.0 ), x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 3.0, 4.0 ), x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 1.0, 2.0 ), x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -113,30 +90,6 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function supports an `x` offset', opts, function test( t ) { - var actual; - var x; - - x = new Complex64Array([ - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0 - ]); - - actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 1.0, 2.0 ), x, 1, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports a stride length equal to zero', opts, function test( t ) { var actual; var x; @@ -179,3 +132,70 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = cindexOf( 3, new Complex64( 9.0, 10.0 ), x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + actual = cindexOf( 2, new Complex64( 7.0, 8.0 ), x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/repl.txt index 524a31cce7dc..c9a6faddb974 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/repl.txt @@ -32,10 +32,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); > var idx = {{alias}}( x.length, 1.0, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); + > var idx = {{alias}}( 4, 4.0, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, -4.0, x1, 2 ) + 1 + {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) Returns the first index of a specified search element in a double-precision @@ -69,9 +81,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) 1 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); + > var idx = {{alias}}.ndarray( 3, -5.0, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/types/test.ts index 8982d272dbca..2eaeafda2879 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/types/test.ts @@ -37,6 +37,7 @@ import dindexOf = require( './index' ); dindexOf( false, 2.0, x, 1 ); // $ExpectError dindexOf( null, 2.0, x, 1 ); // $ExpectError dindexOf( {}, 2.0, x, 1 ); // $ExpectError + dindexOf( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -48,6 +49,7 @@ import dindexOf = require( './index' ); dindexOf( x.length, false, x, 1 ); // $ExpectError dindexOf( x.length, null, x, 1 ); // $ExpectError dindexOf( x.length, {}, x, 1 ); // $ExpectError + dindexOf( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float64Array... @@ -57,6 +59,7 @@ import dindexOf = require( './index' ); dindexOf( x.length, 1.0, false, 1 ); // $ExpectError dindexOf( x.length, 1.0, null, 1 ); // $ExpectError dindexOf( x.length, 1.0, {}, 1 ); // $ExpectError + dindexOf( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -68,6 +71,7 @@ import dindexOf = require( './index' ); dindexOf( x.length, 2.0, x, false ); // $ExpectError dindexOf( x.length, 2.0, x, null ); // $ExpectError dindexOf( x.length, 2.0, x, {} ); // $ExpectError + dindexOf( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -94,6 +98,7 @@ import dindexOf = require( './index' ); dindexOf.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError dindexOf.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError dindexOf.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + dindexOf.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... @@ -105,6 +110,7 @@ import dindexOf = require( './index' ); dindexOf.ndarray( x.length, false, x, 1, 1 ); // $ExpectError dindexOf.ndarray( x.length, null, x, 1, 1 ); // $ExpectError dindexOf.ndarray( x.length, {}, x, 1, 1 ); // $ExpectError + dindexOf.ndarray( x.length, ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array... @@ -114,6 +120,7 @@ import dindexOf = require( './index' ); dindexOf.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError dindexOf.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError dindexOf.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + dindexOf.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -125,6 +132,7 @@ import dindexOf = require( './index' ); dindexOf.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError dindexOf.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError dindexOf.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + dindexOf.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -136,6 +144,7 @@ import dindexOf = require( './index' ); dindexOf.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError dindexOf.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError dindexOf.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + dindexOf.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.js index 8043aa83d4df..ff0c866c8c3d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the first index of a specified search element in a double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.js index 8b5c9983aadf..5cdabc9138a7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.js @@ -23,6 +23,10 @@ /** * Returns the first index of a specified search element in a double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.js index 5d0238a31de1..2122aa43ea8e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.js @@ -39,52 +39,87 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = dindexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, 1 ); + actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dindexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, -1 ); + actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dindexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dindexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.native.js index 581e8806dc6c..2ef2d0405a20 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.native.js @@ -48,52 +48,87 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = dindexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, 1 ); + actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dindexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, -1 ); + actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dindexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dindexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.js index 839d9b94f244..6874132348fb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.js @@ -39,52 +39,84 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = dindexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = dindexOf( x.length-2, 4.0, x, 1, 2 ); + actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dindexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dindexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dindexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = dindexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.native.js index fc8274101c79..cd6ce9ee63e8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.native.js @@ -48,52 +48,84 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = dindexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = dindexOf( x.length-2, 4.0, x, 1, 2 ); + actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dindexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dindexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dindexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = dindexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/docs/repl.txt index 64fd6f8de899..a972b4e780a2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/docs/repl.txt @@ -31,10 +31,22 @@ Examples -------- + // Standard usage: > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; > var idx = {{alias}}( x.length, 1.0, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; + > var idx = {{alias}}( 4, 4.0, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, -4.0, x1, 2 ) + 1 + {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) Returns the first index of a specified search element in a strided array @@ -68,9 +80,15 @@ Examples -------- + // Standard usage: > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) 1 + // Using an index offset: + > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; + > var idx = {{alias}}.ndarray( 3, -5.0, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/docs/types/test.ts index 683dada8a225..b30850d69055 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/docs/types/test.ts @@ -39,15 +39,17 @@ import gindexOf = require( './index' ); gindexOf( false, 2.0, x, 1 ); // $ExpectError gindexOf( null, 2.0, x, 1 ); // $ExpectError gindexOf( {}, 2.0, x, 1 ); // $ExpectError + gindexOf( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a collection... { - gindexOf( x.length, 1.0, '1', 1 ); // $ExpectError + gindexOf( x.length, 1.0, 1, 1 ); // $ExpectError gindexOf( x.length, 1.0, true, 1 ); // $ExpectError gindexOf( x.length, 1.0, false, 1 ); // $ExpectError gindexOf( x.length, 1.0, null, 1 ); // $ExpectError gindexOf( x.length, 1.0, {}, 1 ); // $ExpectError + gindexOf( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -59,6 +61,7 @@ import gindexOf = require( './index' ); gindexOf( x.length, 2.0, x, false ); // $ExpectError gindexOf( x.length, 2.0, x, null ); // $ExpectError gindexOf( x.length, 2.0, x, {} ); // $ExpectError + gindexOf( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -66,7 +69,7 @@ import gindexOf = require( './index' ); gindexOf(); // $ExpectError gindexOf( 3, 2.0 ); // $ExpectError gindexOf( 3, 2.0, [ 1.0, 2.0, 3.0 ] ); // $ExpectError - gindexOf( 3, 2.0, [ 1.0, 2.0, 3.0 ], 1, 0 ); // $ExpectError + gindexOf( 3, 2.0, [ 1.0, 2.0, 3.0 ], 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -86,15 +89,17 @@ import gindexOf = require( './index' ); gindexOf.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError gindexOf.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError gindexOf.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + gindexOf.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... { - gindexOf.ndarray( x.length, 1.0, '1', 1, 1 ); // $ExpectError + gindexOf.ndarray( x.length, 1.0, 1, 1, 1 ); // $ExpectError gindexOf.ndarray( x.length, 1.0, true, 1, 1 ); // $ExpectError gindexOf.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError gindexOf.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError gindexOf.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + gindexOf.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -106,6 +111,7 @@ import gindexOf = require( './index' ); gindexOf.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError gindexOf.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError gindexOf.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + gindexOf.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -117,6 +123,7 @@ import gindexOf = require( './index' ); gindexOf.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError gindexOf.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError gindexOf.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + gindexOf.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -125,5 +132,5 @@ import gindexOf = require( './index' ); gindexOf.ndarray( 3, 2.0 ); // $ExpectError gindexOf.ndarray( 3, 2.0, [ 1.0, 2.0, 3.0 ] ); // $ExpectError gindexOf.ndarray( 3, 2.0, [ 1.0, 2.0, 3.0 ], 1 ); // $ExpectError - gindexOf.ndarray( 3, 2.0, [ 1.0, 2.0, 3.0 ], 1, 0, 0 ); // $ExpectError + gindexOf.ndarray( 3, 2.0, [ 1.0, 2.0, 3.0 ], 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/accessors.js index a2bd128f9877..dd3338f2cda8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/accessors.js @@ -23,6 +23,10 @@ /** * Returns the first index of a specified search element in a strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @private * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/main.js index 7d2b5b34d392..e383c46ac1b6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/main.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the first index of a specified search element in a strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/ndarray.js index bc7e8c4861a5..23daf40e63f5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/lib/ndarray.js @@ -29,6 +29,10 @@ var accessors = require( './accessors.js' ); /** * Returns the first index of a specified search element in a strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/test/test.main.js index 56a6cd5d8aac..43593139450c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/test/test.main.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var gindexOf = require( './../lib' ); @@ -44,32 +45,9 @@ tape( 'the function returns the first index of an element which equals a provide x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... actual = gindexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOf( x.length, 4.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOf( x.length, 4.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -79,32 +57,9 @@ tape( 'the function returns the first index of an element which equals a provide x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = gindexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOf( x.length, 4.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOf( x.length, 4.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -149,3 +104,97 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN` (ac t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]; + + actual = gindexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]; + + actual = gindexOf( 3, 5.0, toAccessorArray( x ), 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]; + + actual = gindexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]; + + actual = gindexOf( 3, 5.0, toAccessorArray( x ), -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = gindexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/test/test.ndarray.js index 4d1b4a570710..c8597ba5597f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of/test/test.ndarray.js @@ -44,32 +44,9 @@ tape( 'the function returns the first index of an element which equals a provide x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... actual = gindexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOf( x.length-2, 4.0, x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOf( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -79,36 +56,13 @@ tape( 'the function returns the first index of an element which equals a provide x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = gindexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOf( x.length, 2.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOf( x.length, 3.0, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOf( x.length, 4.0, x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOf( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gindexOf( 0, 2.0, [ 1.0, 2.0, 3.0 ], 1, 0 ); @@ -120,7 +74,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gindexOf( 0, 2.0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -149,3 +103,113 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN` (ac t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]; + + actual = gindexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]; + + actual = gindexOf( 3, 5.0, toAccessorArray( x ), 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]; + + actual = gindexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]; + + actual = gindexOf( 3, 5.0, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = [ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]; + + actual = gindexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]; + + actual = gindexOf( 3, 4.0, toAccessorArray( x ), 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/repl.txt index f02a766a9f0d..cf130fc489fc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/repl.txt @@ -32,10 +32,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); > var idx = {{alias}}( x.length, 1.0, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); + > var idx = {{alias}}( 4, 4.0, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, -4.0, x1, 2 ) + 1 + {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) Returns the first index of a specified search element in a single-precision @@ -69,9 +81,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) 1 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); + > var idx = {{alias}}.ndarray( 3, -5.0, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/types/test.ts index 8b3ba3645c99..5b8fadaf5f0f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/types/test.ts @@ -37,6 +37,7 @@ import sindexOf = require( './index' ); sindexOf( false, 2.0, x, 1 ); // $ExpectError sindexOf( null, 2.0, x, 1 ); // $ExpectError sindexOf( {}, 2.0, x, 1 ); // $ExpectError + sindexOf( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -48,6 +49,7 @@ import sindexOf = require( './index' ); sindexOf( x.length, false, x, 1 ); // $ExpectError sindexOf( x.length, null, x, 1 ); // $ExpectError sindexOf( x.length, {}, x, 1 ); // $ExpectError + sindexOf( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float32Array... @@ -57,6 +59,7 @@ import sindexOf = require( './index' ); sindexOf( x.length, 1.0, false, 1 ); // $ExpectError sindexOf( x.length, 1.0, null, 1 ); // $ExpectError sindexOf( x.length, 1.0, {}, 1 ); // $ExpectError + sindexOf( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -68,6 +71,7 @@ import sindexOf = require( './index' ); sindexOf( x.length, 2.0, x, false ); // $ExpectError sindexOf( x.length, 2.0, x, null ); // $ExpectError sindexOf( x.length, 2.0, x, {} ); // $ExpectError + sindexOf( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -94,6 +98,7 @@ import sindexOf = require( './index' ); sindexOf.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError sindexOf.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError sindexOf.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + sindexOf.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... @@ -105,6 +110,7 @@ import sindexOf = require( './index' ); sindexOf.ndarray( x.length, false, x, 1, 1 ); // $ExpectError sindexOf.ndarray( x.length, null, x, 1, 1 ); // $ExpectError sindexOf.ndarray( x.length, {}, x, 1, 1 ); // $ExpectError + sindexOf.ndarray( x.length, ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float32Array... @@ -114,6 +120,7 @@ import sindexOf = require( './index' ); sindexOf.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError sindexOf.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError sindexOf.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + sindexOf.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -125,6 +132,7 @@ import sindexOf = require( './index' ); sindexOf.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError sindexOf.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError sindexOf.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + sindexOf.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -136,6 +144,7 @@ import sindexOf = require( './index' ); sindexOf.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError sindexOf.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError sindexOf.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + sindexOf.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/ndarray.js index d4a8415d73cc..d50f81cf7ccf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/ndarray.js @@ -23,6 +23,10 @@ /** * Returns the first index of a specified search element in a single-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float32Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/sindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/sindex_of.js index fa83969afa0c..135f3b43c2ca 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/sindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/sindex_of.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the first index of a specified search element in a single-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float32Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.ndarray.js index 8911c6247d71..2ba292bfcc53 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.ndarray.js @@ -39,52 +39,84 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = sindexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = sindexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = sindexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = sindexOf( x.length-2, 4.0, x, 1, 2 ); + actual = sindexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = sindexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = sindexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = sindexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = sindexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = sindexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = sindexOf( 1, NaN, new Float32Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = sindexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = sindexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = sindexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = sindexOf( 1, NaN, new Float32Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = sindexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = sindexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.ndarray.native.js index 95c1cb837798..f0f09f2c9ab4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.ndarray.native.js @@ -48,52 +48,84 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = sindexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = sindexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = sindexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = sindexOf( x.length-2, 4.0, x, 1, 2 ); + actual = sindexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = sindexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = sindexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = sindexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = sindexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = sindexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = sindexOf( 1, NaN, new Float32Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = sindexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = sindexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = sindexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = sindexOf( 1, NaN, new Float32Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = sindexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = sindexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.sindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.sindex_of.js index 6d9be76f62c3..4230f707a74c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.sindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.sindex_of.js @@ -39,52 +39,87 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = sindexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = sindexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = sindexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = sindexOf( x.length, 4.0, x, 1 ); + actual = sindexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = sindexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = sindexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = sindexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = sindexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = sindexOf( x.length, 4.0, x, -1 ); + actual = sindexOf( 1, NaN, new Float32Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = sindexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = sindexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = sindexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = sindexOf( 1, NaN, new Float32Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = sindexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = sindexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.sindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.sindex_of.native.js index 7bda2ba1dc31..6560423842a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.sindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/test/test.sindex_of.native.js @@ -48,52 +48,87 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = sindexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = sindexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = sindexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = sindexOf( x.length, 4.0, x, 1 ); + actual = sindexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = sindexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = sindexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = sindexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = sindexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = sindexOf( x.length, 4.0, x, -1 ); + actual = sindexOf( 1, NaN, new Float32Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = sindexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = sindexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = sindexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = sindexOf( 1, NaN, new Float32Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = sindexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = sindexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/docs/repl.txt index bf7684da4651..72881e5158cb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/docs/repl.txt @@ -32,11 +32,25 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var s = new {{alias:@stdlib/complex/float64/ctor}}( 3.0, 4.0 ); > var idx = {{alias}}( x.length, s, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var s = new {{alias:@stdlib/complex/float64/ctor}}( 5.0, 6.0 ); + > var idx = {{alias}}( 2, s, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var s = new {{alias:@stdlib/complex/float64/ctor}}( 7.0, 8.0 ); + > var idx = {{alias}}( 2, s, x1, 2 ) + 1 + {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) Returns the first index of a specified search element in a double-precision @@ -70,10 +84,17 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var s = new {{alias:@stdlib/complex/float64/ctor}}( 3.0, 4.0 ); > var idx = {{alias}}.ndarray( x.length, s, x, 1, 0 ) 1 + // Using an index offset: + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var s = new {{alias:@stdlib/complex/float64/ctor}}( 7.0, 8.0 ); + > var idx = {{alias}}.ndarray( 2, s, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/ndarray.js index 695daf58ebd3..56c995f54c49 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/ndarray.js @@ -30,6 +30,10 @@ var imag = require( '@stdlib/complex/float64/imag' ); /** * Returns the first index of a specified search element in a double-precision complex floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex128} searchElement - search element * @param {Complex128Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/zindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/zindex_of.js index 36dfe22284bd..120078fd92c6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/zindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/zindex_of.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the first index of a specified search element in a double-precision complex floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex128} searchElement - search element * @param {Complex128Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.ndarray.js index b6f279af74fe..5dc1056853cc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.ndarray.js @@ -53,36 +53,13 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = zindexOf( x.length, new Complex128( 1.0, 2.0 ), x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = zindexOf( x.length-1, new Complex128( 3.0, 4.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOf( x.length-2, new Complex128( 5.0, 6.0 ), x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOf( x.length-2, new Complex128( 7.0, 8.0 ), x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = zindexOf( x.length, new Complex128( 1.0, 2.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = zindexOf( 3, new Complex128( 3.0, 4.0 ), x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOf( 3, new Complex128( 1.0, 2.0 ), x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 7.0, 8.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -104,30 +81,6 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { - var actual; - var x; - - x = new Complex128Array([ - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0 - ]); - - actual = zindexOf( 3, new Complex128( 5.0, 6.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOf( 3, new Complex128( 1.0, 2.0 ), x, 1, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports a stride length equal to zero', function test( t ) { var actual; var x; @@ -170,3 +123,70 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = zindexOf( 3, new Complex128( 5.0, 6.0 ), x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = zindexOf( 3, new Complex128( 9.0, 10.0 ), x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + actual = zindexOf( 2, new Complex128( 7.0, 8.0 ), x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.ndarray.native.js index 634a3fb84ff9..09af23d2b666 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.ndarray.native.js @@ -62,36 +62,13 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = zindexOf( x.length, new Complex128( 1.0, 2.0 ), x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = zindexOf( x.length-1, new Complex128( 3.0, 4.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOf( x.length-2, new Complex128( 5.0, 6.0 ), x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOf( x.length-2, new Complex128( 7.0, 8.0 ), x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = zindexOf( x.length, new Complex128( 1.0, 2.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = zindexOf( 3, new Complex128( 3.0, 4.0 ), x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOf( 3, new Complex128( 1.0, 2.0 ), x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 7.0, 8.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -113,30 +90,6 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function supports an `x` offset', opts, function test( t ) { - var actual; - var x; - - x = new Complex128Array([ - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0 - ]); - - actual = zindexOf( 3, new Complex128( 5.0, 6.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOf( 3, new Complex128( 1.0, 2.0 ), x, 1, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports a stride length equal to zero', opts, function test( t ) { var actual; var x; @@ -179,3 +132,70 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = zindexOf( 3, new Complex128( 5.0, 6.0 ), x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = zindexOf( 3, new Complex128( 9.0, 10.0 ), x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + actual = zindexOf( 2, new Complex128( 7.0, 8.0 ), x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.zindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.zindex_of.js index fe9c74819ec2..fa41ff478937 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.zindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.zindex_of.js @@ -53,32 +53,9 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = zindexOf( x.length, new Complex128( 1.0, 2.0 ), x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = zindexOf( x.length, new Complex128( 3.0, 4.0 ), x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 5.0, 6.0 ), x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 7.0, 8.0 ), x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = zindexOf( x.length, new Complex128( 1.0, 2.0 ), x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 3.0, 4.0 ), x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 5.0, 6.0 ), x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 7.0, 8.0 ), x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -143,3 +120,73 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = zindexOf( 3, new Complex128( 5.0, 6.0 ), x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = zindexOf( 3, new Complex128( 9.0, 10.0 ), x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = zindexOf( 2, new Complex128( 7.0, 8.0 ), x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.zindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.zindex_of.native.js index 4c63ec4ef34c..525d0dc399ae 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.zindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/test/test.zindex_of.native.js @@ -62,32 +62,9 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = zindexOf( x.length, new Complex128( 1.0, 2.0 ), x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = zindexOf( x.length, new Complex128( 3.0, 4.0 ), x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 5.0, 6.0 ), x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 7.0, 8.0 ), x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = zindexOf( x.length, new Complex128( 1.0, 2.0 ), x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 3.0, 4.0 ), x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 5.0, 6.0 ), x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = zindexOf( x.length, new Complex128( 7.0, 8.0 ), x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -152,3 +129,73 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = zindexOf( 3, new Complex128( 5.0, 6.0 ), x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = zindexOf( 3, new Complex128( 9.0, 10.0 ), x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = zindexOf( 2, new Complex128( 7.0, 8.0 ), x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); From b841028ee8a590cd82c4cfe9be74a947ef624d13 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 9 Sep 2026 21:38:52 +0500 Subject: [PATCH 02/68] fix: refactor `last-index-of` --- .../blas/ext/base/dlast-index-of/README.md | 8 +- .../ext/base/dlast-index-of/docs/repl.txt | 18 ++ .../base/dlast-index-of/docs/types/test.ts | 9 + .../base/dlast-index-of/lib/dlast_index_of.js | 4 + .../ext/base/dlast-index-of/lib/ndarray.js | 4 + .../test/test.dlast_index_of.js | 79 ++++++--- .../test/test.dlast_index_of.native.js | 79 ++++++--- .../base/dlast-index-of/test/test.ndarray.js | 76 +++++--- .../test/test.ndarray.native.js | 76 +++++--- .../blas/ext/base/glast-index-of/README.md | 8 +- .../ext/base/glast-index-of/docs/repl.txt | 18 ++ .../base/glast-index-of/docs/types/test.ts | 37 ++-- .../blas/ext/base/glast-index-of/lib/main.js | 4 + .../ext/base/glast-index-of/lib/ndarray.js | 4 + .../ext/base/glast-index-of/test/test.main.js | 146 +++++++++++----- .../base/glast-index-of/test/test.ndarray.js | 165 +++++++++++++----- .../blas/ext/base/slast-index-of/README.md | 8 +- .../ext/base/slast-index-of/docs/repl.txt | 18 ++ .../base/slast-index-of/docs/types/test.ts | 29 +-- .../ext/base/slast-index-of/lib/ndarray.js | 4 + .../base/slast-index-of/lib/slast_index_of.js | 4 + .../base/slast-index-of/test/test.ndarray.js | 76 +++++--- .../test/test.ndarray.native.js | 76 +++++--- .../test/test.slast_index_of.js | 79 ++++++--- .../test/test.slast_index_of.native.js | 79 ++++++--- 25 files changed, 800 insertions(+), 308 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/README.md b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/README.md index ba8be65ee488..a7566343f3f4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/README.md @@ -87,13 +87,13 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -// Initial array: +// Initial array... var x0 = new Float64Array( [ -2.0, 3.0, -6.0, -4.0, 5.0, 3.0 ] ); -// Create an offset view: +// Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -// Find index: +// Find index... var idx = dlastIndexOf( 3, 3.0, x1, 2 ); // returns 2 ``` @@ -115,7 +115,7 @@ The function has the following additional parameters: - **offsetX**: starting index. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array: ```javascript var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/repl.txt index 53b639b7b4d3..8991cbfc304b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/repl.txt @@ -32,10 +32,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ] ); > var idx = {{alias}}( x.length, 3.0, x, 1 ) 6 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ] ); + > var idx = {{alias}}( 4, 3.0, x, 2 ) + 3 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -2.0, 5.0, -6.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, -2.0, x1, 2 ) + 1 + {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) Returns the last index of a specified search element in a double-precision @@ -69,9 +81,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ] ); > var idx = {{alias}}.ndarray( x.length, 3.0, x, 1, 0 ) 6 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ] ); + > var idx = {{alias}}.ndarray( 3, 3.0, x, 2, 2 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/types/test.ts index 731cd3b4adc7..4ff02cbf081b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/types/test.ts @@ -37,6 +37,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf( false, 2.0, x, 1 ); // $ExpectError dlastIndexOf( null, 2.0, x, 1 ); // $ExpectError dlastIndexOf( {}, 2.0, x, 1 ); // $ExpectError + dlastIndexOf( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -48,6 +49,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf( x.length, false, x, 1 ); // $ExpectError dlastIndexOf( x.length, null, x, 1 ); // $ExpectError dlastIndexOf( x.length, {}, x, 1 ); // $ExpectError + dlastIndexOf( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float64Array... @@ -57,6 +59,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf( x.length, 1.0, false, 1 ); // $ExpectError dlastIndexOf( x.length, 1.0, null, 1 ); // $ExpectError dlastIndexOf( x.length, 1.0, {}, 1 ); // $ExpectError + dlastIndexOf( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -68,6 +71,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf( x.length, 2.0, x, false ); // $ExpectError dlastIndexOf( x.length, 2.0, x, null ); // $ExpectError dlastIndexOf( x.length, 2.0, x, {} ); // $ExpectError + dlastIndexOf( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -94,6 +98,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + dlastIndexOf.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... @@ -105,6 +110,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf.ndarray( x.length, false, x, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, null, x, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, {}, x, 1, 1 ); // $ExpectError + dlastIndexOf.ndarray( x.length, ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array... @@ -114,6 +120,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + dlastIndexOf.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -125,6 +132,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + dlastIndexOf.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -136,6 +144,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError dlastIndexOf.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError dlastIndexOf.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + dlastIndexOf.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.js index 243c760bc6aa..489c7f5af9f4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the last index of a specified search element in a double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.js index c56004585907..d286be5618f2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.js @@ -28,6 +28,10 @@ var dindexOf = require( '@stdlib/blas/ext/base/dindex-of' ).ndarray; /** * Returns the last index of a specified search element in a double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.js index ab7675d06166..9b2b04671899 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.js @@ -39,52 +39,87 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dlastIndexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dlastIndexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 5, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, 1 ); + actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dlastIndexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, -1 ); + actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dlastIndexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.native.js index 40294f80972c..32e81f7c0879 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.native.js @@ -48,52 +48,87 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dlastIndexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dlastIndexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 5, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, 1 ); + actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dlastIndexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, -1 ); + actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dlastIndexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.js index e057f6d6ddd1..82805f36b604 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.js @@ -39,52 +39,84 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dlastIndexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dlastIndexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 3, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = dlastIndexOf( x.length-2, 4.0, x, 1, 2 ); + actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dlastIndexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dlastIndexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = dlastIndexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.native.js index 0113dae2e25e..a459dd751cb9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.native.js @@ -48,52 +48,84 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dlastIndexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dlastIndexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 3, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = dlastIndexOf( x.length-2, 4.0, x, 1, 2 ); + actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dlastIndexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dlastIndexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = dlastIndexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/README.md b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/README.md index 31a16e13db0f..7ab57d3e8ca4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/README.md @@ -81,13 +81,13 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -// Initial array: +// Initial array... var x0 = new Float64Array( [ -2.0, 3.0, -6.0, -4.0, 5.0, 3.0 ] ); -// Create an offset view: +// Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -// Find index: +// Find index... var idx = glastIndexOf( 3, 3.0, x1, 2 ); // returns 2 ``` @@ -107,7 +107,7 @@ The function has the following additional parameters: - **offsetX**: starting index. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array: ```javascript var x = [ -2.0, 1.0, 0.0, -5.0, 4.0, 3.0, 3.0, -1.0 ]; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/docs/repl.txt index 9113fe0a20ab..1d9043dc8b62 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/docs/repl.txt @@ -31,10 +31,22 @@ Examples -------- + // Standard usage: > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ]; > var idx = {{alias}}( x.length, 3.0, x, 1 ) 6 + // Using `N` and stride parameters: + > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ]; + > var idx = {{alias}}( 4, 3.0, x, 2 ) + 3 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -2.0, 5.0, -6.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, -2.0, x1, 2 ) + 1 + {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) Returns the last index of a specified search element in a strided array @@ -68,9 +80,15 @@ Examples -------- + // Standard usage: > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ]; > var idx = {{alias}}.ndarray( x.length, 3.0, x, 1, 0 ) 6 + // Using an index offset: + > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ]; + > var idx = {{alias}}.ndarray( 3, 3.0, x, 2, 2 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/docs/types/test.ts index 12f2a2547460..b797f86838ce 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/docs/types/test.ts @@ -39,16 +39,17 @@ import glastIndexOf = require( './index' ); glastIndexOf( false, 2.0, x, 1 ); // $ExpectError glastIndexOf( null, 2.0, x, 1 ); // $ExpectError glastIndexOf( {}, 2.0, x, 1 ); // $ExpectError + glastIndexOf( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a collection... { - glastIndexOf( 3, 1.0, 1, 1 ); // $ExpectError - glastIndexOf( 3, 1.0, true, 1 ); // $ExpectError - glastIndexOf( 3, 1.0, false, 1 ); // $ExpectError - glastIndexOf( 3, 1.0, null, 1 ); // $ExpectError - glastIndexOf( 3, 1.0, void 0, 1 ); // $ExpectError - glastIndexOf( 3, 1.0, {}, 1 ); // $ExpectError + glastIndexOf( x.length, 1.0, 1, 1 ); // $ExpectError + glastIndexOf( x.length, 1.0, true, 1 ); // $ExpectError + glastIndexOf( x.length, 1.0, false, 1 ); // $ExpectError + glastIndexOf( x.length, 1.0, null, 1 ); // $ExpectError + glastIndexOf( x.length, 1.0, {}, 1 ); // $ExpectError + glastIndexOf( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -60,6 +61,7 @@ import glastIndexOf = require( './index' ); glastIndexOf( x.length, 2.0, x, false ); // $ExpectError glastIndexOf( x.length, 2.0, x, null ); // $ExpectError glastIndexOf( x.length, 2.0, x, {} ); // $ExpectError + glastIndexOf( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -67,7 +69,7 @@ import glastIndexOf = require( './index' ); glastIndexOf(); // $ExpectError glastIndexOf( 3, 2.0 ); // $ExpectError glastIndexOf( 3, 2.0, [ 1.0, 2.0, 3.0 ] ); // $ExpectError - glastIndexOf( 3, 2.0, [ 1.0, 2.0, 3.0 ], 1, 0 ); // $ExpectError + glastIndexOf( 3, 2.0, [ 1.0, 2.0, 3.0 ], 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -87,16 +89,17 @@ import glastIndexOf = require( './index' ); glastIndexOf.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError glastIndexOf.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError glastIndexOf.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + glastIndexOf.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... { - glastIndexOf.ndarray( 3, 1.0, 1, 1, 1 ); // $ExpectError - glastIndexOf.ndarray( 3, 1.0, true, 1, 1 ); // $ExpectError - glastIndexOf.ndarray( 3, 1.0, false, 1, 1 ); // $ExpectError - glastIndexOf.ndarray( 3, 1.0, null, 1, 1 ); // $ExpectError - glastIndexOf.ndarray( 3, 1.0, void 0, 1, 1 ); // $ExpectError - glastIndexOf.ndarray( 3, 1.0, {}, 1, 1 ); // $ExpectError + glastIndexOf.ndarray( x.length, 1.0, 1, 1, 1 ); // $ExpectError + glastIndexOf.ndarray( x.length, 1.0, true, 1, 1 ); // $ExpectError + glastIndexOf.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError + glastIndexOf.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError + glastIndexOf.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + glastIndexOf.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -108,6 +111,7 @@ import glastIndexOf = require( './index' ); glastIndexOf.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError glastIndexOf.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError glastIndexOf.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + glastIndexOf.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -119,13 +123,14 @@ import glastIndexOf = require( './index' ); glastIndexOf.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError glastIndexOf.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError glastIndexOf.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + glastIndexOf.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... { glastIndexOf.ndarray(); // $ExpectError glastIndexOf.ndarray( 3, 2.0 ); // $ExpectError - glastIndexOf.ndarray( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError - glastIndexOf.ndarray( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); // $ExpectError - glastIndexOf.ndarray( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, 0 ); // $ExpectError + glastIndexOf.ndarray( 3, 2.0, [ 1.0, 2.0, 3.0 ] ); // $ExpectError + glastIndexOf.ndarray( 3, 2.0, [ 1.0, 2.0, 3.0 ], 1 ); // $ExpectError + glastIndexOf.ndarray( 3, 2.0, [ 1.0, 2.0, 3.0 ], 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/lib/main.js index 5de90ace2b92..d6d3795af514 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/lib/main.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the last index of a specified search element in a strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/lib/ndarray.js index 885da3022418..94dafba8b5e6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/lib/ndarray.js @@ -28,6 +28,10 @@ var gindexOf = require( '@stdlib/blas/ext/base/gindex-of' ).ndarray; /** * Returns the last index of a specified search element in a strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/test/test.main.js index 8308a0003707..7b2ec4c5fc83 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/test/test.main.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var glastIndexOf = require( './../lib' ); @@ -33,38 +34,20 @@ tape( 'main export is a function', function test( t ) { t.end(); }); +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( glastIndexOf.length, 4, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the last index of an element which equals a provided search element', function test( t ) { var actual; var x; x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... actual = glastIndexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = glastIndexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = glastIndexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = glastIndexOf( x.length, 4.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = glastIndexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = glastIndexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = glastIndexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = glastIndexOf( x.length, 4.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -74,32 +57,9 @@ tape( 'the function returns the last index of an element which equals a provided x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = glastIndexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = glastIndexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = glastIndexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = glastIndexOf( x.length, 4.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = glastIndexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = glastIndexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = glastIndexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = glastIndexOf( x.length, 4.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -144,3 +104,97 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN` (ac t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]; + + actual = glastIndexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]; + + actual = glastIndexOf( 3, 5.0, toAccessorArray( x ), 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]; + + actual = glastIndexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]; + + actual = glastIndexOf( 3, 5.0, toAccessorArray( x ), -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = glastIndexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/test/test.ndarray.js index abdafdc8aa8f..41c15a40d7af 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of/test/test.ndarray.js @@ -33,38 +33,20 @@ tape( 'main export is a function', function test( t ) { t.end(); }); +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( glastIndexOf.length, 5, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the last index of an element which equals a provided search element', function test( t ) { var actual; var x; x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... actual = glastIndexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = glastIndexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = glastIndexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = glastIndexOf( x.length-2, 4.0, x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = glastIndexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = glastIndexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = glastIndexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = glastIndexOf( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -74,36 +56,13 @@ tape( 'the function returns the last index of an element which equals a provided x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = glastIndexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = glastIndexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = glastIndexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = glastIndexOf( x.length-2, 4.0, x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = glastIndexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = glastIndexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = glastIndexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = glastIndexOf( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = glastIndexOf( 0, 2.0, [ 1.0, 2.0, 3.0 ], 1, 0 ); @@ -115,7 +74,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = glastIndexOf( 0, 2.0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -144,3 +103,113 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN` (ac t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]; + + actual = glastIndexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]; + + actual = glastIndexOf( 3, 5.0, toAccessorArray( x ), 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]; + + actual = glastIndexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]; + + actual = glastIndexOf( 3, 5.0, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = [ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]; + + actual = glastIndexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]; + + actual = glastIndexOf( 3, 4.0, toAccessorArray( x ), 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/README.md b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/README.md index 38e3a9afd6ae..7c9e2f06c22e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/README.md @@ -87,13 +87,13 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -// Initial array: +// Initial array... var x0 = new Float32Array( [ -2.0, 3.0, -6.0, -4.0, 5.0, 3.0 ] ); -// Create an offset view: +// Create an offset view... var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -// Find index: +// Find index... var idx = slastIndexOf( 3, 3.0, x1, 2 ); // returns 2 ``` @@ -115,7 +115,7 @@ The function has the following additional parameters: - **offsetX**: starting index. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array: ```javascript var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/docs/repl.txt index 358ed1801bdc..0286e41f40d9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/docs/repl.txt @@ -32,10 +32,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ] ); > var idx = {{alias}}( x.length, 3.0, x, 1 ) 6 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ] ); + > var idx = {{alias}}( 4, 3.0, x, 2 ) + 3 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -2.0, 5.0, -6.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, -2.0, x1, 2 ) + 1 + {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) Returns the last index of a specified search element in a single-precision @@ -69,9 +81,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ] ); > var idx = {{alias}}.ndarray( x.length, 3.0, x, 1, 0 ) 6 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ] ); + > var idx = {{alias}}.ndarray( 3, 3.0, x, 2, 2 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/docs/types/test.ts index 3dceb1dda5cd..e949a3c3dba7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/docs/types/test.ts @@ -37,6 +37,7 @@ import slastIndexOf = require( './index' ); slastIndexOf( false, 2.0, x, 1 ); // $ExpectError slastIndexOf( null, 2.0, x, 1 ); // $ExpectError slastIndexOf( {}, 2.0, x, 1 ); // $ExpectError + slastIndexOf( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -48,15 +49,17 @@ import slastIndexOf = require( './index' ); slastIndexOf( x.length, false, x, 1 ); // $ExpectError slastIndexOf( x.length, null, x, 1 ); // $ExpectError slastIndexOf( x.length, {}, x, 1 ); // $ExpectError + slastIndexOf( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float32Array... { - slastIndexOf( 3, 1.0, '1', 1 ); // $ExpectError - slastIndexOf( 3, 1.0, true, 1 ); // $ExpectError - slastIndexOf( 3, 1.0, false, 1 ); // $ExpectError - slastIndexOf( 3, 1.0, null, 1 ); // $ExpectError - slastIndexOf( 3, 1.0, {}, 1 ); // $ExpectError + slastIndexOf( x.length, 1.0, '1', 1 ); // $ExpectError + slastIndexOf( x.length, 1.0, true, 1 ); // $ExpectError + slastIndexOf( x.length, 1.0, false, 1 ); // $ExpectError + slastIndexOf( x.length, 1.0, null, 1 ); // $ExpectError + slastIndexOf( x.length, 1.0, {}, 1 ); // $ExpectError + slastIndexOf( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -68,6 +71,7 @@ import slastIndexOf = require( './index' ); slastIndexOf( x.length, 2.0, x, false ); // $ExpectError slastIndexOf( x.length, 2.0, x, null ); // $ExpectError slastIndexOf( x.length, 2.0, x, {} ); // $ExpectError + slastIndexOf( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -94,6 +98,7 @@ import slastIndexOf = require( './index' ); slastIndexOf.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError slastIndexOf.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError slastIndexOf.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + slastIndexOf.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... @@ -105,15 +110,17 @@ import slastIndexOf = require( './index' ); slastIndexOf.ndarray( x.length, false, x, 1, 1 ); // $ExpectError slastIndexOf.ndarray( x.length, null, x, 1, 1 ); // $ExpectError slastIndexOf.ndarray( x.length, {}, x, 1, 1 ); // $ExpectError + slastIndexOf.ndarray( x.length, ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float32Array... { - slastIndexOf.ndarray( 3, 1.0, '1', 1, 1 ); // $ExpectError - slastIndexOf.ndarray( 3, 1.0, true, 1, 1 ); // $ExpectError - slastIndexOf.ndarray( 3, 1.0, false, 1, 1 ); // $ExpectError - slastIndexOf.ndarray( 3, 1.0, null, 1, 1 ); // $ExpectError - slastIndexOf.ndarray( 3, 1.0, {}, 1, 1 ); // $ExpectError + slastIndexOf.ndarray( x.length, 1.0, '1', 1, 1 ); // $ExpectError + slastIndexOf.ndarray( x.length, 1.0, true, 1, 1 ); // $ExpectError + slastIndexOf.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError + slastIndexOf.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError + slastIndexOf.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + slastIndexOf.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -125,6 +132,7 @@ import slastIndexOf = require( './index' ); slastIndexOf.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError slastIndexOf.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError slastIndexOf.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + slastIndexOf.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -136,6 +144,7 @@ import slastIndexOf = require( './index' ); slastIndexOf.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError slastIndexOf.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError slastIndexOf.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + slastIndexOf.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/ndarray.js index af1a3c21adc4..5ae29f254834 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/ndarray.js @@ -28,6 +28,10 @@ var sindexOf = require( '@stdlib/blas/ext/base/sindex-of' ).ndarray; /** * Returns the last index of a specified search element in a single-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float32Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/slast_index_of.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/slast_index_of.js index 997f83d8cd7a..0ae75d5c5f77 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/slast_index_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/slast_index_of.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the last index of a specified search element in a single-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float32Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.ndarray.js index 29a6a4b31e89..707c858ccdcd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.ndarray.js @@ -39,52 +39,84 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = slastIndexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = slastIndexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = slastIndexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 3, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = slastIndexOf( x.length-2, 4.0, x, 1, 2 ); + actual = slastIndexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = slastIndexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = slastIndexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); - actual = slastIndexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = slastIndexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = slastIndexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = slastIndexOf( 1, NaN, new Float32Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = slastIndexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = slastIndexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + actual = slastIndexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = slastIndexOf( 1, NaN, new Float32Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = slastIndexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = slastIndexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.ndarray.native.js index 3283ccea7c36..cb0a54e10322 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.ndarray.native.js @@ -48,52 +48,84 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = slastIndexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = slastIndexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = slastIndexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 3, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = slastIndexOf( x.length-2, 4.0, x, 1, 2 ); + actual = slastIndexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = slastIndexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = slastIndexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); - actual = slastIndexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = slastIndexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = slastIndexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = slastIndexOf( 1, NaN, new Float32Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = slastIndexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = slastIndexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + actual = slastIndexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = slastIndexOf( 1, NaN, new Float32Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = slastIndexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = slastIndexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.slast_index_of.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.slast_index_of.js index 8fdd41b42138..608b3bef5172 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.slast_index_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.slast_index_of.js @@ -39,52 +39,87 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = slastIndexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = slastIndexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = slastIndexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 5, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = slastIndexOf( x.length, 4.0, x, 1 ); + actual = slastIndexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = slastIndexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = slastIndexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = slastIndexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = slastIndexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = slastIndexOf( x.length, 4.0, x, -1 ); + actual = slastIndexOf( 1, NaN, new Float32Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = slastIndexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = slastIndexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = slastIndexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = slastIndexOf( 1, NaN, new Float32Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = slastIndexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = slastIndexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.slast_index_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.slast_index_of.native.js index 04d74a842d8b..5ce742991bdb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.slast_index_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/test/test.slast_index_of.native.js @@ -48,52 +48,87 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = slastIndexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = slastIndexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = slastIndexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 5, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = slastIndexOf( x.length, 4.0, x, 1 ); + actual = slastIndexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = slastIndexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = slastIndexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = slastIndexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = slastIndexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = slastIndexOf( x.length, 4.0, x, -1 ); + actual = slastIndexOf( 1, NaN, new Float32Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = slastIndexOf( 0, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = slastIndexOf( -1, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = slastIndexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = slastIndexOf( 1, NaN, new Float32Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float32Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = slastIndexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = slastIndexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); From 9bf61a305f3c749a006163bdb9410351ecb049e2 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 9 Sep 2026 22:56:02 +0500 Subject: [PATCH 03/68] fix: refactor `index-of-truthy` --- .../blas/ext/base/cindex-of-truthy/README.md | 2 - .../ext/base/cindex-of-truthy/docs/repl.txt | 22 ++- .../cindex-of-truthy/docs/types/index.d.ts | 6 +- .../base/cindex-of-truthy/docs/types/test.ts | 7 + .../cindex-of-truthy/lib/cindex_of_truthy.js | 2 +- .../lib/cindex_of_truthy.native.js | 2 +- .../ext/base/cindex-of-truthy/lib/ndarray.js | 2 +- .../cindex-of-truthy/lib/ndarray.native.js | 2 +- .../blas/ext/base/cindex-of-truthy/src/main.c | 1 + .../test/test.cindex_of_truthy.js | 87 +++++++-- .../test/test.cindex_of_truthy.native.js | 87 +++++++-- .../cindex-of-truthy/test/test.ndarray.js | 93 ++++++--- .../test/test.ndarray.native.js | 93 ++++++--- .../blas/ext/base/dindex-of-truthy/README.md | 1 - .../ext/base/dindex-of-truthy/docs/repl.txt | 22 +++ .../dindex-of-truthy/docs/types/index.d.ts | 6 +- .../base/dindex-of-truthy/docs/types/test.ts | 7 + .../dindex-of-truthy/lib/dindex_of_truthy.js | 2 +- .../lib/dindex_of_truthy.native.js | 2 +- .../ext/base/dindex-of-truthy/lib/ndarray.js | 2 +- .../dindex-of-truthy/lib/ndarray.native.js | 2 +- .../test/test.dindex_of_truthy.js | 71 +++++-- .../test/test.dindex_of_truthy.native.js | 71 +++++-- .../dindex-of-truthy/test/test.ndarray.js | 77 +++++--- .../test/test.ndarray.native.js | 77 +++++--- .../blas/ext/base/gindex-of-truthy/README.md | 2 +- .../ext/base/gindex-of-truthy/docs/repl.txt | 22 +++ .../gindex-of-truthy/docs/types/index.d.ts | 9 +- .../base/gindex-of-truthy/docs/types/test.ts | 7 + .../base/gindex-of-truthy/lib/accessors.js | 3 +- .../ext/base/gindex-of-truthy/lib/main.js | 3 +- .../ext/base/gindex-of-truthy/lib/ndarray.js | 3 +- .../base/gindex-of-truthy/test/test.main.js | 121 +++++++++--- .../gindex-of-truthy/test/test.ndarray.js | 176 +++++++++++------- .../blas/ext/base/sindex-of-truthy/README.md | 1 - .../ext/base/sindex-of-truthy/docs/repl.txt | 22 +++ .../sindex-of-truthy/docs/types/index.d.ts | 6 +- .../base/sindex-of-truthy/docs/types/test.ts | 7 + .../ext/base/sindex-of-truthy/lib/ndarray.js | 2 +- .../sindex-of-truthy/lib/ndarray.native.js | 2 +- .../sindex-of-truthy/lib/sindex_of_truthy.js | 2 +- .../lib/sindex_of_truthy.native.js | 2 +- .../sindex-of-truthy/test/test.ndarray.js | 77 +++++--- .../test/test.ndarray.native.js | 77 +++++--- .../test/test.sindex_of_truthy.js | 71 +++++-- .../test/test.sindex_of_truthy.native.js | 71 +++++-- .../blas/ext/base/zindex-of-truthy/README.md | 50 ++--- .../benchmark/c/benchmark.length.c | 6 +- .../ext/base/zindex-of-truthy/docs/repl.txt | 30 ++- .../zindex-of-truthy/docs/types/index.d.ts | 16 +- .../base/zindex-of-truthy/docs/types/test.ts | 35 ++-- .../zindex-of-truthy/examples/c/example.c | 4 +- .../base/zindex-of-truthy/examples/index.js | 2 +- .../ext/base/zindex-of-truthy/lib/index.js | 8 +- .../ext/base/zindex-of-truthy/lib/ndarray.js | 6 +- .../zindex-of-truthy/lib/ndarray.native.js | 6 +- .../zindex-of-truthy/lib/zindex_of_truthy.js | 6 +- .../lib/zindex_of_truthy.native.js | 6 +- .../ext/base/zindex-of-truthy/src/addon.c | 1 + .../zindex-of-truthy/test/test.ndarray.js | 105 ++++++++--- .../test/test.ndarray.native.js | 105 ++++++++--- .../test/test.zindex_of_truthy.js | 91 +++++++-- .../test/test.zindex_of_truthy.native.js | 91 +++++++-- 63 files changed, 1518 insertions(+), 482 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/README.md b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/README.md index 814ec98297c9..a23933ff756c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/README.md @@ -146,7 +146,6 @@ var idx = cindexOfTruthy.ndarray( 3, x, 1, x.length-3 ); ## Notes - A complex number is truthy when at least one of its real or imaginary components is truthy. -- If unable to find a truthy element, both functions return `-1`. - Both functions explicitly treat `NaN` values as falsy. @@ -265,7 +264,6 @@ CBLAS_INT stdlib_strided_cindex_of_truthy_ndarray( const CBLAS_INT N, const stdl ### Notes - A complex number is truthy when at least one of its real or imaginary components is truthy. -- If unable to find a truthy element, both functions return `-1`. - Both functions explicitly treat `NaN` values as falsy. diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/repl.txt index b8a402731735..e51726f293a5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/repl.txt @@ -14,8 +14,6 @@ A complex number is truthy when at least one of its real or imaginary components is truthy. - If unable to find a truthy element, the function returns `-1`. - The function explicitly treats `NaN` values as falsy. Parameters @@ -36,10 +34,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); + > var idx = {{alias}}( 2, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 2, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first truthy element in a single-precision complex @@ -52,8 +62,6 @@ A complex number is truthy when at least one of its real or imaginary components is truthy. - If unable to find a truthy element, the function returns `-1`. - The function explicitly treats `NaN` values as falsy. Parameters @@ -77,9 +85,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 1 + // Using an index offset: + > var x = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + > var idx = {{alias}}.ndarray( 2, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/index.d.ts index ca7db764632a..666e0c13ac32 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/index.d.ts @@ -32,7 +32,7 @@ interface Routine { * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -56,7 +56,7 @@ interface Routine { * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -82,7 +82,7 @@ interface Routine { * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/test.ts index 55e406a8c193..3acbbc5bda74 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/test.ts @@ -40,6 +40,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy( false, x, 1 ); // $ExpectError cindexOfTruthy( null, x, 1 ); // $ExpectError cindexOfTruthy( {}, x, 1 ); // $ExpectError + cindexOfTruthy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Complex64Array... @@ -51,6 +52,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy( x.length, false, 1 ); // $ExpectError cindexOfTruthy( x.length, null, 1 ); // $ExpectError cindexOfTruthy( x.length, {}, 1 ); // $ExpectError + cindexOfTruthy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -62,6 +64,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy( x.length, x, false ); // $ExpectError cindexOfTruthy( x.length, x, null ); // $ExpectError cindexOfTruthy( x.length, x, {} ); // $ExpectError + cindexOfTruthy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -88,6 +91,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy.ndarray( false, x, 1, 1 ); // $ExpectError cindexOfTruthy.ndarray( null, x, 1, 1 ); // $ExpectError cindexOfTruthy.ndarray( {}, x, 1, 1 ); // $ExpectError + cindexOfTruthy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex64Array... @@ -99,6 +103,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy.ndarray( x.length, false, 1, 1 ); // $ExpectError cindexOfTruthy.ndarray( x.length, null, 1, 1 ); // $ExpectError cindexOfTruthy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + cindexOfTruthy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -110,6 +115,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy.ndarray( x.length, x, false, 1 ); // $ExpectError cindexOfTruthy.ndarray( x.length, x, null, 1 ); // $ExpectError cindexOfTruthy.ndarray( x.length, x, {}, 1 ); // $ExpectError + cindexOfTruthy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -121,6 +127,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy.ndarray( x.length, x, 1, false ); // $ExpectError cindexOfTruthy.ndarray( x.length, x, 1, null ); // $ExpectError cindexOfTruthy.ndarray( x.length, x, 1, {} ); // $ExpectError + cindexOfTruthy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.js index c63b23e30dda..254cb854ed96 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.js @@ -32,7 +32,7 @@ var ndarray = require( './ndarray.js' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.native.js index 736d971ecdea..994fccf218fd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.js index f053e051e135..39e23490563d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.js @@ -31,7 +31,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.native.js index 6307d0153dea..c7d405b78100 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/src/main.c index 810c2ef7874c..41c3b730e907 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/src/main.c @@ -17,6 +17,7 @@ */ #include "stdlib/blas/ext/base/cindex_of_truthy.h" +#include "stdlib/complex/float32/ctor.h" #include "stdlib/complex/float32/real.h" #include "stdlib/complex/float32/imag.h" #include "stdlib/math/base/assert/is_nanf.h" diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.js index 03c50cd474c4..aadbd6d1a2ac 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.js @@ -52,20 +52,9 @@ tape( 'the function returns the index of the first truthy element', function tes 0.0 ]); - // Nonnegative stride... actual = cindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = cindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -111,7 +100,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = cindexOfTruthy( 0, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 1 ); // eslint-disable-line max-len @@ -122,3 +111,77 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 0 + 0.0, // 0 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 3.0, + 3.0, + 4.0, // 2 + 4.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = cindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.native.js index 29d1e1c5f1c2..6c160bec4d7a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.native.js @@ -61,20 +61,9 @@ tape( 'the function returns the index of the first truthy element', opts, functi 0.0 ]); - // Nonnegative stride... actual = cindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = cindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -120,7 +109,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = cindexOfTruthy( 0, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 1 ); // eslint-disable-line max-len @@ -131,3 +120,77 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 0 + 0.0, // 0 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 3.0, + 3.0, + 4.0, // 2 + 4.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = cindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.js index e82ef408c579..d746120132db 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.js @@ -52,29 +52,9 @@ tape( 'the function returns the index of the first truthy element', function tes 0.0 ]); - // Nonnegative stride... actual = cindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -120,7 +100,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -143,3 +123,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 0 + 0.0, // 0 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 3.0, + 3.0, + 4.0, // 2 + 4.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = cindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.native.js index a29352157c2c..850727c3a4d8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.native.js @@ -61,29 +61,9 @@ tape( 'the function returns the index of the first truthy element', opts, functi 0.0 ]); - // Nonnegative stride... actual = cindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -129,7 +109,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -152,3 +132,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 0 + 0.0, // 0 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 3.0, + 3.0, + 4.0, // 2 + 4.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = cindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/README.md b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/README.md index adc593c8c226..f3f1d5f356b4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/README.md @@ -135,7 +135,6 @@ var idx = dindexOfTruthy.ndarray( 3, x, 1, x.length-3 ); ## Notes -- If the function is unable to find a truthy element, the function returns `-1`. - Both functions explicitly treat `NaN` values as falsy. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/repl.txt index 63a2408cbbc4..affc77d7e14a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/repl.txt @@ -11,6 +11,8 @@ If `N <= 0`, the function returns `-1`. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -29,10 +31,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 2 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 2 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first truthy element in a double-precision @@ -42,6 +56,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -63,9 +79,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 2 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/index.d.ts index eb2e5785f4c9..d7751b4cff39 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/test.ts index 23817bcd581c..1eb2abdadc67 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/test.ts @@ -37,6 +37,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy( false, x, 1 ); // $ExpectError dindexOfTruthy( null, x, 1 ); // $ExpectError dindexOfTruthy( {}, x, 1 ); // $ExpectError + dindexOfTruthy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... @@ -46,6 +47,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy( x.length, false, 1 ); // $ExpectError dindexOfTruthy( x.length, null, 1 ); // $ExpectError dindexOfTruthy( x.length, {}, 1 ); // $ExpectError + dindexOfTruthy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -57,6 +59,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy( x.length, x, false ); // $ExpectError dindexOfTruthy( x.length, x, null ); // $ExpectError dindexOfTruthy( x.length, x, {} ); // $ExpectError + dindexOfTruthy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -83,6 +86,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy.ndarray( false, x, 1, 1 ); // $ExpectError dindexOfTruthy.ndarray( null, x, 1, 1 ); // $ExpectError dindexOfTruthy.ndarray( {}, x, 1, 1 ); // $ExpectError + dindexOfTruthy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -92,6 +96,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy.ndarray( x.length, false, 1, 1 ); // $ExpectError dindexOfTruthy.ndarray( x.length, null, 1, 1 ); // $ExpectError dindexOfTruthy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + dindexOfTruthy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -103,6 +108,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy.ndarray( x.length, x, false, 1 ); // $ExpectError dindexOfTruthy.ndarray( x.length, x, null, 1 ); // $ExpectError dindexOfTruthy.ndarray( x.length, x, {}, 1 ); // $ExpectError + dindexOfTruthy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -114,6 +120,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy.ndarray( x.length, x, 1, false ); // $ExpectError dindexOfTruthy.ndarray( x.length, x, 1, null ); // $ExpectError dindexOfTruthy.ndarray( x.length, x, 1, {} ); // $ExpectError + dindexOfTruthy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.js index 99cec89e225a..8edd65631af1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.native.js index d6ca36b8c639..87ccc006c965 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.js index e2adce4317cd..83b2fb3679d0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.js @@ -25,7 +25,7 @@ * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.native.js index 73e672600755..c5fb9d5356ff 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.js index a7285940201a..86b1a11a5158 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.js @@ -39,20 +39,9 @@ tape( 'the function returns the index of the first truthy element', function tes x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -80,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = dindexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -91,3 +80,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.native.js index 64d830fd57d8..896aeea02931 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.native.js @@ -48,20 +48,9 @@ tape( 'the function returns the index of the first truthy element', opts, functi x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = dindexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -100,3 +89,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.js index 79e16ca17790..14f589bdb88e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.js @@ -39,29 +39,9 @@ tape( 'the function returns the index of the first truthy element', function tes x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = dindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = dindexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -100,3 +80,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.native.js index 849091639973..cac7c8bf1af3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.native.js @@ -48,29 +48,9 @@ tape( 'the function returns the index of the first truthy element', opts, functi x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = dindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -98,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = dindexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -109,3 +89,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/README.md index 332ed0f19ba3..9d07774b7013 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/README.md @@ -125,7 +125,7 @@ var idx = gindexOfTruthy.ndarray( 3, x, 1, x.length-3 ); ## Notes -- If unable to find a truthy element, both functions return `-1`. +- Both functions explicitly treat `NaN` values as falsy. - 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-truthy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/docs/repl.txt index 9db73064820f..65f7f244fd1f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/docs/repl.txt @@ -10,6 +10,8 @@ If `N <= 0`, the function returns `-1`. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -28,10 +30,22 @@ Examples -------- + // Standard usage: > var x = [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ]; > var idx = {{alias}}( x.length, x, 1 ) 2 + // Using `N` and stride parameters: + > var x = [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ]; + > var idx = {{alias}}( 3, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 2 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first truthy element in a strided array using @@ -41,6 +55,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -62,9 +78,15 @@ Examples -------- + // Standard usage: > var x = [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ]; > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 2 + // Using an index offset: + > var x = [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ]; + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/docs/types/index.d.ts index d54df558477b..e03a159d54f5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/docs/types/index.d.ts @@ -36,7 +36,8 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. + * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array @@ -56,7 +57,8 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. + * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array @@ -78,7 +80,8 @@ interface Routine { * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/docs/types/test.ts index f7539ec6d796..1f31ce4b703a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/docs/types/test.ts @@ -39,6 +39,7 @@ import gindexOfTruthy = require( './index' ); gindexOfTruthy( false, x, 1 ); // $ExpectError gindexOfTruthy( null, x, 1 ); // $ExpectError gindexOfTruthy( {}, x, 1 ); // $ExpectError + gindexOfTruthy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a collection... @@ -48,6 +49,7 @@ import gindexOfTruthy = require( './index' ); gindexOfTruthy( x.length, false, 1 ); // $ExpectError gindexOfTruthy( x.length, null, 1 ); // $ExpectError gindexOfTruthy( x.length, {}, 1 ); // $ExpectError + gindexOfTruthy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -59,6 +61,7 @@ import gindexOfTruthy = require( './index' ); gindexOfTruthy( x.length, x, false ); // $ExpectError gindexOfTruthy( x.length, x, null ); // $ExpectError gindexOfTruthy( x.length, x, {} ); // $ExpectError + gindexOfTruthy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -86,6 +89,7 @@ import gindexOfTruthy = require( './index' ); gindexOfTruthy.ndarray( false, x, 1, 1 ); // $ExpectError gindexOfTruthy.ndarray( null, x, 1, 1 ); // $ExpectError gindexOfTruthy.ndarray( {}, x, 1, 1 ); // $ExpectError + gindexOfTruthy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a collection... @@ -95,6 +99,7 @@ import gindexOfTruthy = require( './index' ); gindexOfTruthy.ndarray( x.length, false, 1, 1 ); // $ExpectError gindexOfTruthy.ndarray( x.length, null, 1, 1 ); // $ExpectError gindexOfTruthy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + gindexOfTruthy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -106,6 +111,7 @@ import gindexOfTruthy = require( './index' ); gindexOfTruthy.ndarray( x.length, x, false, 1 ); // $ExpectError gindexOfTruthy.ndarray( x.length, x, null, 1 ); // $ExpectError gindexOfTruthy.ndarray( x.length, x, {}, 1 ); // $ExpectError + gindexOfTruthy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -117,6 +123,7 @@ import gindexOfTruthy = require( './index' ); gindexOfTruthy.ndarray( x.length, x, 1, false ); // $ExpectError gindexOfTruthy.ndarray( x.length, x, 1, null ); // $ExpectError gindexOfTruthy.ndarray( x.length, x, 1, {} ); // $ExpectError + gindexOfTruthy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/accessors.js index f2e2940dca07..723c89677f6f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/accessors.js @@ -25,7 +25,8 @@ * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @private * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/main.js index 7d7bc9fcc0fe..1693c6016ac3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/main.js @@ -31,7 +31,8 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/ndarray.js index fb73c83dbdbc..5ff4b59fefb8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/lib/ndarray.js @@ -31,7 +31,8 @@ var accessors = require( './accessors.js' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/test/test.main.js index d15493286107..2cd8052941f9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/test/test.main.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var gindexOfTruthy = require( './../lib' ); @@ -44,20 +45,9 @@ tape( 'the function returns the index of the first truthy element', function tes x = [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ]; - // Nonnegative stride... actual = gindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = gindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = gindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -67,20 +57,9 @@ tape( 'the function returns the index of the first truthy element (accessors)', x = toAccessorArray( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = gindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = gindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = gindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -132,7 +111,7 @@ tape( 'the function returns `-1` if unable to find a truthy element (accessors)' t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gindexOfTruthy( 0, [ 1.0, 2.0, 3.0 ], 1 ); @@ -144,7 +123,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gindexOfTruthy( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -155,3 +134,97 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]; + + actual = gindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]; + + actual = gindexOfTruthy( 3, toAccessorArray( x ), 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]; + + actual = gindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]; + + actual = gindexOfTruthy( 3, toAccessorArray( x ), -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = gindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/test/test.ndarray.js index 75c00fa21105..a96d777c85b7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy/test/test.ndarray.js @@ -44,156 +44,202 @@ tape( 'the function returns the index of the first truthy element', function tes x = [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ]; - // Nonnegative stride... actual = gindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = gindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); +}); - actual = gindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); +tape( 'the function returns the index of the first truthy element (accessors)', function test( t ) { + var actual; + var x; - actual = gindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = toAccessorArray( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Negative stride... - actual = gindexOfTruthy( x.length, x, -1, x.length-1 ); + actual = gindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = gindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', function test( t ) { + var actual; + var x; - actual = gindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + x = [ 0.0, NaN, 5.0, 0.0 ]; + + actual = gindexOfTruthy( x.length, x, 1, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first truthy element (accessors)', function test( t ) { +tape( 'the function ignores falsy elements (e.g., `0`, `NaN`) (accessors)', function test( t ) { var actual; var x; - x = toAccessorArray( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); + x = toAccessorArray( [ 0.0, NaN, 5.0, 0.0 ] ); - // Nonnegative stride... actual = gindexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); +}); - actual = gindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a truthy element', function test( t ) { + var actual; + var x; + + x = [ 0.0, 0.0, 0.0, 0.0 ]; - actual = gindexOfTruthy( 1, x, 1, 0 ); + actual = gindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = gindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = gindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a truthy element (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = gindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfTruthy( x.length, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - x = [ 0.0, 0.0, 0.0, 4.0, 0.0, 5.0 ]; + actual = gindexOfTruthy( 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfTruthy( 3, x, 1, 3 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfTruthy( -1, [ 1.0, 2.0, 3.0 ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; - var x; - x = toAccessorArray( [ 0.0, 0.0, 0.0, 4.0, 0.0, 5.0 ] ); + actual = gindexOfTruthy( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfTruthy( 3, x, 1, 3 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfTruthy( -1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; var x; - x = [ 0.0, NaN, 5.0, 0.0 ]; + x = [ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]; - actual = gindexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = gindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function ignores falsy elements (e.g., `0`, `NaN`) (accessors)', function test( t ) { +tape( 'the function supports an `x` stride (accessors)', function test( t ) { var actual; var x; - x = toAccessorArray( [ 0.0, NaN, 5.0, 0.0 ] ); + x = [ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]; - actual = gindexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = gindexOfTruthy( 3, toAccessorArray( x ), 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a truthy element', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = [ 0.0, 0.0, 0.0, 0.0 ]; + x = [ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]; - actual = gindexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a truthy element (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; - x = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = [ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]; - actual = gindexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfTruthy( 3, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; + var x; - actual = gindexOfTruthy( 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = [ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; - actual = gindexOfTruthy( -1, [ 1.0, 2.0, 3.0 ], 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function supports an `x` offset (accessors)', function test( t ) { var actual; + var x; - actual = gindexOfTruthy( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = [ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; - actual = gindexOfTruthy( -1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfTruthy( 3, toAccessorArray( x ), 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/README.md b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/README.md index 780cbacf1345..40e08c6a6ac7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/README.md @@ -135,7 +135,6 @@ var idx = sindexOfTruthy.ndarray( 3, x, 1, x.length-3 ); ## Notes -- If the function is unable to find a truthy element, the function returns `-1`. - Both functions explicitly treat `NaN` values as falsy. diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/repl.txt index aeca2eda0f85..18d6e406725f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/repl.txt @@ -11,6 +11,8 @@ If `N <= 0`, the function returns `-1`. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -29,10 +31,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 2 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 2 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first truthy element in a single-precision @@ -42,6 +56,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -63,9 +79,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 2 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/types/index.d.ts index 3c832d5cf470..a090b7848a16 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/types/test.ts index 4ff9a11e99bf..20681908f19f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/docs/types/test.ts @@ -37,6 +37,7 @@ import sindexOfTruthy = require( './index' ); sindexOfTruthy( false, x, 1 ); // $ExpectError sindexOfTruthy( null, x, 1 ); // $ExpectError sindexOfTruthy( {}, x, 1 ); // $ExpectError + sindexOfTruthy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float32Array... @@ -46,6 +47,7 @@ import sindexOfTruthy = require( './index' ); sindexOfTruthy( x.length, false, 1 ); // $ExpectError sindexOfTruthy( x.length, null, 1 ); // $ExpectError sindexOfTruthy( x.length, {}, 1 ); // $ExpectError + sindexOfTruthy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -57,6 +59,7 @@ import sindexOfTruthy = require( './index' ); sindexOfTruthy( x.length, x, false ); // $ExpectError sindexOfTruthy( x.length, x, null ); // $ExpectError sindexOfTruthy( x.length, x, {} ); // $ExpectError + sindexOfTruthy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -83,6 +86,7 @@ import sindexOfTruthy = require( './index' ); sindexOfTruthy.ndarray( false, x, 1, 1 ); // $ExpectError sindexOfTruthy.ndarray( null, x, 1, 1 ); // $ExpectError sindexOfTruthy.ndarray( {}, x, 1, 1 ); // $ExpectError + sindexOfTruthy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float32Array... @@ -92,6 +96,7 @@ import sindexOfTruthy = require( './index' ); sindexOfTruthy.ndarray( x.length, false, 1, 1 ); // $ExpectError sindexOfTruthy.ndarray( x.length, null, 1, 1 ); // $ExpectError sindexOfTruthy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + sindexOfTruthy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -103,6 +108,7 @@ import sindexOfTruthy = require( './index' ); sindexOfTruthy.ndarray( x.length, x, false, 1 ); // $ExpectError sindexOfTruthy.ndarray( x.length, x, null, 1 ); // $ExpectError sindexOfTruthy.ndarray( x.length, x, {}, 1 ); // $ExpectError + sindexOfTruthy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -114,6 +120,7 @@ import sindexOfTruthy = require( './index' ); sindexOfTruthy.ndarray( x.length, x, 1, false ); // $ExpectError sindexOfTruthy.ndarray( x.length, x, 1, null ); // $ExpectError sindexOfTruthy.ndarray( x.length, x, 1, {} ); // $ExpectError + sindexOfTruthy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/ndarray.js index 0c3ac0ef1973..9c55948997d7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/ndarray.js @@ -25,7 +25,7 @@ * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/ndarray.native.js index 979ab4673832..bf5c1e931525 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/sindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/sindex_of_truthy.js index 2171d19572d1..1246b5f17e48 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/sindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/sindex_of_truthy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/sindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/sindex_of_truthy.native.js index e3a5904b8b9f..37086cdbe0a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/sindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/lib/sindex_of_truthy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.ndarray.js index ad3788fb7fb8..47fdd237db18 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.ndarray.js @@ -39,29 +39,9 @@ tape( 'the function returns the index of the first truthy element', function tes x = new Float32Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = sindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = sindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = sindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = sindexOfTruthy( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -100,3 +80,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = sindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = sindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = sindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.ndarray.native.js index 8e9097b423c5..94c6698643e2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.ndarray.native.js @@ -48,29 +48,9 @@ tape( 'the function returns the index of the first truthy element', opts, functi x = new Float32Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = sindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = sindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = sindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -98,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = sindexOfTruthy( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -109,3 +89,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = sindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = sindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = sindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.sindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.sindex_of_truthy.js index 3cb0efdc80af..f3c62deac1ee 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.sindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.sindex_of_truthy.js @@ -39,20 +39,9 @@ tape( 'the function returns the index of the first truthy element', function tes x = new Float32Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = sindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = sindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = sindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -80,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = sindexOfTruthy( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -91,3 +80,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = sindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = sindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = sindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.sindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.sindex_of_truthy.native.js index 873186cf5a10..cbf85eefee17 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.sindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-truthy/test/test.sindex_of_truthy.native.js @@ -48,20 +48,9 @@ tape( 'the function returns the index of the first truthy element', opts, functi x = new Float32Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = sindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = sindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = sindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = sindexOfTruthy( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -100,3 +89,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = sindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = sindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = sindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/README.md b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/README.md index 0030cbdf3770..c1cd6a05a183 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/README.md @@ -44,13 +44,15 @@ var zindexOfTruthy = require( '@stdlib/blas/ext/base/zindex-of-truthy' ); Returns the index of the first truthy element in a double-precision complex floating-point strided array. + + ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 4.0, 5.0 ] ); +var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, 0.0 ] ); var idx = zindexOfTruthy( x.length, x, 1 ); -// returns 1 +// returns 2 ``` The function has the following parameters: @@ -64,7 +66,7 @@ If the function is unable to find a truthy element, the function returns `-1`. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); +var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); var idx = zindexOfTruthy( x.length, x, 1 ); // returns -1 @@ -77,39 +79,43 @@ The `N` and stride parameters determine which elements in the strided array are ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0, 9.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, 0.0 ] ); var idx = zindexOfTruthy( 4, x, 2 ); -// returns 2 +// returns 1 ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); // Initial array... -var x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +var x0 = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 5.0, 0.0, 0.0, 0.0 ] ); // Create an offset view... var x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element // Find index... -var idx = zindexOfTruthy( 2, x1, 1 ); -// returns 0 +var idx = zindexOfTruthy( 3, x1, 2 ); +// returns 1 ``` #### zindexOfTruthy.ndarray( N, x, strideX, offsetX ) Returns the index of the first truthy element in a double-precision complex floating-point strided array using alternative indexing semantics. + + ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 4.0, 5.0 ] ); +var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, 0.0 ] ); var idx = zindexOfTruthy.ndarray( x.length, x, 1, 0 ); -// returns 1 +// returns 2 ``` The function has the following additional parameters: @@ -118,10 +124,12 @@ The function has the following additional parameters: While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array: + + ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0 ] ); +var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); var idx = zindexOfTruthy.ndarray( 3, x, 1, x.length-3 ); // returns 2 @@ -138,7 +146,6 @@ var idx = zindexOfTruthy.ndarray( 3, x, 1, x.length-3 ); ## Notes - A complex number is truthy when at least one of its real or imaginary components is truthy. -- If unable to find a truthy element, both functions return `-1`. - Both functions explicitly treat `NaN` values as falsy. @@ -159,7 +166,7 @@ var Complex128Array = require( '@stdlib/array/complex128' ); var logEach = require( '@stdlib/console/log-each' ); var zindexOfTruthy = require( '@stdlib/blas/ext/base/zindex-of-truthy' ); -var buf = bernoulli( 10*2, 0.7, { +var buf = bernoulli( 10*2, 0.3, { 'dtype': 'float64' }); var x = new Complex128Array( buf.buffer ); @@ -206,10 +213,10 @@ Returns the index of the first truthy element in a double-precision complex floa ```c #include "stdlib/complex/float64/ctor.h" -const double x[] = { 0.0, 0.0, 1.0, 2.0 }; +const double x[] = { 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 }; -int idx = stdlib_strided_zindex_of_truthy( 2, (const stdlib_complex128_t *)x, 1 ); -// returns 1 +int idx = stdlib_strided_zindex_of_truthy( 4, (const stdlib_complex128_t *)x, 1 ); +// returns 2 ``` The function accepts the following arguments: @@ -229,10 +236,10 @@ Returns the index of the first truthy element in a double-precision complex floa ```c #include "stdlib/complex/float64/ctor.h" -const double x[] = { 0.0, 0.0, 1.0, 2.0 }; +const double x[] = { 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 }; -int idx = stdlib_strided_zindex_of_truthy_ndarray( 2, (const stdlib_complex128_t *)x, 1, 0 ); -// returns 1 +int idx = stdlib_strided_zindex_of_truthy_ndarray( 4, (const stdlib_complex128_t *)x, 1, 0 ); +// returns 2 ``` The function accepts the following arguments: @@ -257,7 +264,6 @@ CBLAS_INT stdlib_strided_zindex_of_truthy_ndarray( const CBLAS_INT N, const stdl ### Notes - A complex number is truthy when at least one of its real or imaginary components is truthy. -- If unable to find a truthy element, both functions return `-1`. - Both functions explicitly treat `NaN` values as falsy. @@ -277,10 +283,10 @@ CBLAS_INT stdlib_strided_zindex_of_truthy_ndarray( const CBLAS_INT N, const stdl int main( void ) { // Create a strided array (interleaved real and imaginary components): - const double x[] = { 0.0, 0.0, 1.0, 2.0, 4.0, 5.0, 6.0, 7.0 }; + const double x[] = { 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, 0.0 }; // Specify the number of indexed elements: - const int N = 4; + const int N = 8; // Specify a stride: const int strideX = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/benchmark/c/benchmark.length.c index faa1ac640b8c..2f8141786fa6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/benchmark/c/benchmark.length.c @@ -62,8 +62,8 @@ static void print_results( int iterations, double elapsed ) { double rate = (double)iterations / elapsed; printf( " ---\n" ); printf( " iterations: %d\n", iterations ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); + printf( " elapsed: %0.9\n", elapsed ); + printf( " rate: %0.9\n", rate ); printf( " ...\n" ); } @@ -83,7 +83,7 @@ static double tic( void ) { * * @return random number */ -static double rand_double( void ) { +static double rand_float( void ) { int r = rand(); return (double)r / ( (double)RAND_MAX + 1.0 ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/repl.txt index b359df93a40f..cb9d22e47e6b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/repl.txt @@ -14,7 +14,7 @@ A complex number is truthy when at least one of its real or imaginary components is truthy. - The function treats `NaN` values as falsy. + The function explicitly treats `NaN` values as falsy. Parameters ---------- @@ -34,10 +34,22 @@ Examples -------- - > var x = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 1.0, 2.0 ] ); + // Standard usage: + > var x = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); + > var idx = {{alias}}( 2, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 2, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first truthy element in a double-precision complex @@ -47,6 +59,11 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + A complex number is truthy when at least one of its real or imaginary + components is truthy. + + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -68,10 +85,15 @@ Examples -------- - > var x = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 1.0, 2.0 ] ); + // Standard usage: + > var x = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 1 + // Using an index offset: + > var x = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + > var idx = {{alias}}.ndarray( 2, x, 2, 1 ) + 1 + See Also -------- - diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/types/index.d.ts index c53c507b3609..61f95c28aef0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/types/index.d.ts @@ -18,6 +18,8 @@ // TypeScript Version: 4.1 +/// + import { Complex128Array } from '@stdlib/types/array'; /** @@ -30,7 +32,7 @@ interface Routine { * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -41,7 +43,7 @@ interface Routine { * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * - * var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0 ] ); + * var x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); * * var idx = zindexOfTruthy( x.length, x, 1 ); * // returns 1 @@ -54,7 +56,7 @@ interface Routine { * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -66,7 +68,7 @@ interface Routine { * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * - * var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0 ] ); + * var x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); * * var idx = zindexOfTruthy.ndarray( x.length, x, 1, 0 ); * // returns 1 @@ -80,7 +82,7 @@ interface Routine { * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -91,7 +93,7 @@ interface Routine { * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0 ] ); +* var x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); * * var idx = zindexOfTruthy( x.length, x, 1 ); * // returns 1 @@ -99,7 +101,7 @@ interface Routine { * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0 ] ); +* var x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); * * var idx = zindexOfTruthy.ndarray( x.length, x, 1, 0 ); * // returns 1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/types/test.ts index 78b08a0bd288..49983362b138 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/docs/types/test.ts @@ -26,108 +26,115 @@ import zindexOfTruthy = require( './index' ); // The function returns a number... { - var x = new Complex128Array( [ 1.0, 2.0, 3.0 ] ); + var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); zindexOfTruthy( x.length, x, 1 ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... { - var x = new Complex128Array( [ 1.0, 2.0, 3.0 ] ); + var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); zindexOfTruthy( '1', x, 1 ); // $ExpectError zindexOfTruthy( true, x, 1 ); // $ExpectError zindexOfTruthy( false, x, 1 ); // $ExpectError zindexOfTruthy( null, x, 1 ); // $ExpectError zindexOfTruthy( {}, x, 1 ); // $ExpectError + zindexOfTruthy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Complex128Array... { - var x = new Complex128Array( [ 1.0, 2.0, 3.0 ] ); + var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); zindexOfTruthy( x.length, '1', 1 ); // $ExpectError zindexOfTruthy( x.length, true, 1 ); // $ExpectError zindexOfTruthy( x.length, false, 1 ); // $ExpectError zindexOfTruthy( x.length, null, 1 ); // $ExpectError zindexOfTruthy( x.length, {}, 1 ); // $ExpectError + zindexOfTruthy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... { - var x = new Complex128Array( [ 1.0, 2.0, 3.0 ] ); + var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); zindexOfTruthy( x.length, x, '1' ); // $ExpectError zindexOfTruthy( x.length, x, true ); // $ExpectError zindexOfTruthy( x.length, x, false ); // $ExpectError zindexOfTruthy( x.length, x, null ); // $ExpectError zindexOfTruthy( x.length, x, {} ); // $ExpectError + zindexOfTruthy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { zindexOfTruthy(); // $ExpectError zindexOfTruthy( 3 ); // $ExpectError - zindexOfTruthy( 3, new Complex128Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError - zindexOfTruthy( 3, new Complex128Array( [ 1.0, 2.0, 3.0 ] ), 1, {} ); // $ExpectError + zindexOfTruthy( 3, new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ) ); // $ExpectError + zindexOfTruthy( 3, new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... { - var x = new Complex128Array( [ 1.0, 2.0, 3.0 ] ); + var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); zindexOfTruthy.ndarray( x.length, x, 1, 0 ); // $ExpectType number } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... { - var x = new Complex128Array( [ 1.0, 2.0, 3.0 ] ); + var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); zindexOfTruthy.ndarray( '1', x, 1, 1 ); // $ExpectError zindexOfTruthy.ndarray( true, x, 1, 1 ); // $ExpectError zindexOfTruthy.ndarray( false, x, 1, 1 ); // $ExpectError zindexOfTruthy.ndarray( null, x, 1, 1 ); // $ExpectError zindexOfTruthy.ndarray( {}, x, 1, 1 ); // $ExpectError + zindexOfTruthy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex128Array... { - var x = new Complex128Array( [ 1.0, 2.0, 3.0 ] ); + var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); zindexOfTruthy.ndarray( x.length, '1', 1, 1 ); // $ExpectError zindexOfTruthy.ndarray( x.length, true, 1, 1 ); // $ExpectError zindexOfTruthy.ndarray( x.length, false, 1, 1 ); // $ExpectError zindexOfTruthy.ndarray( x.length, null, 1, 1 ); // $ExpectError zindexOfTruthy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + zindexOfTruthy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... { - var x = new Complex128Array( [ 1.0, 2.0, 3.0 ] ); + var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); zindexOfTruthy.ndarray( x.length, x, '1', 1 ); // $ExpectError zindexOfTruthy.ndarray( x.length, x, true, 1 ); // $ExpectError zindexOfTruthy.ndarray( x.length, x, false, 1 ); // $ExpectError zindexOfTruthy.ndarray( x.length, x, null, 1 ); // $ExpectError zindexOfTruthy.ndarray( x.length, x, {}, 1 ); // $ExpectError + zindexOfTruthy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... { - var x = new Complex128Array( [ 1.0, 2.0, 3.0 ] ); + var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); zindexOfTruthy.ndarray( x.length, x, 1, '1' ); // $ExpectError zindexOfTruthy.ndarray( x.length, x, 1, true ); // $ExpectError zindexOfTruthy.ndarray( x.length, x, 1, false ); // $ExpectError zindexOfTruthy.ndarray( x.length, x, 1, null ); // $ExpectError zindexOfTruthy.ndarray( x.length, x, 1, {} ); // $ExpectError + zindexOfTruthy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... { zindexOfTruthy.ndarray(); // $ExpectError zindexOfTruthy.ndarray( 3 ); // $ExpectError - zindexOfTruthy.ndarray( 3, new Complex128Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError - zindexOfTruthy.ndarray( 3, new Complex128Array( [ 1.0, 2.0, 3.0 ] ), 1 ); // $ExpectError - zindexOfTruthy.ndarray( 3, new Complex128Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, {} ); // $ExpectError + zindexOfTruthy.ndarray( 3, new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ) ); // $ExpectError + zindexOfTruthy.ndarray( 3, new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 1 ); // $ExpectError + zindexOfTruthy.ndarray( 3, new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/examples/c/example.c index 5616071f22e9..5b7d28c8c787 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/examples/c/example.c @@ -22,10 +22,10 @@ int main( void ) { // Create a strided array (interleaved real and imaginary components): - const double x[] = { 0.0, 0.0, 1.0, 2.0, 4.0, 5.0, 6.0, 7.0 }; + const double x[] = { 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, 0.0 }; // Specify the number of indexed elements: - const int N = 4; + const int N = 8; // Specify a stride: const int strideX = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/examples/index.js index b78478e8caae..4774bf828254 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/examples/index.js @@ -23,7 +23,7 @@ var Complex128Array = require( '@stdlib/array/complex128' ); var logEach = require( '@stdlib/console/log-each' ); var zindexOfTruthy = require( './../lib' ); -var buf = bernoulli( 10*2, 0.7, { +var buf = bernoulli( 10*2, 0.3, { 'dtype': 'float64' }); var x = new Complex128Array( buf.buffer ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/index.js index 91c74bd74bea..169a94569cd1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/index.js @@ -27,19 +27,19 @@ * var Complex128Array = require( '@stdlib/array/complex128' ); * var zindexOfTruthy = require( '@stdlib/blas/ext/base/zindex-of-truthy' ); * -* var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 4.0, 5.0 ] ); +* var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, 0.0 ] ); * * var idx = zindexOfTruthy( x.length, x, 1 ); -* // returns 1 +* // returns 2 * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * var zindexOfTruthy = require( '@stdlib/blas/ext/base/zindex-of-truthy' ); * -* var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 4.0, 5.0 ] ); +* var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, 0.0 ] ); * * var idx = zindexOfTruthy.ndarray( x.length, x, 1, 0 ); -* // returns 1 +* // returns 2 */ // MODULES // diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/ndarray.js index 0325125b0ab5..bcad6a1e1822 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/ndarray.js @@ -31,7 +31,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -43,10 +43,10 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 4.0, 5.0 ] ); +* var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, 0.0 ] ); * * var idx = zindexOfTruthy( x.length, x, 1, 0 ); -* // returns 1 +* // returns 2 */ function zindexOfTruthy( N, x, strideX, offsetX ) { var view; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/ndarray.native.js index c518a436ebb0..aa95d6f35eac 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/ndarray.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -44,10 +44,10 @@ var addon = require( './../src/addon.node' ); * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 4.0, 5.0 ] ); +* var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, 0.0 ] ); * * var idx = zindexOfTruthy( x.length, x, 1, 0 ); -* // returns 1 +* // returns 2 */ function zindexOfTruthy( N, x, strideX, offsetX ) { var view = reinterpret( x, 0 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/zindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/zindex_of_truthy.js index 927c7488d73d..af8bdbd54c3f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/zindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/zindex_of_truthy.js @@ -32,7 +32,7 @@ var ndarray = require( './ndarray.js' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -43,10 +43,10 @@ var ndarray = require( './ndarray.js' ); * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 4.0, 5.0 ] ); +* var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, 0.0 ] ); * * var idx = zindexOfTruthy( x.length, x, 1 ); -* // returns 1 +* // returns 2 */ function zindexOfTruthy( N, x, strideX ) { return ndarray( N, x, strideX, stride2offset( N, strideX ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/zindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/zindex_of_truthy.native.js index aaae89e18f79..ee69e479b674 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/zindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/lib/zindex_of_truthy.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -43,10 +43,10 @@ var addon = require( './../src/addon.node' ); * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 4.0, 5.0 ] ); +* var x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, -1.0, 0.0, 3.0, 0.0 ] ); * * var idx = zindexOfTruthy( x.length, x, 1 ); -* // returns 1 +* // returns 2 */ function zindexOfTruthy( N, x, strideX ) { var view = reinterpret( x, 0 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/src/addon.c index daf5152cc213..a9f70bfb7633 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/src/addon.c @@ -18,6 +18,7 @@ #include "stdlib/blas/ext/base/zindex_of_truthy.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" #include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" #include "stdlib/napi/argv_int64.h" diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.ndarray.js index 17ad7be49605..cb5965b11130 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.ndarray.js @@ -44,37 +44,17 @@ tape( 'the function returns the index of the first truthy element', function tes 1.0, 0.0, 0.0, - 2.0, - 2.0, - 3.0, - 3.0, + 0.0, + 0.0, + 1.0, + 1.0, 0.0, 0.0 ]); - // Nonnegative stride... actual = zindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = zindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = zindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = zindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -120,7 +100,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -129,8 +109,10 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than 1.0, 0.0, 0.0, + 2.0, + 2.0, 3.0, - 4.0 + 3.0 ]); actual = zindexOfTruthy( 0, x, 1, 0 ); @@ -141,3 +123,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 0.0, // 0 + 0.0, // 0 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 3.0, + 3.0, + 4.0, // 2 + 4.0 // 2 + ]); + + actual = zindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = zindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + actual = zindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.ndarray.native.js index a26a2388aa5b..c87e32ef14ec 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.ndarray.native.js @@ -53,37 +53,17 @@ tape( 'the function returns the index of the first truthy element', opts, functi 1.0, 0.0, 0.0, - 2.0, - 2.0, - 3.0, - 3.0, + 0.0, + 0.0, + 1.0, + 1.0, 0.0, 0.0 ]); - // Nonnegative stride... actual = zindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = zindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = zindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = zindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -129,7 +109,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -138,8 +118,10 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than 1.0, 0.0, 0.0, + 2.0, + 2.0, 3.0, - 4.0 + 3.0 ]); actual = zindexOfTruthy( 0, x, 1, 0 ); @@ -150,3 +132,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 0.0, // 0 + 0.0, // 0 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 3.0, + 3.0, + 4.0, // 2 + 4.0 // 2 + ]); + + actual = zindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = zindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + actual = zindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.zindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.zindex_of_truthy.js index 96da7d86b6df..7a1a519d5130 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.zindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.zindex_of_truthy.js @@ -52,20 +52,9 @@ tape( 'the function returns the index of the first truthy element', function tes 0.0 ]); - // Nonnegative stride... actual = zindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = zindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = zindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -111,24 +100,88 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; + + actual = zindexOfTruthy( 0, new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 1 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = zindexOfTruthy( -1, new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 1 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { var actual; var x; x = new Complex128Array([ + 0.0, // 0 + 0.0, // 0 1.0, 1.0, - 0.0, - 0.0, + 2.0, // 1 + 2.0, // 1 + 3.0, 3.0, - 4.0 + 4.0, // 2 + 4.0 // 2 ]); - actual = zindexOfTruthy( 0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = zindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - actual = zindexOfTruthy( -1, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = zindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex128Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = zindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.zindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.zindex_of_truthy.native.js index 09acc9f73e11..392ba34d7e9b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.zindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-truthy/test/test.zindex_of_truthy.native.js @@ -61,20 +61,9 @@ tape( 'the function returns the index of the first truthy element', opts, functi 0.0 ]); - // Nonnegative stride... actual = zindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = zindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = zindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -120,24 +109,88 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; + + actual = zindexOfTruthy( 0, new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 1 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = zindexOfTruthy( -1, new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 1 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; var x; x = new Complex128Array([ + 0.0, // 0 + 0.0, // 0 1.0, 1.0, - 0.0, - 0.0, + 2.0, // 1 + 2.0, // 1 + 3.0, 3.0, - 4.0 + 4.0, // 2 + 4.0 // 2 ]); - actual = zindexOfTruthy( 0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = zindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - actual = zindexOfTruthy( -1, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = zindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex128Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = zindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); From 4315045acec7871c6fd452860ff545a29fcf6df8 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 9 Sep 2026 23:14:48 +0500 Subject: [PATCH 04/68] fix: refactor `index-of-falsy` --- .../blas/ext/base/cindex-of-falsy/README.md | 2 - .../ext/base/cindex-of-falsy/docs/repl.txt | 25 ++- .../cindex-of-falsy/docs/types/index.d.ts | 6 +- .../base/cindex-of-falsy/docs/types/test.ts | 7 + .../cindex-of-falsy/lib/cindex_of_falsy.js | 2 +- .../lib/cindex_of_falsy.native.js | 2 +- .../ext/base/cindex-of-falsy/lib/ndarray.js | 2 +- .../cindex-of-falsy/lib/ndarray.native.js | 2 +- .../test/test.cindex_of_falsy.js | 87 +++++++-- .../test/test.cindex_of_falsy.native.js | 87 +++++++-- .../base/cindex-of-falsy/test/test.ndarray.js | 93 ++++++--- .../test/test.ndarray.native.js | 93 ++++++--- .../blas/ext/base/dindex-of-falsy/README.md | 21 ++- .../ext/base/dindex-of-falsy/docs/repl.txt | 26 ++- .../dindex-of-falsy/docs/types/index.d.ts | 22 +-- .../base/dindex-of-falsy/docs/types/test.ts | 13 +- .../base/dindex-of-falsy/examples/c/example.c | 2 +- .../dindex-of-falsy/lib/dindex_of_falsy.js | 4 +- .../lib/dindex_of_falsy.native.js | 4 +- .../ext/base/dindex-of-falsy/lib/index.js | 4 +- .../ext/base/dindex-of-falsy/lib/ndarray.js | 4 +- .../dindex-of-falsy/lib/ndarray.native.js | 4 +- .../test/test.dindex_of_falsy.js | 79 ++++++-- .../test/test.dindex_of_falsy.native.js | 79 ++++++-- .../base/dindex-of-falsy/test/test.ndarray.js | 85 ++++++--- .../test/test.ndarray.native.js | 85 ++++++--- .../blas/ext/base/gindex-of-falsy/README.md | 2 +- .../ext/base/gindex-of-falsy/docs/repl.txt | 22 +++ .../gindex-of-falsy/docs/types/index.d.ts | 9 +- .../base/gindex-of-falsy/docs/types/test.ts | 7 + .../ext/base/gindex-of-falsy/lib/accessors.js | 3 +- .../blas/ext/base/gindex-of-falsy/lib/main.js | 3 +- .../ext/base/gindex-of-falsy/lib/ndarray.js | 3 +- .../base/gindex-of-falsy/test/test.main.js | 121 +++++++++--- .../base/gindex-of-falsy/test/test.ndarray.js | 176 +++++++++++------- .../blas/ext/base/sindex-of-falsy/README.md | 1 - .../ext/base/sindex-of-falsy/docs/repl.txt | 20 ++ .../sindex-of-falsy/docs/types/index.d.ts | 6 +- .../base/sindex-of-falsy/docs/types/test.ts | 7 + .../ext/base/sindex-of-falsy/lib/ndarray.js | 2 +- .../sindex-of-falsy/lib/ndarray.native.js | 2 +- .../sindex-of-falsy/lib/sindex_of_falsy.js | 2 +- .../lib/sindex_of_falsy.native.js | 2 +- .../base/sindex-of-falsy/test/test.ndarray.js | 77 +++++--- .../test/test.ndarray.native.js | 77 +++++--- .../test/test.sindex_of_falsy.js | 71 +++++-- .../test/test.sindex_of_falsy.native.js | 71 +++++-- .../blas/ext/base/zindex-of-falsy/README.md | 2 - .../ext/base/zindex-of-falsy/docs/repl.txt | 25 ++- .../zindex-of-falsy/docs/types/index.d.ts | 6 +- .../base/zindex-of-falsy/docs/types/test.ts | 7 + .../ext/base/zindex-of-falsy/lib/ndarray.js | 2 +- .../zindex-of-falsy/lib/ndarray.native.js | 2 +- .../zindex-of-falsy/lib/zindex_of_falsy.js | 2 +- .../lib/zindex_of_falsy.native.js | 2 +- .../base/zindex-of-falsy/test/test.ndarray.js | 93 ++++++--- .../test/test.ndarray.native.js | 93 ++++++--- .../test/test.zindex_of_falsy.js | 87 +++++++-- .../test/test.zindex_of_falsy.native.js | 87 +++++++-- 59 files changed, 1490 insertions(+), 442 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/README.md b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/README.md index 98edfd16b85c..2f32b99e305b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/README.md @@ -138,7 +138,6 @@ var idx = cindexOfFalsy.ndarray( 3, x, 1, x.length-3 ); ## Notes - A complex number is falsy when both its real and imaginary components are falsy. -- If unable to find a falsy element, both functions return `-1`. - Both functions explicitly treat `NaN` values as falsy. @@ -257,7 +256,6 @@ CBLAS_INT stdlib_strided_cindex_of_falsy_ndarray( const CBLAS_INT N, const stdli ### Notes - A complex number is falsy when both its real and imaginary components are falsy. -- If unable to find a falsy element, both functions return `-1`. - Both functions explicitly treat `NaN` values as falsy. diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/repl.txt index 4c66051f1b68..3b08ce65ca90 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/repl.txt @@ -14,7 +14,7 @@ A complex number is falsy when both its real and imaginary components are falsy. - The function treats `NaN` values as falsy. + The function explicitly treats `NaN` values as falsy. Parameters ---------- @@ -34,10 +34,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 0.0, 0.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 5.0, 6.0 ] ); + > var idx = {{alias}}( 2, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0, 0.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 2, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first falsy element in a single-precision complex @@ -47,6 +59,11 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + A complex number is falsy when both its real and imaginary components are + falsy. + + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -68,10 +85,16 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 0.0, 0.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 1 + // Using an index offset: + > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0, 0.0 ] ); + > var idx = {{alias}}.ndarray( 2, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/index.d.ts index e53d8b626d5f..b015ab203076 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/index.d.ts @@ -30,7 +30,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -54,7 +54,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -80,7 +80,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/test.ts index 990c56b2cbb9..5fe719cc4e7f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/test.ts @@ -40,6 +40,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy( false, x, 1 ); // $ExpectError cindexOfFalsy( null, x, 1 ); // $ExpectError cindexOfFalsy( {}, x, 1 ); // $ExpectError + cindexOfFalsy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Complex64Array... @@ -51,6 +52,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy( x.length, false, 1 ); // $ExpectError cindexOfFalsy( x.length, null, 1 ); // $ExpectError cindexOfFalsy( x.length, {}, 1 ); // $ExpectError + cindexOfFalsy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -62,6 +64,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy( x.length, x, false ); // $ExpectError cindexOfFalsy( x.length, x, null ); // $ExpectError cindexOfFalsy( x.length, x, {} ); // $ExpectError + cindexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -88,6 +91,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError cindexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError cindexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + cindexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex64Array... @@ -99,6 +103,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy.ndarray( x.length, false, 1, 1 ); // $ExpectError cindexOfFalsy.ndarray( x.length, null, 1, 1 ); // $ExpectError cindexOfFalsy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + cindexOfFalsy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -110,6 +115,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError cindexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError cindexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + cindexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -121,6 +127,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError cindexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError cindexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + cindexOfFalsy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.js index b6d9f55b5230..7437829b76a5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.js @@ -32,7 +32,7 @@ var ndarray = require( './ndarray.js' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.native.js index 750b70173344..d6351b6185f6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.js index c6db468e304f..9adbf01841fd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.js @@ -31,7 +31,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.native.js index 853da1c5f83a..a19e8696c167 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.js index 553d9b3b0ca7..d6da7c96d5a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.js @@ -52,20 +52,9 @@ tape( 'the function returns the index of the first falsy element', function test 1.0 ]); - // Nonnegative stride... actual = cindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = cindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -111,7 +100,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -132,3 +121,77 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = cindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.native.js index 5584f74f1a2e..5a2d7735b473 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.native.js @@ -61,20 +61,9 @@ tape( 'the function returns the index of the first falsy element', opts, functio 1.0 ]); - // Nonnegative stride... actual = cindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = cindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -120,7 +109,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -141,3 +130,77 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = cindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.js index 61f52260c6d9..892235467981 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.js @@ -52,29 +52,9 @@ tape( 'the function returns the index of the first falsy element', function test 1.0 ]); - // Nonnegative stride... actual = cindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -120,7 +100,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -141,3 +121,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = cindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.native.js index 5bb7efb71820..f03d8fe7760e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.native.js @@ -61,29 +61,9 @@ tape( 'the function returns the index of the first falsy element', opts, functio 1.0 ]); - // Nonnegative stride... actual = cindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -129,7 +109,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -150,3 +130,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = cindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/README.md b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/README.md index bfa4b21dc416..115be12b3fa7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/README.md @@ -47,7 +47,7 @@ Returns the index of the first falsy element in a double-precision floating-poin ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); var idx = dindexOfFalsy( x.length, x, 1 ); // returns 2 @@ -75,7 +75,7 @@ The `N` and stride parameters determine which elements in the strided array are ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); var idx = dindexOfFalsy( 4, x, 2 ); // returns 1 @@ -87,7 +87,7 @@ Note that indexing is relative to the first index. To introduce an offset, use [ var Float64Array = require( '@stdlib/array/float64' ); // Initial array... -var x0 = new Float64Array( [ 3.0, 3.0, 3.0, 0.0, 5.0, 3.0 ] ); +var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); // Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element @@ -104,7 +104,7 @@ Returns the index of the first falsy element in a double-precision floating-poin ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); var idx = dindexOfFalsy.ndarray( x.length, x, 1, 0 ); // returns 2 @@ -119,7 +119,7 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, 3.0, 0.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 0.0 ] ); var idx = dindexOfFalsy.ndarray( 3, x, 1, x.length-3 ); // returns 2 @@ -135,7 +135,6 @@ var idx = dindexOfFalsy.ndarray( 3, x, 1, x.length-3 ); ## Notes -- If the function is unable to find a falsy element, the function returns `-1`. - Both functions explicitly treat `NaN` values as falsy. @@ -198,7 +197,7 @@ console.log( idx ); Returns the index of the first falsy element in a double-precision floating-point strided array. ```c -const double x[] = { 3.0, 3.0, 0.0, 4.0 }; +const double x[] = { 1.0, 2.0, 0.0, 3.0 }; int idx = stdlib_strided_dindex_of_falsy( 4, x, 1 ); // returns 2 @@ -219,7 +218,7 @@ CBLAS_INT stdlib_strided_dindex_of_falsy( const CBLAS_INT N, const double *X, co Returns the index of the first falsy element in a double-precision floating-point strided array using alternative indexing semantics. ```c -const double x[] = { 3.0, 3.0, 0.0, 4.0 }; +const double x[] = { 1.0, 2.0, 0.0, 3.0 }; int idx = stdlib_strided_dindex_of_falsy_ndarray( 4, x, 1, 0 ); // returns 2 @@ -264,7 +263,7 @@ CBLAS_INT stdlib_strided_dindex_of_falsy_ndarray( const CBLAS_INT N, const doubl int main( void ) { // Create a strided array: - const double x[] = { 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 }; + const double x[] = { 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; // Specify the number of indexed elements: const int N = 8; @@ -312,6 +311,10 @@ int main( void ) { [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/repl.txt index 0cd12038bebc..766be7b1ce62 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/repl.txt @@ -9,7 +9,7 @@ Indexing is relative to the first index. To introduce an offset, use a typed array view. - if `N <= 0`, the function returns `-1`. + If `N <= 0`, the function returns `-1`. The function explicitly treats `NaN` values as falsy. @@ -31,10 +31,22 @@ Examples -------- - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 3.0, 0.0, 2.0, 4.0, 1.0 ] ); + // Standard usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 2 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first falsy element in a double-precision floating- @@ -44,6 +56,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -65,9 +79,15 @@ Examples -------- - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 3.0, 0.0, 2.0, 4.0, 1.0 ] ); + // Standard usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 2 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/index.d.ts index 3400f7cf146d..309ae6a54158 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -38,10 +38,10 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var x = new Float64Array( [ 1.0, 0.0, 3.0, 2.0 ] ); + * var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1 ); - * // returns 1 + * // returns 2 */ ( N: number, x: Float64Array, strideX: number ): number; @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -62,10 +62,10 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var x = new Float64Array( [ 1.0, 0.0, 3.0, 2.0 ] ); + * var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dindexOfFalsy.ndarray( x.length, x, 1, 0 ); - * // returns 1 + * // returns 2 */ ndarray( N: number, x: Float64Array, strideX: number, offsetX: number ): number; } @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -86,18 +86,18 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 0.0, 3.0, 2.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1 ); -* // returns 1 +* // returns 2 * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 0.0, 3.0, 2.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dindexOfFalsy.ndarray( x.length, x, 1, 0 ); -* // returns 1 +* // returns 2 */ declare var dindexOfFalsy: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/test.ts index ad30f74e15a7..8aabdc9e08cd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/test.ts @@ -16,8 +16,6 @@ * limitations under the License. */ -/* eslint-disable space-in-parens */ - import dindexOfFalsy = require( './index' ); @@ -39,6 +37,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy( false, x, 1 ); // $ExpectError dindexOfFalsy( null, x, 1 ); // $ExpectError dindexOfFalsy( {}, x, 1 ); // $ExpectError + dindexOfFalsy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... @@ -48,6 +47,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy( x.length, false, 1 ); // $ExpectError dindexOfFalsy( x.length, null, 1 ); // $ExpectError dindexOfFalsy( x.length, {}, 1 ); // $ExpectError + dindexOfFalsy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -59,6 +59,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy( x.length, x, false ); // $ExpectError dindexOfFalsy( x.length, x, null ); // $ExpectError dindexOfFalsy( x.length, x, {} ); // $ExpectError + dindexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -66,7 +67,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy(); // $ExpectError dindexOfFalsy( 3 ); // $ExpectError dindexOfFalsy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError - dindexOfFalsy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // $ExpectError + dindexOfFalsy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -85,6 +86,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError dindexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError dindexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + dindexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -94,6 +96,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy.ndarray( x.length, false, 1, 1 ); // $ExpectError dindexOfFalsy.ndarray( x.length, null, 1, 1 ); // $ExpectError dindexOfFalsy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + dindexOfFalsy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -105,6 +108,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError dindexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError dindexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + dindexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -116,6 +120,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError dindexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError dindexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + dindexOfFalsy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -124,5 +129,5 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy.ndarray( 3 ); // $ExpectError dindexOfFalsy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError dindexOfFalsy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); // $ExpectError - dindexOfFalsy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, 0 ); // $ExpectError + dindexOfFalsy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/examples/c/example.c index 66744f037476..be8f8b65fb43 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/examples/c/example.c @@ -21,7 +21,7 @@ int main( void ) { // Create a strided array: - const double x[] = { 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 }; + const double x[] = { 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; // Specify the number of indexed elements: const int N = 8; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.js index ce6232d3adf7..5aac21692d62 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -42,7 +42,7 @@ var ndarray = require( './ndarray.js' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1 ); * // returns 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.native.js index 1c43bb1f28df..145bdcd32d53 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -41,7 +41,7 @@ var addon = require( './../src/addon.node' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1 ); * // returns 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/index.js index 0e6aa8ee8568..1f05c71f4012 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/index.js @@ -27,7 +27,7 @@ * var Float64Array = require( '@stdlib/array/float64' ); * var dindexOfFalsy = require( '@stdlib/blas/ext/base/dindex-of-falsy' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1 ); * // returns 2 @@ -36,7 +36,7 @@ * var Float64Array = require( '@stdlib/array/float64' ); * var dindexOfFalsy = require( '@stdlib/blas/ext/base/dindex-of-falsy' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy.ndarray( x.length, x, 1, 0 ); * // returns 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.js index 49660995cb4d..84344f8f1265 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.js @@ -25,7 +25,7 @@ * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -37,7 +37,7 @@ * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1, 0 ); * // returns 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.native.js index 307d81d8ce76..78fb3f62ccb9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -42,7 +42,7 @@ var addon = require( './../src/addon.node' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1, 0 ); * // returns 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.js index 89cd9d5a03d3..46072a796a95 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.js @@ -39,28 +39,17 @@ tape( 'the function returns the index of the first falsy element', function test x = new Float64Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = dindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); -tape( 'the function treats `NaN` values as falsy (e.g., `NaN`, `0`)', function test( t ) { +tape( 'the function treats `NaN` values as falsy', function test( t ) { var actual; var x; - x = new Float64Array( [ 3.0, 5.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); @@ -80,14 +69,72 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1 ); + actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1 ); + actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.native.js index f9795d29370d..890123af48f5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.native.js @@ -48,28 +48,17 @@ tape( 'the function returns the index of the first falsy element', opts, functio x = new Float64Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = dindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); -tape( 'the function treats `NaN` values as falsy (e.g., `NaN`, `0`)', opts, function test( t ) { +tape( 'the function treats `NaN` values as falsy', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 3.0, 5.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); @@ -89,14 +78,72 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1 ); + actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1 ); + actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.js index 9a8cd31944f6..f3a8eadc66ab 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.js @@ -39,37 +39,17 @@ tape( 'the function returns the index of the first falsy element', function test x = new Float64Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = dindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = dindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); -tape( 'the function treats `NaN` values as falsy (e.g., `NaN`, `0`)', function test( t ) { +tape( 'the function treats `NaN` values as falsy', function test( t ) { var actual; var x; - x = new Float64Array( [ 3.0, 5.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); @@ -89,14 +69,69 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); + actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); + actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.native.js index 39bee715d0c6..8c9438ae0920 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.native.js @@ -48,37 +48,17 @@ tape( 'the function returns the index of the first falsy element', opts, functio x = new Float64Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = dindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = dindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); -tape( 'the function treats `NaN` values as falsy (e.g., `NaN`, `0`)', opts, function test( t ) { +tape( 'the function treats `NaN` values as falsy', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 3.0, 5.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); @@ -98,14 +78,69 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); + actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); + actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/README.md index 7280bbc9958b..b7a67274e754 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/README.md @@ -125,7 +125,7 @@ var idx = gindexOfFalsy.ndarray( 3, x, 1, x.length-3 ); ## Notes -- If unable to find a falsy element, both functions return `-1`. +- Both functions explicitly treat `NaN` values as falsy. - 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-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/docs/repl.txt index 8159e58745cb..6531e446225a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/docs/repl.txt @@ -10,6 +10,8 @@ If `N <= 0`, the function returns `-1`. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -28,10 +30,22 @@ Examples -------- + // Standard usage: > var x = [ 1.0, 3.0, 0.0, 2.0, 0.0, 3.0 ]; > var idx = {{alias}}( x.length, x, 1 ) 2 + // Using `N` and stride parameters: + > var x = [ 1.0, 3.0, 0.0, 2.0, 0.0, 3.0 ]; + > var idx = {{alias}}( 3, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first falsy element in a strided array using @@ -41,6 +55,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -62,9 +78,15 @@ Examples -------- + // Standard usage: > var x = [ 1.0, 3.0, 0.0, 2.0, 0.0, 3.0 ]; > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 2 + // Using an index offset: + > var x = [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ]; + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/docs/types/index.d.ts index df71f45c311a..c4c0ba93a278 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/docs/types/index.d.ts @@ -36,7 +36,8 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. + * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array @@ -56,7 +57,8 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. + * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array @@ -78,7 +80,8 @@ interface Routine { * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/docs/types/test.ts index 2aa2126a2acb..4ae1493aa1b3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/docs/types/test.ts @@ -39,6 +39,7 @@ import gindexOfFalsy = require( './index' ); gindexOfFalsy( false, x, 1 ); // $ExpectError gindexOfFalsy( null, x, 1 ); // $ExpectError gindexOfFalsy( {}, x, 1 ); // $ExpectError + gindexOfFalsy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a collection... @@ -48,6 +49,7 @@ import gindexOfFalsy = require( './index' ); gindexOfFalsy( x.length, false, 1 ); // $ExpectError gindexOfFalsy( x.length, null, 1 ); // $ExpectError gindexOfFalsy( x.length, {}, 1 ); // $ExpectError + gindexOfFalsy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -59,6 +61,7 @@ import gindexOfFalsy = require( './index' ); gindexOfFalsy( x.length, x, false ); // $ExpectError gindexOfFalsy( x.length, x, null ); // $ExpectError gindexOfFalsy( x.length, x, {} ); // $ExpectError + gindexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -86,6 +89,7 @@ import gindexOfFalsy = require( './index' ); gindexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError gindexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError gindexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + gindexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a collection... @@ -95,6 +99,7 @@ import gindexOfFalsy = require( './index' ); gindexOfFalsy.ndarray( x.length, false, 1, 1 ); // $ExpectError gindexOfFalsy.ndarray( x.length, null, 1, 1 ); // $ExpectError gindexOfFalsy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + gindexOfFalsy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -106,6 +111,7 @@ import gindexOfFalsy = require( './index' ); gindexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError gindexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError gindexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + gindexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -117,6 +123,7 @@ import gindexOfFalsy = require( './index' ); gindexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError gindexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError gindexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + gindexOfFalsy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/accessors.js index d7741dd90f36..f04a64ca1bf8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/accessors.js @@ -25,7 +25,8 @@ * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @private * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/main.js index 383c143462b7..aa3b38b40159 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/main.js @@ -31,7 +31,8 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/ndarray.js index 71108aeab87a..3b59e13ff5fe 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/lib/ndarray.js @@ -31,7 +31,8 @@ var accessors = require( './accessors.js' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/test/test.main.js index 06a246425a4d..4429e533015e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/test/test.main.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var gindexOfFalsy = require( './../lib' ); @@ -44,20 +45,9 @@ tape( 'the function returns the index of the first falsy element', function test x = [ 1.0, 0.0, 2.0, 3.0, 0.0, 4.0 ]; - // Nonnegative stride... actual = gindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = gindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = gindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -67,20 +57,9 @@ tape( 'the function returns the index of the first falsy element (accessors)', f x = toAccessorArray( [ 1.0, 0.0, 2.0, 3.0, 0.0, 4.0 ] ); - // Nonnegative stride... actual = gindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = gindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = gindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -132,7 +111,7 @@ tape( 'the function returns `-1` if unable to find a falsy element (accessors)', t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gindexOfFalsy( 0, [ 0.0, 0.0, 0.0 ], 1 ); @@ -144,7 +123,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gindexOfFalsy( 0, toAccessorArray( [ 0.0, 0.0, 0.0 ] ), 1 ); @@ -155,3 +134,97 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]; + + actual = gindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]; + + actual = gindexOfFalsy( 3, toAccessorArray( x ), 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]; + + actual = gindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]; + + actual = gindexOfFalsy( 3, toAccessorArray( x ), -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = gindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/test/test.ndarray.js index 665a940ac1f3..ee4bc18f3559 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy/test/test.ndarray.js @@ -44,156 +44,202 @@ tape( 'the function returns the index of the first falsy element', function test x = [ 1.0, 0.0, 2.0, 3.0, 0.0, 4.0 ]; - // Nonnegative stride... actual = gindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = gindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); +}); - actual = gindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns the index of the first falsy element (accessors)', function test( t ) { + var actual; + var x; - actual = gindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = toAccessorArray( [ 1.0, 0.0, 2.0, 3.0, 0.0, 4.0 ] ); - // Negative stride... - actual = gindexOfFalsy( x.length, x, -1, x.length-1 ); + actual = gindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = gindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function ignores truthy elements (e.g., non-zero values)', function test( t ) { + var actual; + var x; - actual = gindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + x = [ 3.0, 5.0, 0.0, 2.0 ]; + + actual = gindexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first falsy element (accessors)', function test( t ) { +tape( 'the function ignores truthy elements (e.g., non-zero values) (accessors)', function test( t ) { var actual; var x; - x = toAccessorArray( [ 1.0, 0.0, 2.0, 3.0, 0.0, 4.0 ] ); + x = toAccessorArray( [ 3.0, 5.0, 0.0, 2.0 ] ); - // Nonnegative stride... actual = gindexOfFalsy( x.length, x, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); +}); - actual = gindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a falsy element', function test( t ) { + var actual; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0 ]; - actual = gindexOfFalsy( 1, x, 1, 0 ); + actual = gindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = gindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = gindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a falsy element (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0 ] ); - actual = gindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - x = [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0 ]; + actual = gindexOfFalsy( 0, [ 0.0, 0.0, 0.0 ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfFalsy( 3, x, 1, 3 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfFalsy( -1, [ 0.0, 0.0, 0.0 ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; - var x; - x = toAccessorArray( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0 ] ); + actual = gindexOfFalsy( 0, toAccessorArray( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfFalsy( 3, x, 1, 3 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfFalsy( -1, toAccessorArray( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function ignores truthy elements (e.g., non-zero values)', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; var x; - x = [ 3.0, 5.0, 0.0, 2.0 ]; + x = [ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]; - actual = gindexOfFalsy( x.length, x, 1, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = gindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function ignores truthy elements (e.g., non-zero values) (accessors)', function test( t ) { +tape( 'the function supports an `x` stride (accessors)', function test( t ) { var actual; var x; - x = toAccessorArray( [ 3.0, 5.0, 0.0, 2.0 ] ); + x = [ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]; - actual = gindexOfFalsy( x.length, x, 1, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = gindexOfFalsy( 3, toAccessorArray( x ), 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a falsy element', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = [ 1.0, 2.0, 3.0, 4.0 ]; + x = [ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]; - actual = gindexOfFalsy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a falsy element (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; - x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = [ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]; - actual = gindexOfFalsy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfFalsy( 3, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; + var x; - actual = gindexOfFalsy( 0, [ 0.0, 0.0, 0.0 ], 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = [ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]; - actual = gindexOfFalsy( -1, [ 0.0, 0.0, 0.0 ], 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function supports an `x` offset (accessors)', function test( t ) { var actual; + var x; - actual = gindexOfFalsy( 0, toAccessorArray( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = [ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]; - actual = gindexOfFalsy( -1, toAccessorArray( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfFalsy( 3, toAccessorArray( x ), 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/README.md b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/README.md index 50181559531f..faa453768368 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/README.md @@ -135,7 +135,6 @@ var idx = sindexOfFalsy.ndarray( 3, x, 1, x.length-3 ); ## Notes -- If the function is unable to find a falsy element, the function returns `-1`. - Both functions explicitly treat `NaN` values as falsy. diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/repl.txt index d8e191fabf36..9dac1451bceb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/repl.txt @@ -31,10 +31,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 2 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first falsy element in a single-precision floating- @@ -44,6 +56,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -65,9 +79,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 2 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/types/index.d.ts index 9700e5a2712e..499909c6d628 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/types/test.ts index 9990932c766b..249fa9e9fa6a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/docs/types/test.ts @@ -37,6 +37,7 @@ import sindexOfFalsy = require( './index' ); sindexOfFalsy( false, x, 1 ); // $ExpectError sindexOfFalsy( null, x, 1 ); // $ExpectError sindexOfFalsy( {}, x, 1 ); // $ExpectError + sindexOfFalsy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float32Array... @@ -46,6 +47,7 @@ import sindexOfFalsy = require( './index' ); sindexOfFalsy( x.length, false, 1 ); // $ExpectError sindexOfFalsy( x.length, null, 1 ); // $ExpectError sindexOfFalsy( x.length, {}, 1 ); // $ExpectError + sindexOfFalsy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -57,6 +59,7 @@ import sindexOfFalsy = require( './index' ); sindexOfFalsy( x.length, x, false ); // $ExpectError sindexOfFalsy( x.length, x, null ); // $ExpectError sindexOfFalsy( x.length, x, {} ); // $ExpectError + sindexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -83,6 +86,7 @@ import sindexOfFalsy = require( './index' ); sindexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError sindexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError sindexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + sindexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float32Array... @@ -92,6 +96,7 @@ import sindexOfFalsy = require( './index' ); sindexOfFalsy.ndarray( x.length, false, 1, 1 ); // $ExpectError sindexOfFalsy.ndarray( x.length, null, 1, 1 ); // $ExpectError sindexOfFalsy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + sindexOfFalsy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -103,6 +108,7 @@ import sindexOfFalsy = require( './index' ); sindexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError sindexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError sindexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + sindexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -114,6 +120,7 @@ import sindexOfFalsy = require( './index' ); sindexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError sindexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError sindexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + sindexOfFalsy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/ndarray.js index bf77532c508c..de2e41a2f231 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/ndarray.js @@ -25,7 +25,7 @@ * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/ndarray.native.js index fa5ff1a6f4c5..cacc9491659f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/sindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/sindex_of_falsy.js index d191e044c816..c1d63e47916f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/sindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/sindex_of_falsy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/sindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/sindex_of_falsy.native.js index a67f62966773..0be2923eb1a6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/sindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/lib/sindex_of_falsy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.ndarray.js index 71755abf427d..0860f3f87104 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.ndarray.js @@ -39,29 +39,9 @@ tape( 'the function returns the index of the first falsy element', function test x = new Float32Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = sindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = sindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = sindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = sindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = sindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = sindexOfFalsy( 0, new Float32Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); @@ -100,3 +80,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = sindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = sindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = sindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.ndarray.native.js index 783ace309f01..94c11bfbc85f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.ndarray.native.js @@ -48,29 +48,9 @@ tape( 'the function returns the index of the first falsy element', opts, functio x = new Float32Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = sindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = sindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = sindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = sindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = sindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -98,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = sindexOfFalsy( 0, new Float32Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); @@ -109,3 +89,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = sindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = sindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = sindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.sindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.sindex_of_falsy.js index 97766e4b5b49..a53274db3cb5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.sindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.sindex_of_falsy.js @@ -39,20 +39,9 @@ tape( 'the function returns the index of the first falsy element', function test x = new Float32Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = sindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = sindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = sindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -80,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = sindexOfFalsy( 0, new Float32Array( [ 0.0, 1.0, 2.0 ] ), 1 ); @@ -91,3 +80,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = sindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = sindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = sindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.sindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.sindex_of_falsy.native.js index ffc8475b8c71..fedc9dbea4c5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.sindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-falsy/test/test.sindex_of_falsy.native.js @@ -48,20 +48,9 @@ tape( 'the function returns the index of the first falsy element', opts, functio x = new Float32Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = sindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = sindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = sindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = sindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = sindexOfFalsy( 0, new Float32Array( [ 0.0, 1.0, 2.0 ] ), 1 ); @@ -100,3 +89,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = sindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = sindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = sindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/README.md b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/README.md index b6a7168962e1..d26412956788 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/README.md @@ -138,7 +138,6 @@ var idx = zindexOfFalsy.ndarray( 3, x, 1, x.length-3 ); ## Notes - A complex number is falsy when both its real and imaginary components are falsy. -- If unable to find a falsy element, both functions return `-1`. - Both functions explicitly treat `NaN` values as falsy. @@ -257,7 +256,6 @@ CBLAS_INT stdlib_strided_zindex_of_falsy_ndarray( const CBLAS_INT N, const stdli ### Notes - A complex number is falsy when both its real and imaginary components are falsy. -- If unable to find a falsy element, both functions return `-1`. - Both functions explicitly treat `NaN` values as falsy. diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/repl.txt index 6918b97422eb..3cb3b17f7c44 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/repl.txt @@ -14,7 +14,7 @@ A complex number is falsy when both its real and imaginary components are falsy. - The function treats `NaN` values as falsy. + The function explicitly treats `NaN` values as falsy. Parameters ---------- @@ -34,10 +34,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 0.0, 0.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 5.0, 6.0 ] ); + > var idx = {{alias}}( 2, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0, 0.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 2, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first falsy element in a double-precision complex @@ -47,6 +59,11 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + A complex number is falsy when both its real and imaginary components are + falsy. + + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -68,10 +85,16 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 0.0, 0.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 1 + // Using an index offset: + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0, 0.0 ] ); + > var idx = {{alias}}.ndarray( 2, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/types/index.d.ts index d8d0147af93a..01ec7a246f72 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/types/index.d.ts @@ -30,7 +30,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -54,7 +54,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -80,7 +80,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/types/test.ts index 560492599142..067274ee82da 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/docs/types/test.ts @@ -40,6 +40,7 @@ import zindexOfFalsy = require( './index' ); zindexOfFalsy( false, x, 1 ); // $ExpectError zindexOfFalsy( null, x, 1 ); // $ExpectError zindexOfFalsy( {}, x, 1 ); // $ExpectError + zindexOfFalsy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Complex128Array... @@ -51,6 +52,7 @@ import zindexOfFalsy = require( './index' ); zindexOfFalsy( x.length, false, 1 ); // $ExpectError zindexOfFalsy( x.length, null, 1 ); // $ExpectError zindexOfFalsy( x.length, {}, 1 ); // $ExpectError + zindexOfFalsy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -62,6 +64,7 @@ import zindexOfFalsy = require( './index' ); zindexOfFalsy( x.length, x, false ); // $ExpectError zindexOfFalsy( x.length, x, null ); // $ExpectError zindexOfFalsy( x.length, x, {} ); // $ExpectError + zindexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -88,6 +91,7 @@ import zindexOfFalsy = require( './index' ); zindexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError zindexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError zindexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + zindexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex128Array... @@ -99,6 +103,7 @@ import zindexOfFalsy = require( './index' ); zindexOfFalsy.ndarray( x.length, false, 1, 1 ); // $ExpectError zindexOfFalsy.ndarray( x.length, null, 1, 1 ); // $ExpectError zindexOfFalsy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + zindexOfFalsy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -110,6 +115,7 @@ import zindexOfFalsy = require( './index' ); zindexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError zindexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError zindexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + zindexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -121,6 +127,7 @@ import zindexOfFalsy = require( './index' ); zindexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError zindexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError zindexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + zindexOfFalsy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/ndarray.js index bd660fb9577b..5ac287517c56 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/ndarray.js @@ -31,7 +31,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/ndarray.native.js index ea1bc702ca0a..bf84db1250ce 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/ndarray.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/zindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/zindex_of_falsy.js index 299309ec5321..f46182e5ee82 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/zindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/zindex_of_falsy.js @@ -32,7 +32,7 @@ var ndarray = require( './ndarray.js' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/zindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/zindex_of_falsy.native.js index e2c225f7ef62..a453fa3fe11d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/zindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/lib/zindex_of_falsy.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.ndarray.js index 7c33b197c456..bf19847ebd3f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.ndarray.js @@ -52,29 +52,9 @@ tape( 'the function returns the index of the first falsy element', function test 1.0 ]); - // Nonnegative stride... actual = zindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = zindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = zindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = zindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -120,7 +100,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -141,3 +121,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = zindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = zindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = zindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.ndarray.native.js index 98367a200cbc..751f621b8bc5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.ndarray.native.js @@ -61,29 +61,9 @@ tape( 'the function returns the index of the first falsy element', opts, functio 1.0 ]); - // Nonnegative stride... actual = zindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = zindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = zindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = zindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = zindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -129,7 +109,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -150,3 +130,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = zindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = zindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = zindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.zindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.zindex_of_falsy.js index d3d407314aa7..53ede57329b6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.zindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.zindex_of_falsy.js @@ -52,20 +52,9 @@ tape( 'the function returns the index of the first falsy element', function test 1.0 ]); - // Nonnegative stride... actual = zindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = zindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = zindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -111,7 +100,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -132,3 +121,77 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = zindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = zindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex128Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = zindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.zindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.zindex_of_falsy.native.js index 41c3e1241535..114e2423d05f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.zindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-falsy/test/test.zindex_of_falsy.native.js @@ -61,20 +61,9 @@ tape( 'the function returns the index of the first falsy element', opts, functio 1.0 ]); - // Nonnegative stride... actual = zindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = zindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = zindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = zindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -120,7 +109,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -141,3 +130,77 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = zindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex128Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = zindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex128Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = zindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); From 80e83d7f5ceb4e5a1834cd2dd2b68bfa1252d5b8 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 9 Sep 2026 23:49:50 +0500 Subject: [PATCH 05/68] fix: refactor `last-index-of-truthy` --- .../benchmark/c/benchmark.length.c | 4 +- .../base/dlast-index-of-truthy/docs/repl.txt | 28 ++- .../docs/types/index.d.ts | 6 +- .../dlast-index-of-truthy/docs/types/test.ts | 11 +- .../lib/dlast_index_of_truthy.js | 2 +- .../lib/dlast_index_of_truthy.native.js | 2 +- .../base/dlast-index-of-truthy/lib/ndarray.js | 2 +- .../lib/ndarray.native.js | 2 +- .../test/test.dlast_index_of_truthy.js | 71 +++++-- .../test/test.dlast_index_of_truthy.native.js | 71 +++++-- .../test/test.ndarray.js | 83 ++++++--- .../test/test.ndarray.native.js | 83 ++++++--- .../ext/base/glast-index-of-truthy/README.md | 2 +- .../base/glast-index-of-truthy/docs/repl.txt | 22 +++ .../docs/types/index.d.ts | 9 +- .../glast-index-of-truthy/docs/types/test.ts | 7 + .../base/glast-index-of-truthy/lib/main.js | 3 +- .../base/glast-index-of-truthy/lib/ndarray.js | 3 +- .../glast-index-of-truthy/test/test.main.js | 121 +++++++++--- .../test/test.ndarray.js | 176 +++++++++++------- .../base/slast-index-of-truthy/docs/repl.txt | 20 ++ .../docs/types/index.d.ts | 6 +- .../slast-index-of-truthy/docs/types/test.ts | 7 + .../base/slast-index-of-truthy/lib/ndarray.js | 2 +- .../lib/ndarray.native.js | 2 +- .../lib/slast_index_of_truthy.js | 2 +- .../lib/slast_index_of_truthy.native.js | 2 +- .../base/slast-index-of-truthy/manifest.json | 12 +- .../ext/base/slast-index-of-truthy/src/main.c | 10 +- .../test/test.ndarray.js | 77 +++++--- .../test/test.ndarray.native.js | 77 +++++--- .../test/test.slast_index_of_truthy.js | 71 +++++-- .../test/test.slast_index_of_truthy.native.js | 71 +++++-- 33 files changed, 789 insertions(+), 278 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/benchmark/c/benchmark.length.c index bf97c8d6facf..f2dd6b3b9af1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/benchmark/c/benchmark.length.c @@ -61,8 +61,8 @@ static void print_results( int iterations, double elapsed ) { double rate = (double)iterations / elapsed; printf( " ---\n" ); printf( " iterations: %d\n", iterations ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); + printf( " elapsed: %0.9\n", elapsed ); + printf( " rate: %0.9\n", rate ); printf( " ...\n" ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/repl.txt index aeff52b6dade..f3fe96e6ccda 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( N, x, strideX ) - Returns the index of the last truthy element in a double-precision - floating-point strided array. + Returns the index of the last truthy element in a double-precision floating- + point strided array. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. @@ -31,19 +31,33 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 5 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 2 + {{alias}}.ndarray( N, x, strideX, offsetX ) - Returns the index of the last truthy element in a double-precision - floating-point strided array using alternative indexing semantics. + Returns the index of the last truthy element in a double-precision floating- + point strided array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -65,9 +79,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 5 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/index.d.ts index 759f65d5b820..42611a421991 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/test.ts index 5048cc9121fe..68cecb4d700d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/test.ts @@ -37,6 +37,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy( false, x, 1 ); // $ExpectError dlastIndexOfTruthy( null, x, 1 ); // $ExpectError dlastIndexOfTruthy( {}, x, 1 ); // $ExpectError + dlastIndexOfTruthy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... @@ -46,6 +47,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy( x.length, false, 1 ); // $ExpectError dlastIndexOfTruthy( x.length, null, 1 ); // $ExpectError dlastIndexOfTruthy( x.length, {}, 1 ); // $ExpectError + dlastIndexOfTruthy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -57,6 +59,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy( x.length, x, false ); // $ExpectError dlastIndexOfTruthy( x.length, x, null ); // $ExpectError dlastIndexOfTruthy( x.length, x, {} ); // $ExpectError + dlastIndexOfTruthy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -64,7 +67,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy(); // $ExpectError dlastIndexOfTruthy( 3 ); // $ExpectError dlastIndexOfTruthy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError - dlastIndexOfTruthy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // $ExpectError + dlastIndexOfTruthy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -83,6 +86,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy.ndarray( false, x, 1, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( null, x, 1, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( {}, x, 1, 1 ); // $ExpectError + dlastIndexOfTruthy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -92,6 +96,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy.ndarray( x.length, false, 1, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, null, 1, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + dlastIndexOfTruthy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -103,6 +108,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy.ndarray( x.length, x, false, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, x, null, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, x, {}, 1 ); // $ExpectError + dlastIndexOfTruthy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -114,6 +120,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy.ndarray( x.length, x, 1, false ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, x, 1, null ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, x, 1, {} ); // $ExpectError + dlastIndexOfTruthy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -122,5 +129,5 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy.ndarray( 3 ); // $ExpectError dlastIndexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError dlastIndexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); // $ExpectError - dlastIndexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, 0 ); // $ExpectError + dlastIndexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.js index d7ba13dd164b..faf507689d09 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.native.js index 375140164f6c..e07efac67aca 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.js index 1f984417c90c..8d6e37941aba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.js @@ -30,7 +30,7 @@ var dindexOfTruthy = require( '@stdlib/blas/ext/base/dindex-of-truthy' ).ndarray * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.native.js index 9111665a8075..23838706311a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.js index 8b3219a69301..4a36c8abc95f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.js @@ -39,20 +39,9 @@ tape( 'the function returns the index of the last truthy element', function test x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = dlastIndexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dlastIndexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -80,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -91,3 +80,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dlastIndexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dlastIndexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.native.js index 1d8f9c1f41f6..dfcd7ec454e6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.native.js @@ -48,20 +48,9 @@ tape( 'the function returns the index of the last truthy element', opts, functio x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = dlastIndexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dlastIndexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -100,3 +89,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dlastIndexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dlastIndexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.js index ffea1f49693f..01ba352fa417 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.js @@ -39,76 +39,99 @@ tape( 'the function returns the index of the last truthy element', function test x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = dlastIndexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', function test( t ) { + var actual; + var x; + + x = new Float64Array( [ 0.0, -0.0, 5.0, NaN ] ); - actual = dlastIndexOfTruthy( x.length-2, x, 1, 2 ); + actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dlastIndexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); +}); - // Negative stride... - actual = dlastIndexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a truthy element', function test( t ) { + var actual; + var x; - actual = dlastIndexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = dlastIndexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - x = new Float64Array( [ 0.0, 0.0, 0.0, 4.0, 0.0, 5.0 ] ); + actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfTruthy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dlastIndexOfTruthy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; var x; - x = new Float64Array( [ 0.0, -0.0, 5.0, NaN ] ); + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); - actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); + actual = dlastIndexOfTruthy( 3, x, 2, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a truthy element', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); - actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; + var x; - actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); - actual = dlastIndexOfTruthy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.native.js index 8dd150bbf99f..acb5d89e803a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.native.js @@ -48,76 +48,99 @@ tape( 'the function returns the index of the last truthy element', opts, functio x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = dlastIndexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array( [ 0.0, -0.0, 5.0, NaN ] ); - actual = dlastIndexOfTruthy( x.length-2, x, 1, 2 ); + actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dlastIndexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); +}); - // Negative stride... - actual = dlastIndexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a truthy element', opts, function test( t ) { + var actual; + var x; - actual = dlastIndexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = dlastIndexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - var x; - x = new Float64Array( [ 0.0, 0.0, 0.0, 4.0, 0.0, 5.0 ] ); + actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfTruthy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dlastIndexOfTruthy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 0.0, -0.0, 5.0, NaN ] ); + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); - actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); + actual = dlastIndexOfTruthy( 3, x, 2, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a truthy element', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); - actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` offset', opts, function test( t ) { var actual; + var x; - actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); - actual = dlastIndexOfTruthy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/README.md b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/README.md index 6a88b557ec79..bd4115918216 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/README.md @@ -125,7 +125,7 @@ var idx = glastIndexOfTruthy.ndarray( 3, x, 1, x.length-3 ); ## Notes -- If unable to find a truthy element, both functions return `-1`. +- Both functions explicitly treat `NaN` values as falsy. - 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/glast-index-of-truthy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/docs/repl.txt index 3592516a467c..af460a6c5057 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/docs/repl.txt @@ -10,6 +10,8 @@ If `N <= 0`, the function returns `-1`. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -28,10 +30,22 @@ Examples -------- + // Standard usage: > var x = [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ]; > var idx = {{alias}}( x.length, x, 1 ) 5 + // Using `N` and stride parameters: + > var x = [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ]; + > var idx = {{alias}}( 3, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 2 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the last truthy element in a strided array using @@ -41,6 +55,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -62,9 +78,15 @@ Examples -------- + // Standard usage: > var x = [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ]; > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 5 + // Using an index offset: + > var x = [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ]; + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/docs/types/index.d.ts index 49e3e732f55d..f33302c3b7d0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/docs/types/index.d.ts @@ -36,7 +36,8 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. + * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array @@ -56,7 +57,8 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. + * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array @@ -78,7 +80,8 @@ interface Routine { * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/docs/types/test.ts index 4743a77e4e7d..81574504d0b6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/docs/types/test.ts @@ -39,6 +39,7 @@ import glastIndexOfTruthy = require( './index' ); glastIndexOfTruthy( false, x, 1 ); // $ExpectError glastIndexOfTruthy( null, x, 1 ); // $ExpectError glastIndexOfTruthy( {}, x, 1 ); // $ExpectError + glastIndexOfTruthy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a collection... @@ -48,6 +49,7 @@ import glastIndexOfTruthy = require( './index' ); glastIndexOfTruthy( x.length, false, 1 ); // $ExpectError glastIndexOfTruthy( x.length, null, 1 ); // $ExpectError glastIndexOfTruthy( x.length, {}, 1 ); // $ExpectError + glastIndexOfTruthy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -59,6 +61,7 @@ import glastIndexOfTruthy = require( './index' ); glastIndexOfTruthy( x.length, x, false ); // $ExpectError glastIndexOfTruthy( x.length, x, null ); // $ExpectError glastIndexOfTruthy( x.length, x, {} ); // $ExpectError + glastIndexOfTruthy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -86,6 +89,7 @@ import glastIndexOfTruthy = require( './index' ); glastIndexOfTruthy.ndarray( false, x, 1, 1 ); // $ExpectError glastIndexOfTruthy.ndarray( null, x, 1, 1 ); // $ExpectError glastIndexOfTruthy.ndarray( {}, x, 1, 1 ); // $ExpectError + glastIndexOfTruthy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a collection... @@ -95,6 +99,7 @@ import glastIndexOfTruthy = require( './index' ); glastIndexOfTruthy.ndarray( x.length, false, 1, 1 ); // $ExpectError glastIndexOfTruthy.ndarray( x.length, null, 1, 1 ); // $ExpectError glastIndexOfTruthy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + glastIndexOfTruthy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -106,6 +111,7 @@ import glastIndexOfTruthy = require( './index' ); glastIndexOfTruthy.ndarray( x.length, x, false, 1 ); // $ExpectError glastIndexOfTruthy.ndarray( x.length, x, null, 1 ); // $ExpectError glastIndexOfTruthy.ndarray( x.length, x, {}, 1 ); // $ExpectError + glastIndexOfTruthy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -117,6 +123,7 @@ import glastIndexOfTruthy = require( './index' ); glastIndexOfTruthy.ndarray( x.length, x, 1, false ); // $ExpectError glastIndexOfTruthy.ndarray( x.length, x, 1, null ); // $ExpectError glastIndexOfTruthy.ndarray( x.length, x, 1, {} ); // $ExpectError + glastIndexOfTruthy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/lib/main.js index e16801d4b100..0094d78d84aa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/lib/main.js @@ -31,7 +31,8 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/lib/ndarray.js index 82e88cd852ea..07bc61dbb62b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/lib/ndarray.js @@ -30,7 +30,8 @@ var gindexOfTruthy = require( '@stdlib/blas/ext/base/gindex-of-truthy' ).ndarray * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/test/test.main.js index afc227392830..ef3996f0b1b9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/test/test.main.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var glastIndexOfTruthy = require( './../lib' ); @@ -44,20 +45,9 @@ tape( 'the function returns the index of the last truthy element', function test x = [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ]; - // Nonnegative stride... actual = glastIndexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = glastIndexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = glastIndexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = glastIndexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -67,20 +57,9 @@ tape( 'the function returns the index of the last truthy element (accessors)', f x = toAccessorArray( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = glastIndexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = glastIndexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = glastIndexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = glastIndexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -132,7 +111,7 @@ tape( 'the function returns `-1` if unable to find a truthy element (accessors)' t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = glastIndexOfTruthy( 0, [ 1.0, 2.0, 3.0 ], 1 ); @@ -144,7 +123,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = glastIndexOfTruthy( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -155,3 +134,97 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]; + + actual = glastIndexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]; + + actual = glastIndexOfTruthy( 3, toAccessorArray( x ), 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]; + + actual = glastIndexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]; + + actual = glastIndexOfTruthy( 3, toAccessorArray( x ), -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = glastIndexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/test/test.ndarray.js index 655b3ad7bf6d..41d0e753982a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-truthy/test/test.ndarray.js @@ -44,156 +44,202 @@ tape( 'the function returns the index of the last truthy element', function test x = [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ]; - // Nonnegative stride... actual = glastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = glastIndexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = glastIndexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns the index of the last truthy element (accessors)', function test( t ) { + var actual; + var x; - actual = glastIndexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = toAccessorArray( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Negative stride... - actual = glastIndexOfTruthy( x.length, x, -1, x.length-1 ); + actual = glastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = glastIndexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = glastIndexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', function test( t ) { + var actual; + var x; + + x = [ 0.0, 5.0, NaN, 0.0 ]; + + actual = glastIndexOfTruthy( x.length, x, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the last truthy element (accessors)', function test( t ) { +tape( 'the function ignores falsy elements (e.g., `0`, `NaN`) (accessors)', function test( t ) { var actual; var x; - x = toAccessorArray( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); + x = toAccessorArray( [ 0.0, 5.0, NaN, 0.0 ] ); - // Nonnegative stride... actual = glastIndexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); + t.strictEqual( actual, 1, 'returns expected value' ); - actual = glastIndexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = glastIndexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a truthy element', function test( t ) { + var actual; + var x; + + x = [ 0.0, 0.0, 0.0, 0.0 ]; - actual = glastIndexOfTruthy( 1, x, 1, 0 ); + actual = glastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = glastIndexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + t.end(); +}); - actual = glastIndexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a truthy element (accessors)', function test( t ) { + var actual; + var x; - actual = glastIndexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + x = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ); + + actual = glastIndexOfTruthy( x.length, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - x = [ 0.0, 0.0, 0.0, 4.0, 0.0, 5.0 ]; + actual = glastIndexOfTruthy( 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = glastIndexOfTruthy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = glastIndexOfTruthy( -1, [ 1.0, 2.0, 3.0 ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; - var x; - x = toAccessorArray( [ 0.0, 0.0, 0.0, 4.0, 0.0, 5.0 ] ); + actual = glastIndexOfTruthy( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); - actual = glastIndexOfTruthy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = glastIndexOfTruthy( -1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; var x; - x = [ 0.0, 5.0, NaN, 0.0 ]; + x = [ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]; - actual = glastIndexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = glastIndexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function ignores falsy elements (e.g., `0`, `NaN`) (accessors)', function test( t ) { +tape( 'the function supports an `x` stride (accessors)', function test( t ) { var actual; var x; - x = toAccessorArray( [ 0.0, 5.0, NaN, 0.0 ] ); + x = [ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]; - actual = glastIndexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = glastIndexOfTruthy( 3, toAccessorArray( x ), 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a truthy element', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = [ 0.0, 0.0, 0.0, 0.0 ]; + x = [ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]; - actual = glastIndexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = glastIndexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a truthy element (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; - x = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = [ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]; - actual = glastIndexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = glastIndexOfTruthy( 3, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; + var x; - actual = glastIndexOfTruthy( 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = [ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; - actual = glastIndexOfTruthy( -1, [ 1.0, 2.0, 3.0 ], 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = glastIndexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function supports an `x` offset (accessors)', function test( t ) { var actual; + var x; - actual = glastIndexOfTruthy( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + x = [ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; - actual = glastIndexOfTruthy( -1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + actual = glastIndexOfTruthy( 3, toAccessorArray( x ), 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/repl.txt index c69ad890c747..c64368a87152 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/repl.txt @@ -31,10 +31,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 5 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 2 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the last truthy element in a single-precision floating- @@ -44,6 +56,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -65,9 +79,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 5 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/types/index.d.ts index 1605e7a2b0ec..d2afa3930077 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/types/test.ts index 05cc046ab505..059779b57421 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/docs/types/test.ts @@ -37,6 +37,7 @@ import slastIndexOfTruthy = require( './index' ); slastIndexOfTruthy( false, x, 1 ); // $ExpectError slastIndexOfTruthy( null, x, 1 ); // $ExpectError slastIndexOfTruthy( {}, x, 1 ); // $ExpectError + slastIndexOfTruthy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float32Array... @@ -46,6 +47,7 @@ import slastIndexOfTruthy = require( './index' ); slastIndexOfTruthy( x.length, false, 1 ); // $ExpectError slastIndexOfTruthy( x.length, null, 1 ); // $ExpectError slastIndexOfTruthy( x.length, {}, 1 ); // $ExpectError + slastIndexOfTruthy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -57,6 +59,7 @@ import slastIndexOfTruthy = require( './index' ); slastIndexOfTruthy( x.length, x, false ); // $ExpectError slastIndexOfTruthy( x.length, x, null ); // $ExpectError slastIndexOfTruthy( x.length, x, {} ); // $ExpectError + slastIndexOfTruthy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -83,6 +86,7 @@ import slastIndexOfTruthy = require( './index' ); slastIndexOfTruthy.ndarray( false, x, 1, 1 ); // $ExpectError slastIndexOfTruthy.ndarray( null, x, 1, 1 ); // $ExpectError slastIndexOfTruthy.ndarray( {}, x, 1, 1 ); // $ExpectError + slastIndexOfTruthy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float32Array... @@ -92,6 +96,7 @@ import slastIndexOfTruthy = require( './index' ); slastIndexOfTruthy.ndarray( x.length, false, 1, 1 ); // $ExpectError slastIndexOfTruthy.ndarray( x.length, null, 1, 1 ); // $ExpectError slastIndexOfTruthy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + slastIndexOfTruthy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -103,6 +108,7 @@ import slastIndexOfTruthy = require( './index' ); slastIndexOfTruthy.ndarray( x.length, x, false, 1 ); // $ExpectError slastIndexOfTruthy.ndarray( x.length, x, null, 1 ); // $ExpectError slastIndexOfTruthy.ndarray( x.length, x, {}, 1 ); // $ExpectError + slastIndexOfTruthy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -114,6 +120,7 @@ import slastIndexOfTruthy = require( './index' ); slastIndexOfTruthy.ndarray( x.length, x, 1, false ); // $ExpectError slastIndexOfTruthy.ndarray( x.length, x, 1, null ); // $ExpectError slastIndexOfTruthy.ndarray( x.length, x, 1, {} ); // $ExpectError + slastIndexOfTruthy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/ndarray.js index 22426114ca5b..680b80291ce4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/ndarray.js @@ -30,7 +30,7 @@ var sindexOfTruthy = require( '@stdlib/blas/ext/base/sindex-of-truthy' ).ndarray * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/ndarray.native.js index 78a9aa257ad4..cb52ab8ea47f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/slast_index_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/slast_index_of_truthy.js index 3ab244f5929d..a244fca2bbc5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/slast_index_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/slast_index_of_truthy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/slast_index_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/slast_index_of_truthy.native.js index ce6677692b14..70c4d620406b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/slast_index_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/lib/slast_index_of_truthy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/manifest.json index 26a476bad4b2..6f8207967973 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/manifest.json @@ -37,13 +37,13 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/ext/base/sindex-of-truthy", "@stdlib/strided/base/stride2offset", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/create-int32" + "@stdlib/napi/create-int32", + "@stdlib/blas/ext/base/sindex-of-truthy" ] }, { @@ -58,8 +58,8 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/ext/base/sindex-of-truthy", - "@stdlib/strided/base/stride2offset" + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/ext/base/sindex-of-truthy" ] }, { @@ -74,8 +74,8 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/ext/base/sindex-of-truthy", - "@stdlib/strided/base/stride2offset" + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/ext/base/sindex-of-truthy" ] } ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/src/main.c index 1c9f6cf45a2b..87ea7d813629 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/src/main.c @@ -45,18 +45,18 @@ CBLAS_INT API_SUFFIX(stdlib_strided_slast_index_of_truthy)( const CBLAS_INT N, c */ CBLAS_INT API_SUFFIX(stdlib_strided_slast_index_of_truthy_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { CBLAS_INT idx; - CBLAS_INT ox; - CBLAS_INT sx; + CBLAS_INT sv; + CBLAS_INT ov; if ( N <= 0 ) { return -1; } // Reverse the iteration order by flipping the stride and adjusting the offset: - ox = offsetX + ( (N-1) * strideX ); - sx = -strideX; + ov = offsetX + ( ( N - 1 ) * strideX ); + sv = -strideX; // Find the index of the first truthy element in the reversed "view": - idx = API_SUFFIX(stdlib_strided_sindex_of_truthy_ndarray)( N, X, sx, ox ); + idx = API_SUFFIX(stdlib_strided_sindex_of_truthy_ndarray)( N, X, sv, ov ); if ( idx < 0 ) { return idx; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.ndarray.js index f6fdf66c6e2d..550ecfba0a3d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.ndarray.js @@ -39,29 +39,9 @@ tape( 'the function returns the index of the last truthy element', function test x = new Float32Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = slastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = slastIndexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = slastIndexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = slastIndexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = slastIndexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = slastIndexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = slastIndexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = slastIndexOfTruthy( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -100,3 +80,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = slastIndexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = slastIndexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = slastIndexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.ndarray.native.js index 71f45d562cbc..2b960c1847d3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.ndarray.native.js @@ -48,29 +48,9 @@ tape( 'the function returns the index of the last truthy element', opts, functio x = new Float32Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = slastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = slastIndexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = slastIndexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = slastIndexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = slastIndexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = slastIndexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = slastIndexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -98,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = slastIndexOfTruthy( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -109,3 +89,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = slastIndexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = slastIndexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = slastIndexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.slast_index_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.slast_index_of_truthy.js index 9c9499ae36d7..7fdb7e71a4b4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.slast_index_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.slast_index_of_truthy.js @@ -39,20 +39,9 @@ tape( 'the function returns the index of the last truthy element', function test x = new Float32Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = slastIndexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = slastIndexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = slastIndexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = slastIndexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -80,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = slastIndexOfTruthy( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -91,3 +80,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = slastIndexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = slastIndexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = slastIndexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.slast_index_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.slast_index_of_truthy.native.js index ab8f50256220..8e2d42999c49 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.slast_index_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-truthy/test/test.slast_index_of_truthy.native.js @@ -48,20 +48,9 @@ tape( 'the function returns the index of the last truthy element', opts, functio x = new Float32Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = slastIndexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = slastIndexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = slastIndexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = slastIndexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = slastIndexOfTruthy( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -100,3 +89,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = slastIndexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = slastIndexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = slastIndexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); From 291df78645a80e8d314d7f7cbb37aa7e5f709928 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 9 Sep 2026 23:49:53 +0500 Subject: [PATCH 06/68] fix: refactor `last-index-of-falsy` --- .../ext/base/dlast-index-of-falsy/README.md | 30 +-- .../benchmark/c/benchmark.length.c | 4 +- .../base/dlast-index-of-falsy/docs/repl.txt | 36 +++- .../docs/types/index.d.ts | 22 +-- .../dlast-index-of-falsy/docs/types/test.ts | 9 +- .../dlast-index-of-falsy/examples/c/example.c | 2 +- .../lib/dlast_index_of_falsy.js | 6 +- .../lib/dlast_index_of_falsy.native.js | 6 +- .../base/dlast-index-of-falsy/lib/index.js | 8 +- .../base/dlast-index-of-falsy/lib/ndarray.js | 8 +- .../lib/ndarray.native.js | 6 +- .../ext/base/dlast-index-of-falsy/src/main.c | 10 +- .../test/test.dlast_index_of_falsy.js | 85 +++++++-- .../test/test.dlast_index_of_falsy.native.js | 85 +++++++-- .../dlast-index-of-falsy/test/test.ndarray.js | 92 +++++---- .../test/test.ndarray.native.js | 92 +++++---- .../ext/base/glast-index-of-falsy/README.md | 2 +- .../base/glast-index-of-falsy/docs/repl.txt | 22 +++ .../docs/types/index.d.ts | 9 +- .../glast-index-of-falsy/docs/types/test.ts | 7 + .../ext/base/glast-index-of-falsy/lib/main.js | 3 +- .../base/glast-index-of-falsy/lib/ndarray.js | 3 +- .../glast-index-of-falsy/test/test.main.js | 121 +++++++++--- .../glast-index-of-falsy/test/test.ndarray.js | 178 +++++++++++------- .../base/slast-index-of-falsy/docs/repl.txt | 20 ++ .../docs/types/index.d.ts | 6 +- .../slast-index-of-falsy/docs/types/test.ts | 7 + .../base/slast-index-of-falsy/lib/ndarray.js | 2 +- .../lib/ndarray.native.js | 2 +- .../lib/slast_index_of_falsy.js | 2 +- .../lib/slast_index_of_falsy.native.js | 2 +- .../base/slast-index-of-falsy/manifest.json | 12 +- .../ext/base/slast-index-of-falsy/src/main.c | 10 +- .../slast-index-of-falsy/test/test.ndarray.js | 77 +++++--- .../test/test.ndarray.native.js | 77 +++++--- .../test/test.slast_index_of_falsy.js | 71 +++++-- .../test/test.slast_index_of_falsy.native.js | 71 +++++-- .../ext/base/zlast-index-of-falsy/README.md | 2 - .../base/zlast-index-of-falsy/docs/repl.txt | 16 +- .../docs/types/index.d.ts | 6 +- .../zlast-index-of-falsy/docs/types/test.ts | 7 + .../base/zlast-index-of-falsy/lib/ndarray.js | 2 +- .../lib/ndarray.native.js | 2 +- .../lib/zlast_index_of_falsy.js | 2 +- .../lib/zlast_index_of_falsy.native.js | 2 +- .../base/zlast-index-of-falsy/manifest.json | 12 +- .../ext/base/zlast-index-of-falsy/src/main.c | 10 +- .../zlast-index-of-falsy/test/test.ndarray.js | 10 +- .../test/test.ndarray.native.js | 10 +- .../test/test.zlast_index_of_falsy.js | 7 +- .../test/test.zlast_index_of_falsy.native.js | 7 +- 51 files changed, 897 insertions(+), 403 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/README.md b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/README.md index ce53aae77b3b..c6840f8e5006 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/README.md @@ -47,10 +47,10 @@ Returns the index of the last falsy element in a double-precision floating-point ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); var idx = dlastIndexOfFalsy( x.length, x, 1 ); -// returns 4 +// returns 5 ``` The function has the following parameters: @@ -75,10 +75,10 @@ The `N` and stride parameters determine which elements in the strided array are ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 1.0, 3.0 ] ); -var idx = dlastIndexOfFalsy( 4, x, 2 ); -// returns 2 +var idx = dlastIndexOfFalsy( 3, x, 2 ); +// returns 1 ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -87,14 +87,14 @@ Note that indexing is relative to the first index. To introduce an offset, use [ var Float64Array = require( '@stdlib/array/float64' ); // Initial array... -var x0 = new Float64Array( [ 1.0, 3.0, 1.0, 0.0, 2.0, 1.0 ] ); +var x0 = new Float64Array( [ 1.0, 0.0, 1.0, 3.0, 5.0, 0.0 ] ); // Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element // Find index... var idx = dlastIndexOfFalsy( 3, x1, 2 ); -// returns 1 +// returns 2 ``` #### dlastIndexOfFalsy.ndarray( N, x, strideX, offsetX ) @@ -104,10 +104,10 @@ Returns the index of the last falsy element in a double-precision floating-point ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); var idx = dlastIndexOfFalsy.ndarray( x.length, x, 1, 0 ); -// returns 4 +// returns 5 ``` The function has the following additional parameters: @@ -119,7 +119,7 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0, 1.0, 4.0, 0.0, 0.0, 3.0 ] ); var idx = dlastIndexOfFalsy.ndarray( 3, x, 1, x.length-3 ); // returns 1 @@ -197,10 +197,10 @@ console.log( idx ); Returns the index of the last falsy element in a double-precision floating-point strided array. ```c -const double x[] = { 1.0, 3.0, 0.0, 4.0 }; +const double x[] = { 1.0, 2.0, 3.0, 0.0 }; int idx = stdlib_strided_dlast_index_of_falsy( 4, x, 1 ); -// returns 2 +// returns 3 ``` The function accepts the following arguments: @@ -218,10 +218,10 @@ CBLAS_INT stdlib_strided_dlast_index_of_falsy( const CBLAS_INT N, const double * Returns the index of the last falsy element in a double-precision floating-point strided array using alternative indexing semantics. ```c -const double x[] = { 1.0, 3.0, 0.0, 4.0 }; +const double x[] = { 1.0, 2.0, 3.0, 0.0 }; int idx = stdlib_strided_dlast_index_of_falsy_ndarray( 4, x, 1, 0 ); -// returns 2 +// returns 3 ``` The function accepts the following arguments: @@ -263,7 +263,7 @@ CBLAS_INT stdlib_strided_dlast_index_of_falsy_ndarray( const CBLAS_INT N, const int main( void ) { // Create a strided array: - const double x[] = { 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 }; + const double x[] = { 0.0, 0.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 }; // Specify the number of indexed elements: const int N = 8; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/benchmark/c/benchmark.length.c index 5655f2adbb38..6e4a4656dc83 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/benchmark/c/benchmark.length.c @@ -61,8 +61,8 @@ static void print_results( int iterations, double elapsed ) { double rate = (double)iterations / elapsed; printf( " ---\n" ); printf( " iterations: %d\n", iterations ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); + printf( " elapsed: %0.9\n", elapsed ); + printf( " rate: %0.9\n", rate ); printf( " ...\n" ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/repl.txt index 80ce4d30e844..d7da8aad6b9d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( N, x, strideX ) - Returns the index of the last falsy element in a double-precision - floating-point strided array. + Returns the index of the last falsy element in a double-precision floating- + point strided array. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. @@ -31,19 +31,33 @@ Examples -------- - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 0.0, 4.0 ] ); + // Standard usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) - 4 + 5 + + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 0.0, 4.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 0.0, 2.0, 0.0, 4.0, 5.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 1 {{alias}}.ndarray( N, x, strideX, offsetX ) - Returns the index of the last falsy element in a double-precision - floating-point strided array using alternative indexing semantics. + Returns the index of the last falsy element in a double-precision floating- + point strided array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -65,9 +79,15 @@ Examples -------- - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 0.0, 4.0 ] ); + // Standard usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) - 4 + 5 + + // Using an index offset: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 0.0, 2.0, 0.0, 4.0, 5.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 1 See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/index.d.ts index 4dc00ce8f414..26a7a6036f1b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -38,10 +38,10 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + * var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1 ); - * // returns 3 + * // returns 2 */ ( N: number, x: Float64Array, strideX: number ): number; @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -62,10 +62,10 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + * var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy.ndarray( x.length, x, 1, 0 ); - * // returns 3 + * // returns 2 */ ndarray( N: number, x: Float64Array, strideX: number, offsetX: number ): number; } @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -86,18 +86,18 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1 ); -* // returns 3 +* // returns 2 * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy.ndarray( x.length, x, 1, 0 ); -* // returns 3 +* // returns 2 */ declare var dlastIndexOfFalsy: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/test.ts index 559b95ee8757..2792789883bc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/test.ts @@ -16,8 +16,6 @@ * limitations under the License. */ -/* eslint-disable space-in-parens */ - import dlastIndexOfFalsy = require( './index' ); @@ -39,6 +37,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy( false, x, 1 ); // $ExpectError dlastIndexOfFalsy( null, x, 1 ); // $ExpectError dlastIndexOfFalsy( {}, x, 1 ); // $ExpectError + dlastIndexOfFalsy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... @@ -48,6 +47,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy( x.length, false, 1 ); // $ExpectError dlastIndexOfFalsy( x.length, null, 1 ); // $ExpectError dlastIndexOfFalsy( x.length, {}, 1 ); // $ExpectError + dlastIndexOfFalsy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -59,6 +59,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy( x.length, x, false ); // $ExpectError dlastIndexOfFalsy( x.length, x, null ); // $ExpectError dlastIndexOfFalsy( x.length, x, {} ); // $ExpectError + dlastIndexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -85,6 +86,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + dlastIndexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -94,6 +96,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy.ndarray( x.length, false, 1, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, null, 1, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + dlastIndexOfFalsy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -105,6 +108,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + dlastIndexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -116,6 +120,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + dlastIndexOfFalsy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/examples/c/example.c index 7f2569390118..d340814ec304 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/examples/c/example.c @@ -21,7 +21,7 @@ int main( void ) { // Create a strided array: - const double x[] = { 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 }; + const double x[] = { 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 }; // Specify the number of indexed elements: const int N = 8; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.js index e6d54fd6bb00..ac77952c1ab1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -42,10 +42,10 @@ var ndarray = require( './ndarray.js' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1 ); -* // returns 4 +* // returns 5 */ function dlastIndexOfFalsy( N, x, strideX ) { return ndarray( N, x, strideX, stride2offset( N, strideX ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.native.js index d11d515c8d2e..af2d19b29079 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -41,10 +41,10 @@ var addon = require( './../src/addon.node' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1 ); -* // returns 4 +* // returns 5 */ function dlastIndexOfFalsy( N, x, strideX ) { return addon( N, x, strideX ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/index.js index 5802ef0bbe71..90933dc3b2f2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/index.js @@ -27,19 +27,19 @@ * var Float64Array = require( '@stdlib/array/float64' ); * var dlastIndexOfFalsy = require( '@stdlib/blas/ext/base/dlast-index-of-falsy' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1 ); -* // returns 4 +* // returns 5 * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var dlastIndexOfFalsy = require( '@stdlib/blas/ext/base/dlast-index-of-falsy' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy.ndarray( x.length, x, 1, 0 ); -* // returns 4 +* // returns 5 */ // MODULES // diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.js index 18bfb964744d..f8fa2f168cef 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.js @@ -30,7 +30,7 @@ var dindexOfFalsy = require( '@stdlib/blas/ext/base/dindex-of-falsy' ).ndarray; * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -42,10 +42,10 @@ var dindexOfFalsy = require( '@stdlib/blas/ext/base/dindex-of-falsy' ).ndarray; * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1, 0 ); -* // returns 4 +* // returns 5 */ function dlastIndexOfFalsy( N, x, strideX, offsetX ) { var idx; @@ -54,7 +54,7 @@ function dlastIndexOfFalsy( N, x, strideX, offsetX ) { return -1; } // Reverse the iteration order by flipping the stride and adjusting the offset: - offsetX += ( N-1 ) * strideX; + offsetX += ( ( N - 1 ) * strideX ); strideX *= -1; // Find the index of the first falsy element in the reversed "view": diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.native.js index 3043efb6d9b2..bfa85edc2fba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -42,10 +42,10 @@ var addon = require( './../src/addon.node' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1, 0 ); -* // returns 4 +* // returns 5 */ function dlastIndexOfFalsy( N, x, strideX, offsetX ) { return addon.ndarray( N, x, strideX, offsetX ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/src/main.c index a98d52ce068a..3090b85c2092 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/src/main.c @@ -45,18 +45,18 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_of_falsy)( const CBLAS_INT N, co */ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_of_falsy_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { CBLAS_INT idx; - CBLAS_INT ox; - CBLAS_INT sx; + CBLAS_INT sv; + CBLAS_INT ov; if ( N <= 0 ) { return -1; } // Reverse the iteration order by flipping the stride and adjusting the offset: - ox = offsetX + ( ( N - 1 ) * strideX ); - sx = -strideX; + ov = offsetX + ( ( N - 1 ) * strideX ); + sv = -strideX; // Find the index of the first falsy element in the reversed "view": - idx = API_SUFFIX(stdlib_strided_dindex_of_falsy_ndarray)( N, X, sx, ox ); + idx = API_SUFFIX(stdlib_strided_dindex_of_falsy_ndarray)( N, X, sv, ov ); if ( idx < 0 ) { return idx; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.js index f5966a577437..d24f686b222e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.js @@ -37,33 +37,22 @@ tape( 'the function returns the index of the last falsy element', function test( var actual; var x; - x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 0.0, 4.0 ] ); + x = new Float64Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfFalsy( x.length, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dlastIndexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + t.strictEqual( actual, 5, 'returns expected value' ); t.end(); }); -tape( 'the function explicitly treats `NaN` values as falsy', function test( t ) { +tape( 'the function treats `NaN` values as falsy', function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 2.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dlastIndexOfFalsy( x.length, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -80,14 +69,72 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - actual = dlastIndexOfFalsy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + actual = dlastIndexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfFalsy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + actual = dlastIndexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); + + actual = dlastIndexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dlastIndexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.native.js index 6ebcd8a73e85..621e73d51d97 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.native.js @@ -46,33 +46,22 @@ tape( 'the function returns the index of the last falsy element', opts, function var actual; var x; - x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 0.0, 4.0 ] ); + x = new Float64Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfFalsy( x.length, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dlastIndexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + t.strictEqual( actual, 5, 'returns expected value' ); t.end(); }); -tape( 'the function explicitly treats `NaN` values as falsy', opts, function test( t ) { +tape( 'the function treats `NaN` values as falsy', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 2.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dlastIndexOfFalsy( x.length, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -89,14 +78,72 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - actual = dlastIndexOfFalsy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + actual = dlastIndexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfFalsy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + actual = dlastIndexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); + + actual = dlastIndexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dlastIndexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.js index aa10a54bf633..b7b048618258 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.js @@ -37,77 +37,101 @@ tape( 'the function returns the index of the last falsy element', function test( var actual; var x; - x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 0.0, 4.0 ] ); + x = new Float64Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - actual = dlastIndexOfFalsy( 6, x, 1, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, 5, 'returns expected value' ); - actual = dlastIndexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOfFalsy( x.length-2, x, 1, 2 ); +tape( 'the function explicitly treats `NaN` values as falsy', function test( t ) { + var actual; + var x; + + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); + + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dlastIndexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); +}); - // Negative stride... - actual = dlastIndexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a falsy element', function test( t ) { + var actual; + var x; - actual = dlastIndexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - actual = dlastIndexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0 ] ); + actual = dlastIndexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfFalsy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dlastIndexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function explicitly treats `NaN` values as falsy', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 2.0, NaN, 0.0 ] ); + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); - actual = dlastIndexOfFalsy( 4, x, 1, 0 ); - t.strictEqual( actual, 3, 'returns expected value' ); + actual = dlastIndexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a falsy element', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); - actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; + var x; - actual = dlastIndexOfFalsy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = dlastIndexOfFalsy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dlastIndexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.native.js index cd8245449553..f68cc86b0c7b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.native.js @@ -46,77 +46,101 @@ tape( 'the function returns the index of the last falsy element', opts, function var actual; var x; - x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 0.0, 4.0 ] ); + x = new Float64Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - actual = dlastIndexOfFalsy( 6, x, 1, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, 5, 'returns expected value' ); + + t.end(); +}); - actual = dlastIndexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); +tape( 'the function treats `NaN` values as falsy', opts, function test( t ) { + var actual; + var x; - actual = dlastIndexOfFalsy( x.length-2, x, 1, 2 ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); + + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dlastIndexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); +}); - // Negative stride... - actual = dlastIndexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a falsy element', opts, function test( t ) { + var actual; + var x; - actual = dlastIndexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - actual = dlastIndexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - var x; - x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0 ] ); + actual = dlastIndexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfFalsy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dlastIndexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function explicitly treats `NaN` values as falsy', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 2.0, NaN, 0.0 ] ); + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); - actual = dlastIndexOfFalsy( 4, x, 1, 0 ); - t.strictEqual( actual, 3, 'returns expected value' ); + actual = dlastIndexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a falsy element', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); - actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` offset', opts, function test( t ) { var actual; + var x; - actual = dlastIndexOfFalsy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = dlastIndexOfFalsy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dlastIndexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/README.md b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/README.md index d501ea777bcc..e10501400679 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/README.md @@ -125,7 +125,7 @@ var idx = glastIndexOfFalsy.ndarray( 3, x, 1, x.length-3 ); ## Notes -- If unable to find a falsy element, both functions return `-1`. +- Both functions explicitly treat `NaN` values as falsy. - 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/glast-index-of-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/docs/repl.txt index d306a5a2193b..0357c68729c4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/docs/repl.txt @@ -10,6 +10,8 @@ If `N <= 0`, the function returns `-1`. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -28,10 +30,22 @@ Examples -------- + // Standard usage: > var x = [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0 ]; > var idx = {{alias}}( x.length, x, 1 ) 4 + // Using `N` and stride parameters: + > var x = [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0 ]; + > var idx = {{alias}}( 3, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 0.0, 2.0, 0.0, 4.0, 5.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the last falsy element in a strided array using @@ -41,6 +55,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -62,9 +78,15 @@ Examples -------- + // Standard usage: > var x = [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0 ]; > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 4 + // Using an index offset: + > var x = [ 1.0, 0.0, 2.0, 0.0, 4.0, 5.0 ]; + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/docs/types/index.d.ts index fb1af7939758..79af35ff410c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/docs/types/index.d.ts @@ -36,7 +36,8 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. + * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array @@ -56,7 +57,8 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. + * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array @@ -78,7 +80,8 @@ interface Routine { * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements * @param x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/docs/types/test.ts index a8a4aea7f3fe..f79f4ca31755 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/docs/types/test.ts @@ -39,6 +39,7 @@ import glastIndexOfFalsy = require( './index' ); glastIndexOfFalsy( false, x, 1 ); // $ExpectError glastIndexOfFalsy( null, x, 1 ); // $ExpectError glastIndexOfFalsy( {}, x, 1 ); // $ExpectError + glastIndexOfFalsy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a collection... @@ -48,6 +49,7 @@ import glastIndexOfFalsy = require( './index' ); glastIndexOfFalsy( x.length, false, 1 ); // $ExpectError glastIndexOfFalsy( x.length, null, 1 ); // $ExpectError glastIndexOfFalsy( x.length, {}, 1 ); // $ExpectError + glastIndexOfFalsy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -59,6 +61,7 @@ import glastIndexOfFalsy = require( './index' ); glastIndexOfFalsy( x.length, x, false ); // $ExpectError glastIndexOfFalsy( x.length, x, null ); // $ExpectError glastIndexOfFalsy( x.length, x, {} ); // $ExpectError + glastIndexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -86,6 +89,7 @@ import glastIndexOfFalsy = require( './index' ); glastIndexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError glastIndexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError glastIndexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + glastIndexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a collection... @@ -95,6 +99,7 @@ import glastIndexOfFalsy = require( './index' ); glastIndexOfFalsy.ndarray( x.length, false, 1, 1 ); // $ExpectError glastIndexOfFalsy.ndarray( x.length, null, 1, 1 ); // $ExpectError glastIndexOfFalsy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + glastIndexOfFalsy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -106,6 +111,7 @@ import glastIndexOfFalsy = require( './index' ); glastIndexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError glastIndexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError glastIndexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + glastIndexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -117,6 +123,7 @@ import glastIndexOfFalsy = require( './index' ); glastIndexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError glastIndexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError glastIndexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + glastIndexOfFalsy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/lib/main.js index 6aea672e4c17..27e800a4e69c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/lib/main.js @@ -31,7 +31,8 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/lib/ndarray.js index 79d672073976..a094fc858039 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/lib/ndarray.js @@ -30,7 +30,8 @@ var gindexOfFalsy = require( '@stdlib/blas/ext/base/gindex-of-falsy' ).ndarray; * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. +* - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/test/test.main.js index 806e8fffbe33..6a65c2553c8c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/test/test.main.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var glastIndexOfFalsy = require( './../lib' ); @@ -44,20 +45,9 @@ tape( 'the function returns the index of the last falsy element', function test( x = [ 2.0, 0.0, 3.0, 0.0, 0.0, 4.0 ]; - // Nonnegative stride... actual = glastIndexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = glastIndexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = glastIndexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = glastIndexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -67,20 +57,9 @@ tape( 'the function returns the index of the last falsy element (accessors)', fu x = toAccessorArray( [ 2.0, 0.0, 3.0, 0.0, 0.0, 4.0 ] ); - // Nonnegative stride... actual = glastIndexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = glastIndexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = glastIndexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = glastIndexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -132,7 +111,7 @@ tape( 'the function returns `-1` if unable to find a falsy element (accessors)', t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = glastIndexOfFalsy( 0, [ 1.0, 2.0, 3.0 ], 1 ); @@ -144,7 +123,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = glastIndexOfFalsy( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -155,3 +134,97 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]; + + actual = glastIndexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]; + + actual = glastIndexOfFalsy( 3, toAccessorArray( x ), 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]; + + actual = glastIndexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]; + + actual = glastIndexOfFalsy( 3, toAccessorArray( x ), -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = glastIndexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/test/test.ndarray.js index fb34329438e4..f75ba248dafe 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-falsy/test/test.ndarray.js @@ -44,29 +44,9 @@ tape( 'the function returns the index of the last falsy element', function test( x = [ 2.0, 0.0, 3.0, 0.0, 0.0, 4.0 ]; - // Nonnegative stride... actual = glastIndexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = glastIndexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = glastIndexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = glastIndexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = glastIndexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = glastIndexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = glastIndexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -76,53 +56,9 @@ tape( 'the function returns the index of the last falsy element (accessors)', fu x = toAccessorArray( [ 2.0, 0.0, 3.0, 0.0, 0.0, 4.0 ] ); - // Nonnegative stride... actual = glastIndexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = glastIndexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = glastIndexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = glastIndexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = glastIndexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = glastIndexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = glastIndexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports an offset parameter', function test( t ) { - var actual; - var x; - - x = [ 0.0, 2.0, 3.0, 0.0, 4.0, 0.0 ]; - - actual = glastIndexOfFalsy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports an offset parameter (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0.0, 2.0, 3.0, 0.0, 4.0, 0.0 ] ); - - actual = glastIndexOfFalsy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); - t.end(); }); @@ -174,7 +110,7 @@ tape( 'the function returns `-1` if unable to find a falsy element (accessors)', t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = glastIndexOfFalsy( 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); @@ -186,7 +122,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = glastIndexOfFalsy( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -197,3 +133,113 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]; + + actual = glastIndexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]; + + actual = glastIndexOfFalsy( 3, toAccessorArray( x ), 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]; + + actual = glastIndexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]; + + actual = glastIndexOfFalsy( 3, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = [ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]; + + actual = glastIndexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]; + + actual = glastIndexOfFalsy( 3, toAccessorArray( x ), 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/repl.txt index 448f51673c35..6209d968cccd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/repl.txt @@ -31,10 +31,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 5 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 0.0, 3.0, 0.0, 4.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 0.0, 2.0, 0.0, 4.0, 5.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the last falsy element in a single-precision floating- @@ -44,6 +56,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -65,9 +79,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 5 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 0.0, 2.0, 0.0, 4.0, 5.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/types/index.d.ts index 25576548c2d1..b2f726527956 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/types/test.ts index aa09d227147b..f3d5d098f9ee 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/docs/types/test.ts @@ -37,6 +37,7 @@ import slastIndexOfFalsy = require( './index' ); slastIndexOfFalsy( false, x, 1 ); // $ExpectError slastIndexOfFalsy( null, x, 1 ); // $ExpectError slastIndexOfFalsy( {}, x, 1 ); // $ExpectError + slastIndexOfFalsy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float32Array... @@ -46,6 +47,7 @@ import slastIndexOfFalsy = require( './index' ); slastIndexOfFalsy( x.length, false, 1 ); // $ExpectError slastIndexOfFalsy( x.length, null, 1 ); // $ExpectError slastIndexOfFalsy( x.length, {}, 1 ); // $ExpectError + slastIndexOfFalsy( x.length, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -57,6 +59,7 @@ import slastIndexOfFalsy = require( './index' ); slastIndexOfFalsy( x.length, x, false ); // $ExpectError slastIndexOfFalsy( x.length, x, null ); // $ExpectError slastIndexOfFalsy( x.length, x, {} ); // $ExpectError + slastIndexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -83,6 +86,7 @@ import slastIndexOfFalsy = require( './index' ); slastIndexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError slastIndexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError slastIndexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + slastIndexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float32Array... @@ -92,6 +96,7 @@ import slastIndexOfFalsy = require( './index' ); slastIndexOfFalsy.ndarray( x.length, false, 1, 1 ); // $ExpectError slastIndexOfFalsy.ndarray( x.length, null, 1, 1 ); // $ExpectError slastIndexOfFalsy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + slastIndexOfFalsy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -103,6 +108,7 @@ import slastIndexOfFalsy = require( './index' ); slastIndexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError slastIndexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError slastIndexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + slastIndexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -114,6 +120,7 @@ import slastIndexOfFalsy = require( './index' ); slastIndexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError slastIndexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError slastIndexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + slastIndexOfFalsy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/ndarray.js index 572a88ac8570..78dd9dbcea69 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/ndarray.js @@ -30,7 +30,7 @@ var sindexOfFalsy = require( '@stdlib/blas/ext/base/sindex-of-falsy' ).ndarray; * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/ndarray.native.js index da2fea8cfce2..09bdce245d47 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/slast_index_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/slast_index_of_falsy.js index 0fac71cf9151..33e234cf0f87 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/slast_index_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/slast_index_of_falsy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/slast_index_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/slast_index_of_falsy.native.js index d40722f56f9d..e838d23c5c77 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/slast_index_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/lib/slast_index_of_falsy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/manifest.json index 55febf7643aa..c18284881cef 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/manifest.json @@ -37,13 +37,13 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/ext/base/sindex-of-falsy", "@stdlib/strided/base/stride2offset", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/create-int32" + "@stdlib/napi/create-int32", + "@stdlib/blas/ext/base/sindex-of-falsy" ] }, { @@ -58,8 +58,8 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/ext/base/sindex-of-falsy", - "@stdlib/strided/base/stride2offset" + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/ext/base/sindex-of-falsy" ] }, { @@ -74,8 +74,8 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/ext/base/sindex-of-falsy", - "@stdlib/strided/base/stride2offset" + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/ext/base/sindex-of-falsy" ] } ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/src/main.c index 684c3351cd40..45ad0be63581 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/src/main.c @@ -45,18 +45,18 @@ CBLAS_INT API_SUFFIX(stdlib_strided_slast_index_of_falsy)( const CBLAS_INT N, co */ CBLAS_INT API_SUFFIX(stdlib_strided_slast_index_of_falsy_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { CBLAS_INT idx; - CBLAS_INT ox; - CBLAS_INT sx; + CBLAS_INT sv; + CBLAS_INT ov; if ( N <= 0 ) { return -1; } // Reverse the iteration order by flipping the stride and adjusting the offset: - ox = offsetX + ( ( N - 1 ) * strideX ); - sx = -strideX; + ov = offsetX + ( ( N - 1 ) * strideX ); + sv = -strideX; // Find the index of the first falsy element in the reversed "view": - idx = API_SUFFIX(stdlib_strided_sindex_of_falsy_ndarray)( N, X, sx, ox ); + idx = API_SUFFIX(stdlib_strided_sindex_of_falsy_ndarray)( N, X, sv, ov ); if ( idx < 0 ) { return idx; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.ndarray.js index 10bc3a6ea842..5861806b2be4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.ndarray.js @@ -39,29 +39,9 @@ tape( 'the function returns the index of the last falsy element', function test( x = new Float32Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - // Nonnegative stride... actual = slastIndexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 5, 'returns expected value' ); - actual = slastIndexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = slastIndexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = slastIndexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - actual = slastIndexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = slastIndexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = slastIndexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - t.end(); }); @@ -89,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = slastIndexOfFalsy( 0, new Float32Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); @@ -100,3 +80,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); + + actual = slastIndexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = slastIndexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = slastIndexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.ndarray.native.js index cbad7490d56d..03958f7d0b11 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.ndarray.native.js @@ -48,29 +48,9 @@ tape( 'the function returns the index of the last falsy element', opts, function x = new Float32Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - // Nonnegative stride... actual = slastIndexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 5, 'returns expected value' ); - actual = slastIndexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = slastIndexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = slastIndexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - actual = slastIndexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = slastIndexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = slastIndexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - t.end(); }); @@ -98,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = slastIndexOfFalsy( 0, new Float32Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); @@ -109,3 +89,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); + + actual = slastIndexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = slastIndexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = slastIndexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.slast_index_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.slast_index_of_falsy.js index a9ead14a4a97..35b041b099c3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.slast_index_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.slast_index_of_falsy.js @@ -39,20 +39,9 @@ tape( 'the function returns the index of the last falsy element', function test( x = new Float32Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - // Nonnegative stride... actual = slastIndexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 5, 'returns expected value' ); - actual = slastIndexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - actual = slastIndexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = slastIndexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - t.end(); }); @@ -80,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = slastIndexOfFalsy( 0, new Float32Array( [ 0.0, 1.0, 2.0 ] ), 1 ); @@ -91,3 +80,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); + + actual = slastIndexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = slastIndexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = slastIndexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.slast_index_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.slast_index_of_falsy.native.js index 344aabea1bb7..ac25be04b754 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.slast_index_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of-falsy/test/test.slast_index_of_falsy.native.js @@ -48,20 +48,9 @@ tape( 'the function returns the index of the last falsy element', opts, function x = new Float32Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - // Nonnegative stride... actual = slastIndexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 5, 'returns expected value' ); - actual = slastIndexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - actual = slastIndexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = slastIndexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - t.end(); }); @@ -89,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = slastIndexOfFalsy( 0, new Float32Array( [ 0.0, 1.0, 2.0 ] ), 1 ); @@ -100,3 +89,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); + + actual = slastIndexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float32Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = slastIndexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float32Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = slastIndexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/README.md b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/README.md index 3945c6da16eb..f63d7152fac4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/README.md @@ -157,7 +157,6 @@ var idx = zlastIndexOfFalsy.ndarray( 3, x, 1, x.length-3 ); - A complex number is falsy when both its real and imaginary components are falsy. - Both functions explicitly treat `NaN` values as falsy. -- If unable to find a falsy element, both functions return `-1`. @@ -280,7 +279,6 @@ CBLAS_INT stdlib_strided_zlast_index_of_falsy_ndarray( const CBLAS_INT N, const - A complex number is falsy when both its real and imaginary components are falsy. - Both functions explicitly treat `NaN` values as falsy. -- If unable to find a falsy element, both functions return `-1`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/repl.txt index 3f241d15045d..d62b7c77f0f8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/repl.txt @@ -34,20 +34,20 @@ Examples -------- - // Standard Usage: + // Standard usage: > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 2 // Using `N` and stride parameters: - > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); - > idx = {{alias}}( 2, x, 2 ) + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); + > var idx = {{alias}}( 2, x, 2 ) 1 // Using view offsets: > var x0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0 ] ); > var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > idx = {{alias}}( 2, x1, 1 ) + > var idx = {{alias}}( 2, x1, 1 ) 0 @@ -85,14 +85,14 @@ Examples -------- - // Standard Usage: + // Standard usage: > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 2 - // Advanced indexing: - > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 2.0, 3.0 ] ); - > idx = {{alias}}.ndarray( 2, x, 1, x.length-2 ) + // Using an index offset: + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}.ndarray( 2, x, 1, x.length-2 ) 0 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/types/index.d.ts index a8b53ed44702..9b3af902b7e0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/types/index.d.ts @@ -30,7 +30,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -54,7 +54,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -80,7 +80,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/types/test.ts index 5b67461ca26d..6d70bd57b021 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/docs/types/test.ts @@ -40,6 +40,7 @@ import zlastIndexOfFalsy = require( './index' ); zlastIndexOfFalsy( false, x, 1 ); // $ExpectError zlastIndexOfFalsy( null, x, 1 ); // $ExpectError zlastIndexOfFalsy( {}, x, 1 ); // $ExpectError + zlastIndexOfFalsy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Complex128Array... @@ -49,6 +50,7 @@ import zlastIndexOfFalsy = require( './index' ); zlastIndexOfFalsy( 3, false, 1 ); // $ExpectError zlastIndexOfFalsy( 3, null, 1 ); // $ExpectError zlastIndexOfFalsy( 3, {}, 1 ); // $ExpectError + zlastIndexOfFalsy( 3, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -60,6 +62,7 @@ import zlastIndexOfFalsy = require( './index' ); zlastIndexOfFalsy( x.length, x, false ); // $ExpectError zlastIndexOfFalsy( x.length, x, null ); // $ExpectError zlastIndexOfFalsy( x.length, x, {} ); // $ExpectError + zlastIndexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -86,6 +89,7 @@ import zlastIndexOfFalsy = require( './index' ); zlastIndexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError zlastIndexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError zlastIndexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + zlastIndexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex128Array... @@ -95,6 +99,7 @@ import zlastIndexOfFalsy = require( './index' ); zlastIndexOfFalsy.ndarray( 3, false, 1, 1 ); // $ExpectError zlastIndexOfFalsy.ndarray( 3, null, 1, 1 ); // $ExpectError zlastIndexOfFalsy.ndarray( 3, {}, 1, 1 ); // $ExpectError + zlastIndexOfFalsy.ndarray( 3, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -106,6 +111,7 @@ import zlastIndexOfFalsy = require( './index' ); zlastIndexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError zlastIndexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError zlastIndexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + zlastIndexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -117,6 +123,7 @@ import zlastIndexOfFalsy = require( './index' ); zlastIndexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError zlastIndexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError zlastIndexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + zlastIndexOfFalsy.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/ndarray.js index e020102aafc2..e486a3afe7bb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/ndarray.js @@ -31,7 +31,7 @@ var zindexOfFalsy = require( '@stdlib/blas/ext/base/zindex-of-falsy' ).ndarray; * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/ndarray.native.js index 5e4674f14fb3..a1a0c14356ee 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/ndarray.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/zlast_index_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/zlast_index_of_falsy.js index dfe6157f2dda..1d521e8abd9d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/zlast_index_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/zlast_index_of_falsy.js @@ -32,7 +32,7 @@ var ndarray = require( './ndarray.js' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/zlast_index_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/zlast_index_of_falsy.native.js index e270fb957ef8..b8f56a04a25f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/zlast_index_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/lib/zlast_index_of_falsy.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/manifest.json index bf947268f84e..0dec01b8169a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/manifest.json @@ -37,14 +37,14 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/ext/base/zindex-of-falsy", "@stdlib/complex/float64/ctor", "@stdlib/strided/base/stride2offset", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex128array", - "@stdlib/napi/create-int32" + "@stdlib/napi/create-int32", + "@stdlib/blas/ext/base/zindex-of-falsy" ] }, { @@ -59,9 +59,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/ext/base/zindex-of-falsy", "@stdlib/complex/float64/ctor", - "@stdlib/strided/base/stride2offset" + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/ext/base/zindex-of-falsy" ] }, { @@ -76,9 +76,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/ext/base/zindex-of-falsy", "@stdlib/complex/float64/ctor", - "@stdlib/strided/base/stride2offset" + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/ext/base/zindex-of-falsy" ] } ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/src/main.c index 8292f266a70e..5f1f9b703801 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/src/main.c @@ -45,18 +45,18 @@ CBLAS_INT API_SUFFIX(stdlib_strided_zlast_index_of_falsy)( const CBLAS_INT N, co */ CBLAS_INT API_SUFFIX(stdlib_strided_zlast_index_of_falsy_ndarray)( const CBLAS_INT N, const stdlib_complex128_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { CBLAS_INT idx; - CBLAS_INT ox; - CBLAS_INT sx; + CBLAS_INT sv; + CBLAS_INT ov; if ( N <= 0 ) { return -1; } // Reverse the iteration order by flipping the stride and adjusting the offset: - ox = offsetX + ( ( N - 1 ) * strideX ); - sx = -strideX; + ov = offsetX + ( ( N - 1 ) * strideX ); + sv = -strideX; // Find the index of the first falsy element in the reversed "view": - idx = API_SUFFIX(stdlib_strided_zindex_of_falsy_ndarray)( N, X, sx, ox ); + idx = API_SUFFIX(stdlib_strided_zindex_of_falsy_ndarray)( N, X, sv, ov ); if ( idx < 0 ) { return idx; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.ndarray.js index c5ba4c3cdff1..2dff52e8cdcb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.ndarray.js @@ -47,16 +47,10 @@ tape( 'the function returns the index of the last falsy element', function test( actual = zlastIndexOfFalsy( 6, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = zlastIndexOfFalsy( 5, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = zlastIndexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - t.end(); }); -tape( 'if provided an N parameter less than or equal to 0, the function returns -1', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -95,7 +89,7 @@ tape( 'the function supports a negative `x` stride', function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset parameter', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.ndarray.native.js index 4325be82734a..f8bf0c63181b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.ndarray.native.js @@ -56,16 +56,10 @@ tape( 'the function returns the index of the last falsy element', opts, function actual = zlastIndexOfFalsy( 6, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = zlastIndexOfFalsy( 5, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = zlastIndexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - t.end(); }); -tape( 'if provided an N parameter less than or equal to 0, the function returns -1', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -104,7 +98,7 @@ tape( 'the function supports a negative `x` stride', opts, function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset parameter', opts, function test( t ) { +tape( 'the function supports an `x` offset', opts, function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.zlast_index_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.zlast_index_of_falsy.js index ef1f4e68ca01..184552488359 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.zlast_index_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.zlast_index_of_falsy.js @@ -47,15 +47,10 @@ tape( 'the function returns the index of the last falsy element', function test( actual = zlastIndexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - x = new Complex128Array( [ 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 0.0, 0.0 ] ); - - actual = zlastIndexOfFalsy( x.length, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter less than or equal to 0', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.zlast_index_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.zlast_index_of_falsy.native.js index 27c81be2ce10..0a7118073c09 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.zlast_index_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-falsy/test/test.zlast_index_of_falsy.native.js @@ -56,15 +56,10 @@ tape( 'the function returns the index of the last falsy element', opts, function actual = zlastIndexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - x = new Complex128Array( [ 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 0.0, 0.0 ] ); - - actual = zlastIndexOfFalsy( x.length, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter less than or equal to 0', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; From 5184528648a0af53c5547010520fa63cbb750c0f Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 00:03:37 +0500 Subject: [PATCH 07/68] fix: refactor `index-of-not-equal` --- .../base/dindex-of-not-equal/docs/repl.txt | 4 +- .../dindex-of-not-equal/docs/types/test.ts | 9 ++ .../test/test.dindex_of_not_equal.js | 36 ++----- .../test/test.dindex_of_not_equal.native.js | 36 ++----- .../dindex-of-not-equal/test/test.ndarray.js | 50 +++------ .../test/test.ndarray.native.js | 50 +++------ .../base/gindex-of-not-equal/docs/repl.txt | 4 +- .../gindex-of-not-equal/docs/types/test.ts | 7 ++ .../gindex-of-not-equal/test/test.main.js | 72 ++++--------- .../gindex-of-not-equal/test/test.ndarray.js | 100 ++++++------------ .../base/sindex-of-not-equal/docs/repl.txt | 4 +- .../sindex-of-not-equal/docs/types/test.ts | 9 ++ .../sindex-of-not-equal/test/test.ndarray.js | 50 +++------ .../test/test.ndarray.native.js | 50 +++------ .../test/test.sindex_of_not_equal.js | 36 ++----- .../test/test.sindex_of_not_equal.native.js | 36 ++----- 16 files changed, 181 insertions(+), 372 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/repl.txt index 25a5b034fb96..e65ec7ee4ec5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/repl.txt @@ -42,7 +42,7 @@ > var idx = {{alias}}( 3, 1.0, x, 2 ) 1 - // View offsets: + // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 1.0, 1.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var idx = {{alias}}( 2, 1.0, x1, 1 ) @@ -87,7 +87,7 @@ > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) 2 - // Advanced indexing: + // Using an index offset: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 1.0, 3.0, 1.0, 4.0 ] ); > var idx = {{alias}}.ndarray( 3, 1.0, x, 2, 1 ) 0 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/types/test.ts index fff8d364263d..41f423e809b4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/types/test.ts @@ -37,6 +37,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual( false, 2.0, x, 1 ); // $ExpectError dindexOfNotEqual( null, 2.0, x, 1 ); // $ExpectError dindexOfNotEqual( {}, 2.0, x, 1 ); // $ExpectError + dindexOfNotEqual( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -48,6 +49,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual( x.length, false, x, 1 ); // $ExpectError dindexOfNotEqual( x.length, null, x, 1 ); // $ExpectError dindexOfNotEqual( x.length, {}, x, 1 ); // $ExpectError + dindexOfNotEqual( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float64Array... @@ -57,6 +59,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual( x.length, 1.0, false, 1 ); // $ExpectError dindexOfNotEqual( x.length, 1.0, null, 1 ); // $ExpectError dindexOfNotEqual( x.length, 1.0, {}, 1 ); // $ExpectError + dindexOfNotEqual( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -68,6 +71,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual( x.length, 2.0, x, false ); // $ExpectError dindexOfNotEqual( x.length, 2.0, x, null ); // $ExpectError dindexOfNotEqual( x.length, 2.0, x, {} ); // $ExpectError + dindexOfNotEqual( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -94,6 +98,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + dindexOfNotEqual.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... @@ -105,6 +110,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual.ndarray( x.length, false, x, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, null, x, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, {}, x, 1, 1 ); // $ExpectError + dindexOfNotEqual.ndarray( x.length, ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array... @@ -114,6 +120,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + dindexOfNotEqual.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -125,6 +132,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + dindexOfNotEqual.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -136,6 +144,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + dindexOfNotEqual.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.js index 031bcd089736..37541133d141 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.js @@ -44,33 +44,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOfNotEqual( x.length, 1.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dindexOfNotEqual( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = dindexOfNotEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -131,13 +107,19 @@ tape( 'the function supports an `x` stride', function test( t ) { t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ] ); + x = new Float64Array([ + 1.0, // 2 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 0 + ]); - actual = dindexOfNotEqual( x.length, 1.0, x, -1 ); + actual = dindexOfNotEqual( 3, 1.0, x, -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.native.js index 7b5ee6595253..bf6ccc93f735 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.native.js @@ -53,33 +53,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOfNotEqual( x.length, 1.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dindexOfNotEqual( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = dindexOfNotEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -140,13 +116,19 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ] ); + x = new Float64Array([ + 1.0, // 2 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 0 + ]); - actual = dindexOfNotEqual( x.length, 1.0, x, -1 ); + actual = dindexOfNotEqual( 3, 1.0, x, -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.js index ecd2cdab08aa..3a6b1646bd9d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.js @@ -44,33 +44,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOfNotEqual( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dindexOfNotEqual( x.length, 2.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = dindexOfNotEqual( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -131,33 +107,39 @@ tape( 'the function supports an `x` stride', function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; x = new Float64Array([ - 9.0, - 0.0, // 0 + 1.0, // 2 9.0, 0.0, // 1 9.0, - 1.0 // 2 + 1.0 // 0 ]); - actual = dindexOfNotEqual( 3, 0.0, x, 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dindexOfNotEqual( 3, 1.0, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; var x; - x = new Float64Array( [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ] ); + x = new Float64Array([ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]); - actual = dindexOfNotEqual( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = dindexOfNotEqual( 3, 0.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.native.js index 2d2cfb19eaa6..bfb33c9f5809 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.native.js @@ -53,33 +53,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOfNotEqual( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dindexOfNotEqual( x.length, 2.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = dindexOfNotEqual( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -140,33 +116,39 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; x = new Float64Array([ - 9.0, - 0.0, // 0 + 1.0, // 2 9.0, 0.0, // 1 9.0, - 1.0 // 2 + 1.0 // 0 ]); - actual = dindexOfNotEqual( 3, 0.0, x, 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dindexOfNotEqual( 3, 1.0, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports an `x` offset', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ] ); + x = new Float64Array([ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]); - actual = dindexOfNotEqual( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = dindexOfNotEqual( 3, 0.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/repl.txt index 5bed55ccbb29..17c48625c075 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/repl.txt @@ -42,7 +42,7 @@ > var idx = {{alias}}( 3, 1.0, x, 2 ) 1 - // View offsets: + // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 1.0, 1.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var idx = {{alias}}( 2, 1.0, x1, 1 ) @@ -86,7 +86,7 @@ > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) 2 - // Advanced indexing: + // Using an index offset: > var x = [ 1.0, 2.0, 1.0, 3.0, 1.0, 4.0 ]; > var idx = {{alias}}.ndarray( 3, 1.0, x, 2, 1 ) 0 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/types/test.ts index d58b9cf76888..b53da7e6606e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/types/test.ts @@ -39,6 +39,7 @@ import gindexOfNotEqual = require( './index' ); gindexOfNotEqual( false, 2.0, x, 1 ); // $ExpectError gindexOfNotEqual( null, 2.0, x, 1 ); // $ExpectError gindexOfNotEqual( {}, 2.0, x, 1 ); // $ExpectError + gindexOfNotEqual( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a collection... @@ -48,6 +49,7 @@ import gindexOfNotEqual = require( './index' ); gindexOfNotEqual( x.length, 1.0, false, 1 ); // $ExpectError gindexOfNotEqual( x.length, 1.0, null, 1 ); // $ExpectError gindexOfNotEqual( x.length, 1.0, {}, 1 ); // $ExpectError + gindexOfNotEqual( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -59,6 +61,7 @@ import gindexOfNotEqual = require( './index' ); gindexOfNotEqual( x.length, 2.0, x, false ); // $ExpectError gindexOfNotEqual( x.length, 2.0, x, null ); // $ExpectError gindexOfNotEqual( x.length, 2.0, x, {} ); // $ExpectError + gindexOfNotEqual( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -86,6 +89,7 @@ import gindexOfNotEqual = require( './index' ); gindexOfNotEqual.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError gindexOfNotEqual.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError gindexOfNotEqual.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + gindexOfNotEqual.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... @@ -95,6 +99,7 @@ import gindexOfNotEqual = require( './index' ); gindexOfNotEqual.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError gindexOfNotEqual.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError gindexOfNotEqual.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + gindexOfNotEqual.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -106,6 +111,7 @@ import gindexOfNotEqual = require( './index' ); gindexOfNotEqual.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError gindexOfNotEqual.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError gindexOfNotEqual.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + gindexOfNotEqual.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -117,6 +123,7 @@ import gindexOfNotEqual = require( './index' ); gindexOfNotEqual.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError gindexOfNotEqual.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError gindexOfNotEqual.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + gindexOfNotEqual.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.main.js index 2601cf099fd8..1934428ca511 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.main.js @@ -45,33 +45,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... actual = gindexOfNotEqual( x.length, 1.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfNotEqual( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 4.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - actual = gindexOfNotEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 4.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -81,33 +57,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = gindexOfNotEqual( x.length, 1.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfNotEqual( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 4.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = toAccessorArray( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = gindexOfNotEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 4.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -213,25 +165,37 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ]; + x = [ + 1.0, // 2 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 0 + ]; - actual = gindexOfNotEqual( x.length, 1.0, x, -1 ); + actual = gindexOfNotEqual( 3, 1.0, x, -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; - x = [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ]; + x = [ + 1.0, // 2 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 0 + ]; - actual = gindexOfNotEqual( x.length, 1.0, toAccessorArray( x ), -1 ); + actual = gindexOfNotEqual( 3, 1.0, toAccessorArray( x ), -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.ndarray.js index 2b80a3a06bcb..069f57691006 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.ndarray.js @@ -44,33 +44,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... actual = gindexOfNotEqual( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfNotEqual( x.length, 2.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 3.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 4.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - actual = gindexOfNotEqual( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -80,33 +56,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = gindexOfNotEqual( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfNotEqual( x.length, 2.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 3.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 4.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = toAccessorArray( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = gindexOfNotEqual( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfNotEqual( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -212,64 +164,76 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; x = [ - 9.0, - 0.0, // 0 + 1.0, // 2 9.0, 0.0, // 1 9.0, - 1.0 // 2 + 1.0 // 0 ]; - actual = gindexOfNotEqual( 3, 0.0, x, 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = gindexOfNotEqual( 3, 1.0, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an `x` offset (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; x = [ - 9.0, - 0.0, // 0 + 1.0, // 2 9.0, 0.0, // 1 9.0, - 1.0 // 2 + 1.0 // 0 ]; - actual = gindexOfNotEqual( 3, 0.0, toAccessorArray( x ), 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = gindexOfNotEqual( 3, 1.0, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; var x; - x = [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ]; + x = [ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; - actual = gindexOfNotEqual( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gindexOfNotEqual( 3, 0.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports an `x` offset (accessors)', function test( t ) { var actual; var x; - x = [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ]; + x = [ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; - actual = gindexOfNotEqual( x.length, 0.0, toAccessorArray( x ), -1, x.length-1 ); // eslint-disable-line max-len - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gindexOfNotEqual( 3, 0.0, toAccessorArray( x ), 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/docs/repl.txt index 6b141fc5b8fb..9b9682cf3c23 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/docs/repl.txt @@ -42,7 +42,7 @@ > var idx = {{alias}}( 3, 1.0, x, 2 ) 1 - // View offsets: + // Using view offsets: > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 1.0, 1.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var idx = {{alias}}( 2, 1.0, x1, 1 ) @@ -87,7 +87,7 @@ > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) 2 - // Advanced indexing: + // Using an index offset: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 1.0, 3.0, 1.0, 4.0 ] ); > var idx = {{alias}}.ndarray( 3, 1.0, x, 2, 1 ) 0 diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/docs/types/test.ts index 7558995cc75e..1f40d50e0001 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/docs/types/test.ts @@ -37,6 +37,7 @@ import sindexOfNotEqual = require( './index' ); sindexOfNotEqual( false, 2.0, x, 1 ); // $ExpectError sindexOfNotEqual( null, 2.0, x, 1 ); // $ExpectError sindexOfNotEqual( {}, 2.0, x, 1 ); // $ExpectError + sindexOfNotEqual( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -48,6 +49,7 @@ import sindexOfNotEqual = require( './index' ); sindexOfNotEqual( x.length, false, x, 1 ); // $ExpectError sindexOfNotEqual( x.length, null, x, 1 ); // $ExpectError sindexOfNotEqual( x.length, {}, x, 1 ); // $ExpectError + sindexOfNotEqual( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float32Array... @@ -57,6 +59,7 @@ import sindexOfNotEqual = require( './index' ); sindexOfNotEqual( x.length, 1.0, false, 1 ); // $ExpectError sindexOfNotEqual( x.length, 1.0, null, 1 ); // $ExpectError sindexOfNotEqual( x.length, 1.0, {}, 1 ); // $ExpectError + sindexOfNotEqual( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -68,6 +71,7 @@ import sindexOfNotEqual = require( './index' ); sindexOfNotEqual( x.length, 2.0, x, false ); // $ExpectError sindexOfNotEqual( x.length, 2.0, x, null ); // $ExpectError sindexOfNotEqual( x.length, 2.0, x, {} ); // $ExpectError + sindexOfNotEqual( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -94,6 +98,7 @@ import sindexOfNotEqual = require( './index' ); sindexOfNotEqual.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError sindexOfNotEqual.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError sindexOfNotEqual.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + sindexOfNotEqual.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... @@ -105,6 +110,7 @@ import sindexOfNotEqual = require( './index' ); sindexOfNotEqual.ndarray( x.length, false, x, 1, 1 ); // $ExpectError sindexOfNotEqual.ndarray( x.length, null, x, 1, 1 ); // $ExpectError sindexOfNotEqual.ndarray( x.length, {}, x, 1, 1 ); // $ExpectError + sindexOfNotEqual.ndarray( x.length, ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float32Array... @@ -114,6 +120,7 @@ import sindexOfNotEqual = require( './index' ); sindexOfNotEqual.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError sindexOfNotEqual.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError sindexOfNotEqual.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + sindexOfNotEqual.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -125,6 +132,7 @@ import sindexOfNotEqual = require( './index' ); sindexOfNotEqual.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError sindexOfNotEqual.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError sindexOfNotEqual.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + sindexOfNotEqual.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -136,6 +144,7 @@ import sindexOfNotEqual = require( './index' ); sindexOfNotEqual.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError sindexOfNotEqual.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError sindexOfNotEqual.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + sindexOfNotEqual.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.ndarray.js index d89422034f31..c6ce99a4a76b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.ndarray.js @@ -44,33 +44,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = sindexOfNotEqual( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = sindexOfNotEqual( x.length, 2.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 3.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 4.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float32Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = sindexOfNotEqual( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -131,33 +107,39 @@ tape( 'the function supports an `x` stride', function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; x = new Float32Array([ - 9.0, - 0.0, // 0 + 1.0, // 2 9.0, 0.0, // 1 9.0, - 1.0 // 2 + 1.0 // 0 ]); - actual = sindexOfNotEqual( 3, 0.0, x, 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = sindexOfNotEqual( 3, 1.0, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; var x; - x = new Float32Array( [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ] ); + x = new Float32Array([ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]); - actual = sindexOfNotEqual( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = sindexOfNotEqual( 3, 0.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.ndarray.native.js index 5931e9cb225d..9aaf0d216b9a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.ndarray.native.js @@ -53,33 +53,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = sindexOfNotEqual( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = sindexOfNotEqual( x.length, 2.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 3.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 4.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float32Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = sindexOfNotEqual( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -140,33 +116,39 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; x = new Float32Array([ - 9.0, - 0.0, // 0 + 1.0, // 2 9.0, 0.0, // 1 9.0, - 1.0 // 2 + 1.0 // 0 ]); - actual = sindexOfNotEqual( 3, 0.0, x, 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = sindexOfNotEqual( 3, 1.0, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports an `x` offset', opts, function test( t ) { var actual; var x; - x = new Float32Array( [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ] ); + x = new Float32Array([ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]); - actual = sindexOfNotEqual( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = sindexOfNotEqual( 3, 0.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.sindex_of_not_equal.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.sindex_of_not_equal.js index 66be3bebe7f4..9a2b7d94eec3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.sindex_of_not_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.sindex_of_not_equal.js @@ -44,33 +44,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = sindexOfNotEqual( x.length, 1.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = sindexOfNotEqual( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 4.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float32Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = sindexOfNotEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 4.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -131,13 +107,19 @@ tape( 'the function supports an `x` stride', function test( t ) { t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ] ); + x = new Float32Array([ + 1.0, // 2 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 0 + ]); - actual = sindexOfNotEqual( x.length, 1.0, x, -1 ); + actual = sindexOfNotEqual( 3, 1.0, x, -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.sindex_of_not_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.sindex_of_not_equal.native.js index 9342c80c9ea2..ece5ca967254 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.sindex_of_not_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-not-equal/test/test.sindex_of_not_equal.native.js @@ -53,33 +53,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = sindexOfNotEqual( x.length, 1.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = sindexOfNotEqual( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 4.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float32Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = sindexOfNotEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = sindexOfNotEqual( x.length, 4.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -140,13 +116,19 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; - x = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ] ); + x = new Float32Array([ + 1.0, // 2 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 0 + ]); - actual = sindexOfNotEqual( x.length, 1.0, x, -1 ); + actual = sindexOfNotEqual( 3, 1.0, x, -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); From f3e6700ee86a1ef76567d9e06bfb94affcf12ac0 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 10:04:09 +0500 Subject: [PATCH 08/68] fix: refactor `index-of-less-than` --- .../ext/base/gindex-of-less-than/README.md | 2 +- .../base/gindex-of-less-than/docs/repl.txt | 4 +- .../gindex-of-less-than/docs/types/index.d.ts | 6 +- .../gindex-of-less-than/docs/types/test.ts | 7 ++ .../base/gindex-of-less-than/lib/accessors.js | 2 +- .../ext/base/gindex-of-less-than/lib/main.js | 2 +- .../base/gindex-of-less-than/lib/ndarray.js | 2 +- .../gindex-of-less-than/test/test.main.js | 72 +++--------- .../gindex-of-less-than/test/test.ndarray.js | 104 ++++++------------ 9 files changed, 68 insertions(+), 133 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/README.md index 9f877664aa1b..3ee947327f67 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/README.md @@ -58,7 +58,7 @@ The function has the following parameters: - **x**: input array. - **strideX**: stride length. -If unable to find an element which is less than the search element, the function returns `-1`. +If the function is unable to find an element which is less than the search element, the function returns `-1`. ```javascript var x = [ 1.0, 1.0, 1.0, 1.0 ]; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/repl.txt index 89a34b8ec369..fccf6e7ee5a4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/repl.txt @@ -42,7 +42,7 @@ > var idx = {{alias}}( 3, 1.0, x, 2 ) 1 - // View offsets: + // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 1.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var idx = {{alias}}( 2, 1.0, x1, 1 ) @@ -86,7 +86,7 @@ > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) 2 - // Advanced indexing: + // Using an index offset: > var x = [ 1.0, 2.0, 1.0, 0.0, 1.0, 4.0 ]; > var idx = {{alias}}.ndarray( 3, 1.0, x, 2, 1 ) 1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/types/index.d.ts index 0fe897e089d7..d64ff58cdda9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/types/index.d.ts @@ -36,7 +36,7 @@ interface Routine { * * ## Notes * - * - If unable to find an element which is less than the search element, the function returns `-1`. + * - If the function is unable to find an element which is less than the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element @@ -57,7 +57,7 @@ interface Routine { * * ## Notes * - * - If unable to find an element which is less than the search element, the function returns `-1`. + * - If the function is unable to find an element which is less than the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element @@ -80,7 +80,7 @@ interface Routine { * * ## Notes * -* - If unable to find an element which is less than the search element, the function returns `-1`. +* - If the function is unable to find an element which is less than the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/types/test.ts index 8e4ec55da755..983b2ba1705b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/docs/types/test.ts @@ -39,6 +39,7 @@ import gindexOfLessThan = require( './index' ); gindexOfLessThan( false, 2.0, x, 1 ); // $ExpectError gindexOfLessThan( null, 2.0, x, 1 ); // $ExpectError gindexOfLessThan( {}, 2.0, x, 1 ); // $ExpectError + gindexOfLessThan( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a collection... @@ -48,6 +49,7 @@ import gindexOfLessThan = require( './index' ); gindexOfLessThan( x.length, 1.0, false, 1 ); // $ExpectError gindexOfLessThan( x.length, 1.0, null, 1 ); // $ExpectError gindexOfLessThan( x.length, 1.0, {}, 1 ); // $ExpectError + gindexOfLessThan( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -59,6 +61,7 @@ import gindexOfLessThan = require( './index' ); gindexOfLessThan( x.length, 2.0, x, false ); // $ExpectError gindexOfLessThan( x.length, 2.0, x, null ); // $ExpectError gindexOfLessThan( x.length, 2.0, x, {} ); // $ExpectError + gindexOfLessThan( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -86,6 +89,7 @@ import gindexOfLessThan = require( './index' ); gindexOfLessThan.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError gindexOfLessThan.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError gindexOfLessThan.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + gindexOfLessThan.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... @@ -95,6 +99,7 @@ import gindexOfLessThan = require( './index' ); gindexOfLessThan.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError gindexOfLessThan.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError gindexOfLessThan.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + gindexOfLessThan.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -106,6 +111,7 @@ import gindexOfLessThan = require( './index' ); gindexOfLessThan.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError gindexOfLessThan.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError gindexOfLessThan.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + gindexOfLessThan.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -117,6 +123,7 @@ import gindexOfLessThan = require( './index' ); gindexOfLessThan.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError gindexOfLessThan.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError gindexOfLessThan.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + gindexOfLessThan.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/accessors.js index 3eb0728bafba..db0f5ca5d58d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/accessors.js @@ -25,7 +25,7 @@ * * ## Notes * -* - If unable to find an element which is less than the search element, the function returns `-1`. +* - If the function is unable to find an element which is less than the search element, the function returns `-1`. * * @private * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/main.js index 56ef0e34ba5a..28b7da0cf5c0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/main.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find an element which is less than the search element, the function returns `-1`. +* - If the function is unable to find an element which is less than the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/ndarray.js index e103fe91f9c6..cdfe3578fbf3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/lib/ndarray.js @@ -31,7 +31,7 @@ var accessors = require( './accessors.js' ); * * ## Notes * -* - If unable to find an element which is less than the search element, the function returns `-1`. +* - If the function is unable to find an element which is less than the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/test/test.main.js index 885894e6f9de..81228db1c188 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/test/test.main.js @@ -45,33 +45,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ]; - // Nonnegative stride... - actual = gindexOfLessThan( x.length, 4.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfLessThan( x.length, 3.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfLessThan( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 1.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - x = [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - actual = gindexOfLessThan( x.length, 4.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 1.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -81,33 +57,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = toAccessorArray( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] ); - // Nonnegative stride... - actual = gindexOfLessThan( x.length, 4.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfLessThan( x.length, 3.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfLessThan( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 1.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - x = toAccessorArray( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = gindexOfLessThan( x.length, 4.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 1.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -243,25 +195,37 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ]; + x = [ + 1.0, // 2 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 0 + ]; - actual = gindexOfLessThan( x.length, 1.0, x, -1 ); + actual = gindexOfLessThan( 3, 1.0, x, -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; - x = [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ]; + x = [ + 1.0, // 2 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 0 + ]; - actual = gindexOfLessThan( x.length, 1.0, toAccessorArray( x ), -1 ); + actual = gindexOfLessThan( 3, 1.0, toAccessorArray( x ), -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/test/test.ndarray.js index 01798d158112..a4f9496e92a1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than/test/test.ndarray.js @@ -44,33 +44,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ]; - // Nonnegative stride... - actual = gindexOfLessThan( x.length, 4.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfLessThan( x.length, 3.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfLessThan( x.length, 2.0, x, 1, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 1.0, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - x = [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - actual = gindexOfLessThan( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -80,33 +56,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = toAccessorArray( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] ); - // Nonnegative stride... - actual = gindexOfLessThan( x.length, 4.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfLessThan( x.length, 3.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfLessThan( x.length, 2.0, x, 1, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 1.0, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - x = toAccessorArray( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = gindexOfLessThan( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThan( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -242,64 +194,76 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; x = [ + 1.0, // 2 9.0, - 1.0, // 0 + 0.0, // 1 9.0, - 1.0, // 1 - 9.0, - 0.0 // 2 + 1.0 // 0 ]; - actual = gindexOfLessThan( 3, 1.0, x, 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = gindexOfLessThan( 3, 1.0, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an `x` offset (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; x = [ + 1.0, // 2 9.0, - 1.0, // 0 - 9.0, - 1.0, // 1 + 0.0, // 1 9.0, - 0.0 // 2 + 1.0 // 0 ]; - actual = gindexOfLessThan( 3, 1.0, toAccessorArray( x ), 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = gindexOfLessThan( 3, 1.0, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; var x; - x = [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ]; + x = [ + 9.0, + 1.0, // 0 + 9.0, + 1.0, // 1 + 9.0, + 0.0 // 2 + ]; - actual = gindexOfLessThan( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gindexOfLessThan( 3, 1.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports an `x` offset (accessors)', function test( t ) { var actual; var x; - x = [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ]; + x = [ + 9.0, + 1.0, // 0 + 9.0, + 1.0, // 1 + 9.0, + 0.0 // 2 + ]; - actual = gindexOfLessThan( x.length, 1.0, toAccessorArray( x ), -1, x.length-1 ); // eslint-disable-line max-len - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gindexOfLessThan( 3, 1.0, toAccessorArray( x ), 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); From 29cf71bd5d7458325a38ba6d42d2677186ee14dc Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 10:27:00 +0500 Subject: [PATCH 09/68] fix: refactor `index-of-greater-than` --- .../ext/base/gindex-of-greater-than/README.md | 24 +-- .../base/gindex-of-greater-than/docs/repl.txt | 20 +-- .../docs/types/index.d.ts | 12 +- .../gindex-of-greater-than/docs/types/test.ts | 7 + .../gindex-of-greater-than/examples/index.js | 4 +- .../gindex-of-greater-than/lib/accessors.js | 6 +- .../base/gindex-of-greater-than/lib/index.js | 2 +- .../base/gindex-of-greater-than/lib/main.js | 6 +- .../gindex-of-greater-than/lib/ndarray.js | 6 +- .../base/gindex-of-greater-than/package.json | 2 +- .../gindex-of-greater-than/test/test.main.js | 155 ++++++++++-------- .../test/test.ndarray.js | 132 +++++++-------- 12 files changed, 197 insertions(+), 179 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/README.md index 334558f8f243..a5e7a17463f1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/README.md @@ -20,7 +20,7 @@ limitations under the License. # gindexOfGreaterThan -> Return the index of the first element in a strided array which is greater than a specified search element. +> Return the first index of an element in a strided array which is greater than a specified search element. @@ -42,7 +42,7 @@ var gindexOfGreaterThan = require( '@stdlib/blas/ext/base/gindex-of-greater-than #### gindexOfGreaterThan( N, searchElement, x, strideX ) -Returns the index of the first element in a strided array which is greater than a specified search element. +Returns the first index of an element in a strided array which is greater than a specified search element. ```javascript var x = [ 0.0, 0.0, 1.0, 0.0 ]; @@ -58,7 +58,7 @@ The function has the following parameters: - **x**: input array. - **strideX**: stride length. -If the function is unable to find an element which is greater than a specified search element, the function returns `-1`. +If the function is unable to find an element which is greater than the search element, the function returns `-1`. ```javascript var x = [ 0.0, 0.0, 0.0, 0.0 ]; @@ -70,10 +70,10 @@ var idx = gindexOfGreaterThan( x.length, 0.0, x, 1 ); The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to search every other element: ```javascript -var x = [ 0.0, 9.0, 0.0, 9.0, 1.0, 9.0 ]; +var x = [ 0.0, 9.0, 1.0, 9.0, 0.0, 9.0 ]; var idx = gindexOfGreaterThan( 3, 0.0, x, 2 ); -// returns 2 +// returns 1 ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -94,7 +94,7 @@ var idx = gindexOfGreaterThan( 3, 0.0, x1, 2 ); #### gindexOfGreaterThan.ndarray( N, searchElement, x, strideX, offsetX ) -Returns the index of the first element in a strided array which is greater than a specified search element using alternative indexing semantics. +Returns the first index of an element in a strided array which is greater than a specified search element using alternative indexing semantics. ```javascript var x = [ 0.0, 0.0, 1.0, 0.0 ]; @@ -110,10 +110,10 @@ The function has the following additional parameters: While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array: ```javascript -var x = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 2.0 ]; +var x = [ 0.0, 0.0, 1.0, 0.0 ]; -var idx = gindexOfGreaterThan.ndarray( 3, 0.0, x, 1, x.length-3 ); -// returns 2 +var idx = gindexOfGreaterThan.ndarray( 3, 0.0, x, 1, 1 ); +// returns 1 ``` @@ -126,7 +126,7 @@ var idx = gindexOfGreaterThan.ndarray( 3, 0.0, x, 1, x.length-3 ); ## Notes -- When comparing elements, the function uses the less-than operator `>`. As a consequence, comparisons involving `NaN` always evaluate to `false`, and `-0` and `+0` are considered the same. +- When comparing elements, the function uses the greater-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]). @@ -145,12 +145,12 @@ var idx = gindexOfGreaterThan.ndarray( 3, 0.0, x, 1, x.length-3 ); var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var gindexOfGreaterThan = require( '@stdlib/blas/ext/base/gindex-of-greater-than' ); -var x = discreteUniform( 10, -100, 100, { +var x = discreteUniform( 10, 0, 3, { 'dtype': 'generic' }); console.log( x ); -var idx = gindexOfGreaterThan( x.length, 80.0, x, 1 ); +var idx = gindexOfGreaterThan( x.length, 1.0, x, 1 ); console.log( idx ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/repl.txt index 3d12fc9463e6..e3fa00f47a50 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( N, searchElement, x, strideX ) - Returns the index of the first element in a strided array which is greater + Returns the first index of an element in a strided array which is greater than a specified search element. The `N` and stride parameters determine which elements in the strided array @@ -38,19 +38,19 @@ 2 // Using `N` and stride parameters: - > var x = [ 0.0, 9.0, 0.0, 9.0, 1.0, 9.0 ]; + > var x = [ 0.0, 9.0, 1.0, 9.0, 0.0, 9.0 ]; > var idx = {{alias}}( 3, 0.0, x, 2 ) - 2 + 1 - // View offsets: - > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 0.0, 0.0 ] ); + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var idx = {{alias}}( 2, 0.0, x1, 1 ) - 0 + 1 {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) - Returns the index of the first element in a strided array which is greater + Returns the first index of an element in a strided array which is greater than a specified search element using alternative indexing semantics. While typed array views mandate a view offset based on the underlying @@ -86,10 +86,10 @@ > var idx = {{alias}}.ndarray( x.length, 0.0, x, 1, 0 ) 2 - // Advanced indexing: - > var x = [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0 ]; + // Using an index offset: + > var x = [ 0.0, 0.0, 0.0, 1.0, 0.0, 2.0 ]; > var idx = {{alias}}.ndarray( 3, 0.0, x, 2, 1 ) - 0 + 1 See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/types/index.d.ts index b2c16858142b..762e571d0342 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/types/index.d.ts @@ -32,11 +32,11 @@ type InputArray = Collection | AccessorArrayLike; */ interface Routine { /** - * Returns the index of the first element in a strided array which is greater than a specified search element. + * Returns the first index of an element in a strided array which is greater than a specified search element. * * ## Notes * - * - If the function is unable to find an element which is greater than a search element, the function returns `-1`. + * - If the function is unable to find an element which is greater than the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element @@ -53,11 +53,11 @@ interface Routine { ( N: number, searchElement: unknown, x: InputArray, strideX: number ): number; /** - * Returns the index of the first element in a strided array which is greater than a specified search element using alternative indexing semantics. + * Returns the first index of an element in a strided array which is greater than a specified search element using alternative indexing semantics. * * ## Notes * - * - If the function is unable to find an element which is greater than a search element, the function returns `-1`. + * - If the function is unable to find an element which is greater than the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element @@ -76,11 +76,11 @@ interface Routine { } /** -* Returns the index of the first element in a strided array which is greater than a specified search element. +* Returns the first index of an element in a strided array which is greater than a specified search element. * * ## Notes * -* - If the function is unable to find an element which is greater than a search element, the function returns `-1`. +* - If the function is unable to find an element which is greater than the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/types/test.ts index 3ce550591f8d..8a3a8b76a7a1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/docs/types/test.ts @@ -39,6 +39,7 @@ import gindexOfGreaterThan = require( './index' ); gindexOfGreaterThan( false, 2.0, x, 1 ); // $ExpectError gindexOfGreaterThan( null, 2.0, x, 1 ); // $ExpectError gindexOfGreaterThan( {}, 2.0, x, 1 ); // $ExpectError + gindexOfGreaterThan( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a collection... @@ -48,6 +49,7 @@ import gindexOfGreaterThan = require( './index' ); gindexOfGreaterThan( x.length, 1.0, false, 1 ); // $ExpectError gindexOfGreaterThan( x.length, 1.0, null, 1 ); // $ExpectError gindexOfGreaterThan( x.length, 1.0, {}, 1 ); // $ExpectError + gindexOfGreaterThan( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -59,6 +61,7 @@ import gindexOfGreaterThan = require( './index' ); gindexOfGreaterThan( x.length, 2.0, x, false ); // $ExpectError gindexOfGreaterThan( x.length, 2.0, x, null ); // $ExpectError gindexOfGreaterThan( x.length, 2.0, x, {} ); // $ExpectError + gindexOfGreaterThan( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -86,6 +89,7 @@ import gindexOfGreaterThan = require( './index' ); gindexOfGreaterThan.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError gindexOfGreaterThan.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError gindexOfGreaterThan.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + gindexOfGreaterThan.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... @@ -95,6 +99,7 @@ import gindexOfGreaterThan = require( './index' ); gindexOfGreaterThan.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError gindexOfGreaterThan.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError gindexOfGreaterThan.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + gindexOfGreaterThan.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -106,6 +111,7 @@ import gindexOfGreaterThan = require( './index' ); gindexOfGreaterThan.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError gindexOfGreaterThan.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError gindexOfGreaterThan.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + gindexOfGreaterThan.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -117,6 +123,7 @@ import gindexOfGreaterThan = require( './index' ); gindexOfGreaterThan.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError gindexOfGreaterThan.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError gindexOfGreaterThan.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + gindexOfGreaterThan.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/examples/index.js index bdaa1033d703..b03a9c916b94 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/examples/index.js @@ -21,10 +21,10 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var gindexOfGreaterThan = require( './../lib' ); -var x = discreteUniform( 10, -100, 100, { +var x = discreteUniform( 10, 0, 3, { 'dtype': 'generic' }); console.log( x ); -var idx = gindexOfGreaterThan( x.length, 80.0, x, 1 ); +var idx = gindexOfGreaterThan( x.length, 1.0, x, 1 ); console.log( idx ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/accessors.js index 14815e6bd476..d1af28138664 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/accessors.js @@ -21,7 +21,11 @@ // MAIN // /** -* Returns the index of the first element in a strided array which is greater than a specified search element. +* Returns the first index of an element in a strided array which is greater than a specified search element. +* +* ## Notes +* +* - If the function is unable to find an element which is greater than the search element, the function returns `-1`. * * @private * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/index.js index e04f65b2e7db..b8c80359e473 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Return the index of the first element in a strided array which is greater than a specified search element. +* Return the first index of an element in a strided array which is greater than a specified search element. * * @module @stdlib/blas/ext/base/gindex-of-greater-than * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/main.js index 4845651f5323..f40ac1e16d56 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/main.js @@ -27,7 +27,11 @@ var ndarray = require( './ndarray.js' ); // MAIN // /** -* Returns the index of the first element in a strided array which is greater than a specified search element. +* Returns the first index of an element in a strided array which is greater than a specified search element. +* +* ## Notes +* +* - If the function is unable to find an element which is greater than the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/ndarray.js index 2642d556f3a9..c8efa2659e9c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/lib/ndarray.js @@ -27,7 +27,11 @@ var accessors = require( './accessors.js' ); // MAIN // /** -* Returns the index of the first element in a strided array which is greater than a specified search element using alternative indexing semantics. +* Returns the first index of an element in a strided array which is greater than a specified search element using alternative indexing semantics. +* +* ## Notes +* +* - If the function is unable to find an element which is greater than the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/package.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/package.json index e9434d033559..95a5d486fb12 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/ext/base/gindex-of-greater-than", "version": "0.0.0", - "description": "Return the index of the first element in a strided array which is greater than a specified search element.", + "description": "Return the first index of an element in a strided array which is greater than a specified search element.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/test/test.main.js index 1ffd15ba3d2d..e19e1fdfd8fe 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/test/test.main.js @@ -39,71 +39,49 @@ tape( 'the function has an arity of 4', function test( t ) { t.end(); }); -tape( 'the function returns the first index of an element which is greater than a search element', function test( t ) { +tape( 'the function returns the index of the first element in a strided array which is greater than a provided search element', function test( t ) { var actual; var x; x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... - actual = gindexOfGreaterThan( x.length, 0.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfGreaterThan( x.length, 1.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfGreaterThan( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfGreaterThan( x.length, 3.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfGreaterThan( x.length, 0.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThan( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThan( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThan( x.length, 3.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns the first index of an element which is greater than a search element (accessors)', function test( t ) { +tape( 'the function returns the index of the first element in a strided array which is greater than a provided search element (accessors)', function test( t ) { var actual; var x; x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... - actual = gindexOfGreaterThan( x.length, 0.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfGreaterThan( x.length, 1.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfGreaterThan( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + t.end(); +}); - actual = gindexOfGreaterThan( x.length, 3.0, x, 1 ); +tape( 'the function returns `-1` if every indexed element in the array is less than or equal to the search element', function test( t ) { + var actual; + var x; + + x = [ 2.0, 2.0, 2.0 ]; + + actual = gindexOfGreaterThan( x.length, 2.0, x, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = gindexOfGreaterThan( x.length, 0.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); +}); - actual = gindexOfGreaterThan( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function returns `-1` if every indexed element in the array is less than or equal to the search element (accessors)', function test( t ) { + var actual; + var x; - actual = gindexOfGreaterThan( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + x = toAccessorArray( [ 2.0, 2.0, 2.0 ] ); - actual = gindexOfGreaterThan( x.length, 3.0, x, -1 ); + actual = gindexOfGreaterThan( x.length, 2.0, x, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -136,10 +114,10 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; - actual = gindexOfGreaterThan( 1, NaN, [ 0.0 ], 1 ); + actual = gindexOfGreaterThan( 2, NaN, [ 0.0, 1.0 ], 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfGreaterThan( 1, 0.0, [ NaN ], 1 ); + actual = gindexOfGreaterThan( 2, 0.0, [ NaN, NaN ], 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -148,30 +126,36 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', function tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors)', function test( t ) { var actual; - actual = gindexOfGreaterThan( 1, NaN, toAccessorArray( [ 0.0 ] ), 1 ); + actual = gindexOfGreaterThan( 2, NaN, toAccessorArray( [ 0.0, 1.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfGreaterThan( 1, 0.0, toAccessorArray( [ NaN ] ), 1 ); + actual = gindexOfGreaterThan( 2, 0.0, toAccessorArray( [ NaN, NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = gindexOfGreaterThan( 1, -0.0, [ 0.0 ], 1 ); t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfGreaterThan( 1, 0.0, [ -0.0 ], 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = gindexOfGreaterThan( 1, -0.0, toAccessorArray( [ 0.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfGreaterThan( 1, 0.0, toAccessorArray( [ -0.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); }); @@ -182,14 +166,14 @@ tape( 'the function supports an `x` stride', function test( t ) { x = [ 0.0, // 0 9.0, - 0.0, // 1 + 1.0, // 1 9.0, - 1.0 // 2 + 0.0 // 2 ]; actual = gindexOfGreaterThan( 3, 0.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -200,72 +184,99 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { x = [ 0.0, // 0 9.0, - 0.0, // 1 + 1.0, // 1 9.0, - 1.0 // 2 + 0.0 // 2 ]; actual = gindexOfGreaterThan( 3, 0.0, toAccessorArray( x ), 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; x = [ - 1.0, // 2 + 0.0, // 2 9.0, - 0.0, // 1 + 1.0, // 1 9.0, 0.0 // 0 ]; actual = gindexOfGreaterThan( 3, 0.0, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; x = [ - 1.0, // 2 + 0.0, // 2 9.0, - 0.0, // 1 + 1.0, // 1 9.0, 0.0 // 0 ]; actual = gindexOfGreaterThan( 3, 0.0, toAccessorArray( x ), -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports view offsets', function test( t ) { +tape( 'the function supports complex access patterns', function test( t ) { var actual; - var x0; - var x1; + var x; - // Initial array... - x0 = new Float64Array([ - 9.0, - 1.0, // 2 + x = [ + 0.0, // 0 9.0, 0.0, // 1 9.0, - 0.0 // 0 - ]); + 1.0 // 2 + ]; + + actual = gindexOfGreaterThan( 3, 0.0, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; - // Create offset view... - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + x = [ + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; - actual = gindexOfGreaterThan( 3, 0.0, x1, -2 ); + actual = gindexOfGreaterThan( 3, 0.0, toAccessorArray( x ), 2 ); t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array( [ 9.0, 0.0, 1.0, 0.0, 0.0 ] ); + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = gindexOfGreaterThan( 3, 0.0, x1, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/test/test.ndarray.js index 5e1134753424..bd2a901d8787 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than/test/test.ndarray.js @@ -38,77 +38,55 @@ tape( 'the function has an arity of 5', function test( t ) { t.end(); }); -tape( 'the function returns the first index of an element which is greater than a search element', function test( t ) { +tape( 'the function returns the index of the first element in a strided array which is greater than a provided search element', function test( t ) { var actual; var x; x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... - actual = gindexOfGreaterThan( x.length, 0.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThan( x.length-1, 1.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfGreaterThan( x.length-2, 2.0, x, 1, 2 ); + actual = gindexOfGreaterThan( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfGreaterThan( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfGreaterThan( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThan( 3, 1.0, x, -2, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThan( 3, 2.0, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThan( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns the first index of an element which is greater than a search element (accessors)', function test( t ) { +tape( 'the function returns the index of the first element in a strided array which is greater than a provided search element (accessors)', function test( t ) { var actual; var x; x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... - actual = gindexOfGreaterThan( x.length, 0.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfGreaterThan( x.length, 1.0, x, 1, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfGreaterThan( x.length, 1.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = gindexOfGreaterThan( x.length, 2.0, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if every indexed element in the array is less than or equal to the search element', function test( t ) { + var actual; + var x; + + x = [ 2.0, 2.0, 2.0 ]; - actual = gindexOfGreaterThan( x.length, 3.0, x, 1, 2 ); + actual = gindexOfGreaterThan( x.length, 2.0, x, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = gindexOfGreaterThan( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); +}); - actual = gindexOfGreaterThan( 3, 1.0, x, -2, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function returns `-1` if every indexed element in the array is less than or equal to the search element (accessors)', function test( t ) { + var actual; + var x; - actual = gindexOfGreaterThan( 3, 2.0, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + x = toAccessorArray( [ 2.0, 2.0, 2.0 ] ); - actual = gindexOfGreaterThan( x.length, 3.0, x, -1, x.length-1 ); + actual = gindexOfGreaterThan( x.length, 2.0, x, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gindexOfGreaterThan( 0, 2.0, [ 1.0, 2.0, 3.0 ], 1, 0 ); @@ -120,7 +98,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gindexOfGreaterThan( 0, 2.0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -135,10 +113,10 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; - actual = gindexOfGreaterThan( 1, NaN, [ 0.0 ], 1, 0 ); + actual = gindexOfGreaterThan( 2, NaN, [ 0.0, 1.0 ], 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfGreaterThan( 1, 0.0, [ NaN ], 1, 0 ); + actual = gindexOfGreaterThan( 2, 0.0, [ NaN, NaN ], 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -147,30 +125,36 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', function tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors)', function test( t ) { var actual; - actual = gindexOfGreaterThan( 1, NaN, toAccessorArray( [ 0.0 ] ), 1, 0 ); + actual = gindexOfGreaterThan( 2, NaN, toAccessorArray( [ 0.0, 1.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfGreaterThan( 1, 0.0, toAccessorArray( [ NaN ] ), 1, 0 ); + actual = gindexOfGreaterThan( 2, 0.0, toAccessorArray( [ NaN, NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = gindexOfGreaterThan( 1, -0.0, [ 0.0 ], 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfGreaterThan( 1, 0.0, [ -0.0 ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = gindexOfGreaterThan( 1, -0.0, toAccessorArray( [ 0.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); + actual = gindexOfGreaterThan( 1, 0.0, toAccessorArray( [ -0.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); }); @@ -187,8 +171,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]; actual = gindexOfGreaterThan( 3, 0.0, x, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -205,44 +189,44 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { ]; actual = gindexOfGreaterThan( 3, 0.0, toAccessorArray( x ), 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; x = [ - 1.0, // 2 + 0.0, // 2 9.0, - 0.0, // 1 + 1.0, // 1 9.0, 0.0 // 0 ]; actual = gindexOfGreaterThan( 3, 0.0, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; x = [ - 1.0, // 2 + 0.0, // 2 9.0, - 0.0, // 1 + 1.0, // 1 9.0, 0.0 // 0 ]; actual = gindexOfGreaterThan( 3, 0.0, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -253,13 +237,15 @@ tape( 'the function supports an `x` offset', function test( t ) { x = [ 9.0, 0.0, // 0 + 9.0, 0.0, // 1 + 9.0, 1.0 // 2 ]; - actual = gindexOfGreaterThan( 3, 0.0, x, 1, 1 ); - + actual = gindexOfGreaterThan( 3, 0.0, x, 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -270,13 +256,15 @@ tape( 'the function supports an `x` offset (accessors)', function test( t ) { x = [ 9.0, 0.0, // 0 + 9.0, 0.0, // 1 + 9.0, 1.0 // 2 ]; - actual = gindexOfGreaterThan( 3, 0.0, toAccessorArray( x ), 1, 1 ); - + actual = gindexOfGreaterThan( 3, 0.0, toAccessorArray( x ), 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -285,17 +273,17 @@ tape( 'the function supports complex access patterns', function test( t ) { var x; x = [ + 9.0, 0.0, // 0 9.0, 0.0, // 1 9.0, - 1.0, // 2 - 9.0 + 1.0 // 2 ]; - actual = gindexOfGreaterThan( 3, 0.0, x, 2, 0 ); - + actual = gindexOfGreaterThan( 3, 0.0, x, 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -304,16 +292,16 @@ tape( 'the function supports complex access patterns (accessors)', function test var x; x = [ + 9.0, 0.0, // 0 9.0, 0.0, // 1 9.0, - 1.0, // 2 - 9.0 + 1.0 // 2 ]; - actual = gindexOfGreaterThan( 3, 0.0, toAccessorArray( x ), 2, 0 ); - + actual = gindexOfGreaterThan( 3, 0.0, toAccessorArray( x ), 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); From 8c0fc74eb4577279172da03a6884697bb3d9cb20 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 10:39:58 +0500 Subject: [PATCH 10/68] fix: refactor `index-of-greater-than-equal` --- .../gindex-of-greater-than-equal/README.md | 24 +-- .../docs/repl.txt | 20 +-- .../docs/types/index.d.ts | 12 +- .../docs/types/test.ts | 7 + .../examples/index.js | 4 +- .../lib/accessors.js | 6 +- .../gindex-of-greater-than-equal/lib/index.js | 2 +- .../gindex-of-greater-than-equal/lib/main.js | 6 +- .../lib/ndarray.js | 6 +- .../gindex-of-greater-than-equal/package.json | 2 +- .../test/test.main.js | 167 +++++++++--------- .../test/test.ndarray.js | 142 +++++++-------- 12 files changed, 196 insertions(+), 202 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/README.md index 10684858cc5e..017d6eaf58f3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/README.md @@ -20,7 +20,7 @@ limitations under the License. # gindexOfGreaterThanEqual -> Return the index of the first element in a strided array which is greater than or equal to a specified search element. +> Return the first index of an element in a strided array which is greater than or equal to a specified search element. @@ -42,7 +42,7 @@ var gindexOfGreaterThanEqual = require( '@stdlib/blas/ext/base/gindex-of-greater #### gindexOfGreaterThanEqual( N, searchElement, x, strideX ) -Returns the index of the first element in a strided array which is greater than or equal to a specified search element. +Returns the first index of an element in a strided array which is greater than or equal to a specified search element. ```javascript var x = [ 0.0, 0.0, 1.0, 0.0 ]; @@ -58,7 +58,7 @@ The function has the following parameters: - **x**: input array. - **strideX**: stride length. -If the function is unable to find an element which is greater than or equal to a specified search element, the function returns `-1`. +If the function is unable to find an element which is greater than or equal to the search element, the function returns `-1`. ```javascript var x = [ 0.0, 0.0, 0.0, 0.0 ]; @@ -70,10 +70,10 @@ var idx = gindexOfGreaterThanEqual( x.length, 1.0, x, 1 ); The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to search every other element: ```javascript -var x = [ 0.0, 9.0, 0.0, 9.0, 1.0, 9.0 ]; +var x = [ 0.0, 9.0, 1.0, 9.0, 0.0, 9.0 ]; var idx = gindexOfGreaterThanEqual( 3, 1.0, x, 2 ); -// returns 2 +// returns 1 ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -94,7 +94,7 @@ var idx = gindexOfGreaterThanEqual( 3, 1.0, x1, 2 ); #### gindexOfGreaterThanEqual.ndarray( N, searchElement, x, strideX, offsetX ) -Returns the index of the first element in a strided array which is greater than or equal to a specified search element using alternative indexing semantics. +Returns the first index of an element in a strided array which is greater than or equal to a specified search element using alternative indexing semantics. ```javascript var x = [ 0.0, 0.0, 1.0, 0.0 ]; @@ -110,10 +110,10 @@ The function has the following additional parameters: While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array: ```javascript -var x = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 2.0 ]; +var x = [ 0.0, 0.0, 1.0, 0.0 ]; -var idx = gindexOfGreaterThanEqual.ndarray( 3, 1.0, x, 1, x.length-3 ); -// returns 2 +var idx = gindexOfGreaterThanEqual.ndarray( 3, 1.0, x, 1, 1 ); +// returns 1 ``` @@ -126,7 +126,7 @@ var idx = gindexOfGreaterThanEqual.ndarray( 3, 1.0, x, 1, x.length-3 ); ## Notes -- When comparing elements, the function uses the greater-than-or-equal-to operator `>=`. As a consequence, comparisons involving `NaN` always evaluate to `false`, and `-0` and `+0` are considered the same. +- When comparing elements, the function uses the greater-than-or-equal 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]). @@ -145,12 +145,12 @@ var idx = gindexOfGreaterThanEqual.ndarray( 3, 1.0, x, 1, x.length-3 ); var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var gindexOfGreaterThanEqual = require( '@stdlib/blas/ext/base/gindex-of-greater-than-equal' ); -var x = discreteUniform( 10, -100, 100, { +var x = discreteUniform( 10, 0, 3, { 'dtype': 'generic' }); console.log( x ); -var idx = gindexOfGreaterThanEqual( x.length, 80.0, x, 1 ); +var idx = gindexOfGreaterThanEqual( x.length, 2.0, x, 1 ); console.log( idx ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/repl.txt index 209db001b2df..0b84f3e52da4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( N, searchElement, x, strideX ) - Returns the index of the first element in a strided array which is greater + Returns the first index of an element in a strided array which is greater than or equal to a specified search element. The `N` and stride parameters determine which elements in the strided array @@ -38,19 +38,19 @@ 2 // Using `N` and stride parameters: - > var x = [ 0.0, 9.0, 0.0, 9.0, 1.0, 9.0 ]; + > var x = [ 0.0, 9.0, 1.0, 9.0, 0.0, 9.0 ]; > var idx = {{alias}}( 3, 1.0, x, 2 ) - 2 + 1 - // View offsets: - > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 0.0, 0.0 ] ); + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var idx = {{alias}}( 2, 1.0, x1, 1 ) - 0 + 1 {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) - Returns the index of the first element in a strided array which is greater + Returns the first index of an element in a strided array which is greater than or equal to a specified search element using alternative indexing semantics. @@ -87,10 +87,10 @@ > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) 2 - // Advanced indexing: - > var x = [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0 ]; + // Using an index offset: + > var x = [ 0.0, 0.0, 0.0, 1.0, 0.0, 2.0 ]; > var idx = {{alias}}.ndarray( 3, 1.0, x, 2, 1 ) - 0 + 1 See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/types/index.d.ts index bde637c201a4..e4565444f999 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/types/index.d.ts @@ -32,11 +32,11 @@ type InputArray = Collection | AccessorArrayLike; */ interface Routine { /** - * Returns the index of the first element in a strided array which is greater than or equal to a specified search element. + * Returns the first index of an element in a strided array which is greater than or equal to a specified search element. * * ## Notes * - * - If the function is unable to find an element which is greater than or equal to a search element, the function returns `-1`. + * - If the function is unable to find an element which is greater than or equal to the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element @@ -53,11 +53,11 @@ interface Routine { ( N: number, searchElement: unknown, x: InputArray, strideX: number ): number; /** - * Returns the index of the first element in a strided array which is greater than or equal to a specified search element using alternative indexing semantics. + * Returns the first index of an element in a strided array which is greater than or equal to a specified search element using alternative indexing semantics. * * ## Notes * - * - If the function is unable to find an element which is greater than or equal to a search element, the function returns `-1`. + * - If the function is unable to find an element which is greater than or equal to the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element @@ -76,11 +76,11 @@ interface Routine { } /** -* Returns the index of the first element in a strided array which is greater than or equal to a specified search element. +* Returns the first index of an element in a strided array which is greater than or equal to a specified search element. * * ## Notes * -* - If the function is unable to find an element which is greater than or equal to a search element, the function returns `-1`. +* - If the function is unable to find an element which is greater than or equal to the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/types/test.ts index aa672d89e6e5..6c6e4fde46e2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/docs/types/test.ts @@ -39,6 +39,7 @@ import gindexOfGreaterThanEqual = require( './index' ); gindexOfGreaterThanEqual( false, 2.0, x, 1 ); // $ExpectError gindexOfGreaterThanEqual( null, 2.0, x, 1 ); // $ExpectError gindexOfGreaterThanEqual( {}, 2.0, x, 1 ); // $ExpectError + gindexOfGreaterThanEqual( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a collection... @@ -48,6 +49,7 @@ import gindexOfGreaterThanEqual = require( './index' ); gindexOfGreaterThanEqual( x.length, 1.0, false, 1 ); // $ExpectError gindexOfGreaterThanEqual( x.length, 1.0, null, 1 ); // $ExpectError gindexOfGreaterThanEqual( x.length, 1.0, {}, 1 ); // $ExpectError + gindexOfGreaterThanEqual( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -59,6 +61,7 @@ import gindexOfGreaterThanEqual = require( './index' ); gindexOfGreaterThanEqual( x.length, 2.0, x, false ); // $ExpectError gindexOfGreaterThanEqual( x.length, 2.0, x, null ); // $ExpectError gindexOfGreaterThanEqual( x.length, 2.0, x, {} ); // $ExpectError + gindexOfGreaterThanEqual( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -86,6 +89,7 @@ import gindexOfGreaterThanEqual = require( './index' ); gindexOfGreaterThanEqual.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError gindexOfGreaterThanEqual.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError gindexOfGreaterThanEqual.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + gindexOfGreaterThanEqual.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... @@ -95,6 +99,7 @@ import gindexOfGreaterThanEqual = require( './index' ); gindexOfGreaterThanEqual.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError gindexOfGreaterThanEqual.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError gindexOfGreaterThanEqual.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + gindexOfGreaterThanEqual.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -106,6 +111,7 @@ import gindexOfGreaterThanEqual = require( './index' ); gindexOfGreaterThanEqual.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError gindexOfGreaterThanEqual.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError gindexOfGreaterThanEqual.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + gindexOfGreaterThanEqual.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -117,6 +123,7 @@ import gindexOfGreaterThanEqual = require( './index' ); gindexOfGreaterThanEqual.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError gindexOfGreaterThanEqual.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError gindexOfGreaterThanEqual.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + gindexOfGreaterThanEqual.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/examples/index.js index 9106b1742672..71559fa7c623 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/examples/index.js @@ -21,10 +21,10 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var gindexOfGreaterThanEqual = require( './../lib' ); -var x = discreteUniform( 10, -100, 100, { +var x = discreteUniform( 10, 0, 3, { 'dtype': 'generic' }); console.log( x ); -var idx = gindexOfGreaterThanEqual( x.length, 80.0, x, 1 ); +var idx = gindexOfGreaterThanEqual( x.length, 2.0, x, 1 ); console.log( idx ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/accessors.js index 6550d7547c84..79dd01dd71e7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/accessors.js @@ -21,7 +21,11 @@ // MAIN // /** -* Returns the index of the first element in a strided array which is greater than or equal to a specified search element. +* Returns the first index of an element in a strided array which is greater than or equal to a specified search element. +* +* ## Notes +* +* - If the function is unable to find an element which is greater than or equal to the search element, the function returns `-1`. * * @private * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/index.js index 703eaa69387c..e4be8a04060d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Return the index of the first element in a strided array which is greater than or equal to a specified search element. +* Return the first index of an element in a strided array which is greater than or equal to a specified search element. * * @module @stdlib/blas/ext/base/gindex-of-greater-than-equal * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/main.js index eb7ab725f96b..6370ef4b95e3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/main.js @@ -27,7 +27,11 @@ var ndarray = require( './ndarray.js' ); // MAIN // /** -* Returns the index of the first element in a strided array which is greater than or equal to a specified search element. +* Returns the first index of an element in a strided array which is greater than or equal to a specified search element. +* +* ## Notes +* +* - If the function is unable to find an element which is greater than or equal to the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/ndarray.js index ed601fe851af..b1c73dde125f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/lib/ndarray.js @@ -27,7 +27,11 @@ var accessors = require( './accessors.js' ); // MAIN // /** -* Returns the index of the first element in a strided array which is greater than or equal to a specified search element using alternative indexing semantics. +* Returns the first index of an element in a strided array which is greater than or equal to a specified search element using alternative indexing semantics. +* +* ## Notes +* +* - If the function is unable to find an element which is greater than or equal to the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/package.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/package.json index 009788da288f..e533bdb0d3d0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/ext/base/gindex-of-greater-than-equal", "version": "0.0.0", - "description": "Return the index of the first element in a strided array which is greater than or equal to a specified search element.", + "description": "Return the first index of an element in a strided array which is greater than or equal to a specified search element.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/test/test.main.js index 91ffaeb227e7..a25993cf8913 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/test/test.main.js @@ -39,83 +39,49 @@ tape( 'the function has an arity of 4', function test( t ) { t.end(); }); -tape( 'the function returns the first index of an element which is greater than or equal to a search element', function test( t ) { +tape( 'the function returns the index of the first element in a strided array which is greater than or equal to a provided search element', function test( t ) { var actual; var x; x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... - actual = gindexOfGreaterThanEqual( x.length, 0.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length, 1.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfGreaterThanEqual( x.length, 2.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfGreaterThanEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length, 4.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfGreaterThanEqual( x.length, 0.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length, 4.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns the first index of an element which is greater than or equal to a search element (accessors)', function test( t ) { +tape( 'the function returns the index of the first element in a strided array which is greater than or equal to a provided search element (accessors)', function test( t ) { var actual; var x; x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... - actual = gindexOfGreaterThanEqual( x.length, 0.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length, 1.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfGreaterThanEqual( x.length, 2.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfGreaterThanEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + t.end(); +}); - actual = gindexOfGreaterThanEqual( x.length, 4.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); +tape( 'the function returns `-1` if every indexed element in the array is less than the search element', function test( t ) { + var actual; + var x; - // Negative stride... - actual = gindexOfGreaterThanEqual( x.length, 0.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + x = [ 2.0, 2.0, 2.0 ]; - actual = gindexOfGreaterThanEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfGreaterThanEqual( x.length, 3.0, x, 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfGreaterThanEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); +}); - actual = gindexOfGreaterThanEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function returns `-1` if every indexed element in the array is less than the search element (accessors)', function test( t ) { + var actual; + var x; - actual = gindexOfGreaterThanEqual( x.length, 4.0, x, -1 ); + x = toAccessorArray( [ 2.0, 2.0, 2.0 ] ); + + actual = gindexOfGreaterThanEqual( x.length, 3.0, x, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -148,10 +114,10 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; - actual = gindexOfGreaterThanEqual( 1, NaN, [ 0.0 ], 1 ); + actual = gindexOfGreaterThanEqual( 2, NaN, [ 0.0, 1.0 ], 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfGreaterThanEqual( 1, 0.0, [ NaN ], 1 ); + actual = gindexOfGreaterThanEqual( 2, 0.0, [ NaN, NaN ], 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -160,30 +126,36 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', function tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors)', function test( t ) { var actual; - actual = gindexOfGreaterThanEqual( 1, NaN, toAccessorArray( [ 0.0 ] ), 1 ); + actual = gindexOfGreaterThanEqual( 2, NaN, toAccessorArray( [ 0.0, 1.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfGreaterThanEqual( 1, 0.0, toAccessorArray( [ NaN ] ), 1 ); + actual = gindexOfGreaterThanEqual( 2, 0.0, toAccessorArray( [ NaN, NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = gindexOfGreaterThanEqual( 1, -0.0, [ 0.0 ], 1 ); t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfGreaterThanEqual( 1, 0.0, [ -0.0 ], 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = gindexOfGreaterThanEqual( 1, -0.0, toAccessorArray( [ 0.0 ] ), 1 ); t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfGreaterThanEqual( 1, 0.0, toAccessorArray( [ -0.0 ] ), 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); }); @@ -194,14 +166,14 @@ tape( 'the function supports an `x` stride', function test( t ) { x = [ 0.0, // 0 9.0, - 0.0, // 1 + 1.0, // 1 9.0, - 1.0 // 2 + 0.0 // 2 ]; actual = gindexOfGreaterThanEqual( 3, 1.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -212,72 +184,99 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { x = [ 0.0, // 0 9.0, - 0.0, // 1 + 1.0, // 1 9.0, - 1.0 // 2 + 0.0 // 2 ]; actual = gindexOfGreaterThanEqual( 3, 1.0, toAccessorArray( x ), 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; x = [ - 1.0, // 2 + 0.0, // 2 9.0, - 0.0, // 1 + 1.0, // 1 9.0, 0.0 // 0 ]; actual = gindexOfGreaterThanEqual( 3, 1.0, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; x = [ - 1.0, // 2 + 0.0, // 2 9.0, - 0.0, // 1 + 1.0, // 1 9.0, 0.0 // 0 ]; actual = gindexOfGreaterThanEqual( 3, 1.0, toAccessorArray( x ), -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports view offsets', function test( t ) { +tape( 'the function supports complex access patterns', function test( t ) { var actual; - var x0; - var x1; + var x; - // Initial array... - x0 = new Float64Array([ - 9.0, - 1.0, // 2 + x = [ + 0.0, // 0 9.0, 0.0, // 1 9.0, - 0.0 // 0 - ]); + 1.0 // 2 + ]; + + actual = gindexOfGreaterThanEqual( 3, 1.0, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; - // Create offset view... - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + x = [ + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; - actual = gindexOfGreaterThanEqual( 3, 1.0, x1, -2 ); + actual = gindexOfGreaterThanEqual( 3, 1.0, toAccessorArray( x ), 2 ); t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array( [ 9.0, 0.0, 1.0, 0.0, 0.0 ] ); + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = gindexOfGreaterThanEqual( 3, 1.0, x1, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/test/test.ndarray.js index f7cb4066c910..46a6cbe34c12 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-greater-than-equal/test/test.ndarray.js @@ -38,89 +38,55 @@ tape( 'the function has an arity of 5', function test( t ) { t.end(); }); -tape( 'the function returns the first index of an element which is greater than or equal to a search element', function test( t ) { +tape( 'the function returns the index of the first element in a strided array which is greater than or equal to a provided search element', function test( t ) { var actual; var x; x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... - actual = gindexOfGreaterThanEqual( x.length, 0.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length-1, 1.0, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length-2, 2.0, x, 1, 2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length-2, 3.0, x, 1, 2 ); + actual = gindexOfGreaterThanEqual( x.length, 2.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfGreaterThanEqual( x.length-2, 4.0, x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfGreaterThanEqual( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( 3, 1.0, x, -2, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( 3, 2.0, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns the first index of an element which is greater than or equal to a search element (accessors)', function test( t ) { +tape( 'the function returns the index of the first element in a strided array which is greater than or equal to a provided search element (accessors)', function test( t ) { var actual; var x; x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... - actual = gindexOfGreaterThanEqual( x.length, 0.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfGreaterThanEqual( x.length, 2.0, x, 1, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfGreaterThanEqual( x.length, 1.0, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); +}); - actual = gindexOfGreaterThanEqual( x.length, 2.0, x, 1, 2 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function returns `-1` if every indexed element in the array is less than the search element', function test( t ) { + var actual; + var x; - actual = gindexOfGreaterThanEqual( x.length, 3.0, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + x = [ 2.0, 2.0, 2.0 ]; - actual = gindexOfGreaterThanEqual( x.length, 4.0, x, 1, 2 ); + actual = gindexOfGreaterThanEqual( x.length, 3.0, x, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = gindexOfGreaterThanEqual( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfGreaterThanEqual( 3, 1.0, x, -2, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); +}); - actual = gindexOfGreaterThanEqual( 3, 2.0, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function returns `-1` if every indexed element in the array is less than the search element (accessors)', function test( t ) { + var actual; + var x; - actual = gindexOfGreaterThanEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); + x = toAccessorArray( [ 2.0, 2.0, 2.0 ] ); - actual = gindexOfGreaterThanEqual( x.length, 4.0, x, -1, x.length-1 ); + actual = gindexOfGreaterThanEqual( x.length, 3.0, x, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gindexOfGreaterThanEqual( 0, 2.0, [ 1.0, 2.0, 3.0 ], 1, 0 ); @@ -132,7 +98,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gindexOfGreaterThanEqual( 0, 2.0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -147,10 +113,10 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; - actual = gindexOfGreaterThanEqual( 1, NaN, [ 0.0 ], 1, 0 ); + actual = gindexOfGreaterThanEqual( 2, NaN, [ 0.0, 1.0 ], 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfGreaterThanEqual( 1, 0.0, [ NaN ], 1, 0 ); + actual = gindexOfGreaterThanEqual( 2, 0.0, [ NaN, NaN ], 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -159,30 +125,36 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', function tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors)', function test( t ) { var actual; - actual = gindexOfGreaterThanEqual( 1, NaN, toAccessorArray( [ 0.0 ] ), 1, 0 ); + actual = gindexOfGreaterThanEqual( 2, NaN, toAccessorArray( [ 0.0, 1.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = gindexOfGreaterThanEqual( 1, 0.0, toAccessorArray( [ NaN ] ), 1, 0 ); + actual = gindexOfGreaterThanEqual( 2, 0.0, toAccessorArray( [ NaN, NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = gindexOfGreaterThanEqual( 1, -0.0, [ 0.0 ], 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfGreaterThanEqual( 1, 0.0, [ -0.0 ], 1, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = gindexOfGreaterThanEqual( 1, -0.0, toAccessorArray( [ 0.0 ] ), 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); + actual = gindexOfGreaterThanEqual( 1, 0.0, toAccessorArray( [ -0.0 ] ), 1, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + t.end(); }); @@ -199,8 +171,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]; actual = gindexOfGreaterThanEqual( 3, 1.0, x, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -217,44 +189,44 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { ]; actual = gindexOfGreaterThanEqual( 3, 1.0, toAccessorArray( x ), 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; x = [ - 1.0, // 2 + 0.0, // 2 9.0, - 0.0, // 1 + 1.0, // 1 9.0, 0.0 // 0 ]; actual = gindexOfGreaterThanEqual( 3, 1.0, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; x = [ - 1.0, // 2 + 0.0, // 2 9.0, - 0.0, // 1 + 1.0, // 1 9.0, 0.0 // 0 ]; actual = gindexOfGreaterThanEqual( 3, 1.0, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -265,13 +237,15 @@ tape( 'the function supports an `x` offset', function test( t ) { x = [ 9.0, 0.0, // 0 + 9.0, 0.0, // 1 + 9.0, 1.0 // 2 ]; - actual = gindexOfGreaterThanEqual( 3, 1.0, x, 1, 1 ); - + actual = gindexOfGreaterThanEqual( 3, 1.0, x, 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -282,13 +256,15 @@ tape( 'the function supports an `x` offset (accessors)', function test( t ) { x = [ 9.0, 0.0, // 0 + 9.0, 0.0, // 1 + 9.0, 1.0 // 2 ]; - actual = gindexOfGreaterThanEqual( 3, 1.0, toAccessorArray( x ), 1, 1 ); - + actual = gindexOfGreaterThanEqual( 3, 1.0, toAccessorArray( x ), 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -297,17 +273,17 @@ tape( 'the function supports complex access patterns', function test( t ) { var x; x = [ + 9.0, 0.0, // 0 9.0, 0.0, // 1 9.0, - 1.0, // 2 - 9.0 + 1.0 // 2 ]; - actual = gindexOfGreaterThanEqual( 3, 1.0, x, 2, 0 ); - + actual = gindexOfGreaterThanEqual( 3, 1.0, x, 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -316,16 +292,16 @@ tape( 'the function supports complex access patterns (accessors)', function test var x; x = [ + 9.0, 0.0, // 0 9.0, 0.0, // 1 9.0, - 1.0, // 2 - 9.0 + 1.0 // 2 ]; - actual = gindexOfGreaterThanEqual( 3, 1.0, toAccessorArray( x ), 2, 0 ); - + actual = gindexOfGreaterThanEqual( 3, 1.0, toAccessorArray( x ), 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); From a768d59d34c2edd93c66aa84d6e0ef111c5ab5df Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 10:44:53 +0500 Subject: [PATCH 11/68] fix: refactor `index-of-less-than-equal` --- .../base/gindex-of-less-than-equal/README.md | 2 +- .../gindex-of-less-than-equal/docs/repl.txt | 4 +- .../docs/types/index.d.ts | 6 +- .../docs/types/test.ts | 7 ++ .../lib/accessors.js | 2 +- .../gindex-of-less-than-equal/lib/main.js | 2 +- .../gindex-of-less-than-equal/lib/ndarray.js | 2 +- .../test/test.main.js | 72 +++--------- .../test/test.ndarray.js | 104 ++++++------------ 9 files changed, 68 insertions(+), 133 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/README.md index 2a06e4babf30..39272484fd89 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/README.md @@ -58,7 +58,7 @@ The function has the following parameters: - **x**: input array. - **strideX**: stride length. -If unable to find an element which is less than or equal to the search element, the function returns `-1`. +If the function is unable to find an element which is less than or equal to the search element, the function returns `-1`. ```javascript var x = [ 2.0, 2.0, 2.0, 2.0 ]; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/repl.txt index 1f34aba1cfe7..178f23b03e43 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/repl.txt @@ -42,7 +42,7 @@ > var idx = {{alias}}( 3, 1.0, x, 2 ) 1 - // View offsets: + // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 1.0, 3.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var idx = {{alias}}( 2, 1.0, x1, 1 ) @@ -86,7 +86,7 @@ > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) 2 - // Advanced indexing: + // Using an index offset: > var x = [ 1.0, 2.0, 1.0, 1.0, 1.0, 4.0 ]; > var idx = {{alias}}.ndarray( 3, 1.0, x, 2, 1 ) 1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/types/index.d.ts index 2d72cf47c81d..c8d6412587c1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/types/index.d.ts @@ -36,7 +36,7 @@ interface Routine { * * ## Notes * - * - If unable to find an element which is less than or equal to the search element, the function returns `-1`. + * - If the function is unable to find an element which is less than or equal to the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element @@ -57,7 +57,7 @@ interface Routine { * * ## Notes * - * - If unable to find an element which is less than or equal to the search element, the function returns `-1`. + * - If the function is unable to find an element which is less than or equal to the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element @@ -80,7 +80,7 @@ interface Routine { * * ## Notes * -* - If unable to find an element which is less than or equal to the search element, the function returns `-1`. +* - If the function is unable to find an element which is less than or equal to the search element, the function returns `-1`. * * @param N - number of indexed elements * @param searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/types/test.ts index 4c262985acd8..c9535f26e570 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/docs/types/test.ts @@ -39,6 +39,7 @@ import gindexOfLessThanEqual = require( './index' ); gindexOfLessThanEqual( false, 2.0, x, 1 ); // $ExpectError gindexOfLessThanEqual( null, 2.0, x, 1 ); // $ExpectError gindexOfLessThanEqual( {}, 2.0, x, 1 ); // $ExpectError + gindexOfLessThanEqual( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a collection... @@ -48,6 +49,7 @@ import gindexOfLessThanEqual = require( './index' ); gindexOfLessThanEqual( x.length, 1.0, false, 1 ); // $ExpectError gindexOfLessThanEqual( x.length, 1.0, null, 1 ); // $ExpectError gindexOfLessThanEqual( x.length, 1.0, {}, 1 ); // $ExpectError + gindexOfLessThanEqual( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -59,6 +61,7 @@ import gindexOfLessThanEqual = require( './index' ); gindexOfLessThanEqual( x.length, 2.0, x, false ); // $ExpectError gindexOfLessThanEqual( x.length, 2.0, x, null ); // $ExpectError gindexOfLessThanEqual( x.length, 2.0, x, {} ); // $ExpectError + gindexOfLessThanEqual( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -86,6 +89,7 @@ import gindexOfLessThanEqual = require( './index' ); gindexOfLessThanEqual.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError gindexOfLessThanEqual.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError gindexOfLessThanEqual.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + gindexOfLessThanEqual.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... @@ -95,6 +99,7 @@ import gindexOfLessThanEqual = require( './index' ); gindexOfLessThanEqual.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError gindexOfLessThanEqual.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError gindexOfLessThanEqual.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + gindexOfLessThanEqual.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -106,6 +111,7 @@ import gindexOfLessThanEqual = require( './index' ); gindexOfLessThanEqual.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError gindexOfLessThanEqual.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError gindexOfLessThanEqual.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + gindexOfLessThanEqual.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -117,6 +123,7 @@ import gindexOfLessThanEqual = require( './index' ); gindexOfLessThanEqual.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError gindexOfLessThanEqual.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError gindexOfLessThanEqual.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + gindexOfLessThanEqual.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/accessors.js index cb869301a184..51fa2bf0b1a9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/accessors.js @@ -25,7 +25,7 @@ * * ## Notes * -* - If unable to find an element which is less than or equal to the search element, the function returns `-1`. +* - If the function is unable to find an element which is less than or equal to the search element, the function returns `-1`. * * @private * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/main.js index 21e017d28f09..fc16fe594458 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/main.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find an element which is less than or equal to the search element, the function returns `-1`. +* - If the function is unable to find an element which is less than or equal to the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/ndarray.js index f4586fbd3282..391b1acb800a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/lib/ndarray.js @@ -31,7 +31,7 @@ var accessors = require( './accessors.js' ); * * ## Notes * -* - If unable to find an element which is less than or equal to the search element, the function returns `-1`. +* - If the function is unable to find an element which is less than or equal to the search element, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {*} searchElement - search element diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/test/test.main.js index 734eb0b58762..4857cc8d6a81 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/test/test.main.js @@ -45,33 +45,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ]; - // Nonnegative stride... - actual = gindexOfLessThanEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfLessThanEqual( x.length, 2.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfLessThanEqual( x.length, 1.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 0.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - x = [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - actual = gindexOfLessThanEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 0.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -81,33 +57,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = toAccessorArray( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] ); - // Nonnegative stride... - actual = gindexOfLessThanEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfLessThanEqual( x.length, 2.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfLessThanEqual( x.length, 1.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 0.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - x = toAccessorArray( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = gindexOfLessThanEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 0.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -243,25 +195,37 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = [ 2.0, 2.0, 2.0, 2.0, 1.0, 2.0 ]; + x = [ + 0.0, // 2 + 9.0, + 1.0, // 1 + 9.0, + 2.0 // 0 + ]; - actual = gindexOfLessThanEqual( x.length, 1.0, x, -1 ); + actual = gindexOfLessThanEqual( 3, 1.0, x, -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; - x = [ 2.0, 2.0, 2.0, 2.0, 1.0, 2.0 ]; + x = [ + 0.0, // 2 + 9.0, + 1.0, // 1 + 9.0, + 2.0 // 0 + ]; - actual = gindexOfLessThanEqual( x.length, 1.0, toAccessorArray( x ), -1 ); + actual = gindexOfLessThanEqual( 3, 1.0, toAccessorArray( x ), -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/test/test.ndarray.js index de0a3b1841e6..4c1f8f95bf27 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-less-than-equal/test/test.ndarray.js @@ -44,33 +44,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ]; - // Nonnegative stride... - actual = gindexOfLessThanEqual( x.length, 3.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfLessThanEqual( x.length, 2.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfLessThanEqual( x.length, 1.0, x, 1, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 0.0, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - x = [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - actual = gindexOfLessThanEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -80,33 +56,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = toAccessorArray( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] ); - // Nonnegative stride... - actual = gindexOfLessThanEqual( x.length, 3.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfLessThanEqual( x.length, 2.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfLessThanEqual( x.length, 1.0, x, 1, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 0.0, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - x = toAccessorArray( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = gindexOfLessThanEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfLessThanEqual( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -242,64 +194,76 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; x = [ + 0.0, // 2 9.0, - 2.0, // 0 - 9.0, - 2.0, // 1 + 1.0, // 1 9.0, - 1.0 // 2 + 2.0 // 0 ]; - actual = gindexOfLessThanEqual( 3, 1.0, x, 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = gindexOfLessThanEqual( 3, 1.0, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an `x` offset (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; x = [ + 0.0, // 2 9.0, - 2.0, // 0 - 9.0, - 2.0, // 1 + 1.0, // 1 9.0, - 1.0 // 2 + 2.0 // 0 ]; - actual = gindexOfLessThanEqual( 3, 1.0, toAccessorArray( x ), 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = gindexOfLessThanEqual( 3, 1.0, toAccessorArray( x ), -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; var x; - x = [ 2.0, 2.0, 2.0, 2.0, 1.0, 2.0 ]; + x = [ + 9.0, + 2.0, // 0 + 9.0, + 2.0, // 1 + 9.0, + 1.0 // 2 + ]; - actual = gindexOfLessThanEqual( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gindexOfLessThanEqual( 3, 1.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports an `x` offset (accessors)', function test( t ) { var actual; var x; - x = [ 2.0, 2.0, 2.0, 2.0, 1.0, 2.0 ]; + x = [ + 9.0, + 2.0, // 0 + 9.0, + 2.0, // 1 + 9.0, + 1.0 // 2 + ]; - actual = gindexOfLessThanEqual( x.length, 1.0, toAccessorArray( x ), -1, x.length-1 ); // eslint-disable-line max-len - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gindexOfLessThanEqual( 3, 1.0, toAccessorArray( x ), 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); From e1eb4c8cbb43f6c68e5f1568ba110d29a33dbad1 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 10:55:38 +0500 Subject: [PATCH 12/68] fix: refactor `index-of-same-value` --- .../ext/base/gindex-of-same-value/README.md | 6 +- .../base/gindex-of-same-value/docs/repl.txt | 10 +- .../docs/types/index.d.ts | 6 +- .../gindex-of-same-value/docs/types/test.ts | 7 + .../gindex-of-same-value/lib/accessors.js | 2 +- .../base/gindex-of-same-value/lib/index.js | 2 +- .../ext/base/gindex-of-same-value/lib/main.js | 2 +- .../base/gindex-of-same-value/lib/ndarray.js | 2 +- .../base/gindex-of-same-value/package.json | 2 +- .../gindex-of-same-value/test/test.main.js | 81 ++++-------- .../gindex-of-same-value/test/test.ndarray.js | 123 +++++++----------- 11 files changed, 91 insertions(+), 152 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/README.md index 845fa63a226a..64c89b690774 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/README.md @@ -20,7 +20,7 @@ limitations under the License. # gindexOfSameValue -> Return the index of the first element in a strided array which has the same value as a provided search element. +> Return the first index of an element in a strided array which has the same value as a specified search element. @@ -42,7 +42,7 @@ var gindexOfSameValue = require( '@stdlib/blas/ext/base/gindex-of-same-value' ); #### gindexOfSameValue( N, searchElement, x, strideX ) -Returns the index of the first element in a strided array which has the same value as a provided search element. +Returns the first index of an element in a strided array which has the same value as a specified search element. ```javascript var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, 3.0 ]; @@ -94,7 +94,7 @@ var idx = gindexOfSameValue( 3, -6.0, x1, 2 ); #### gindexOfSameValue.ndarray( N, searchElement, x, strideX, offsetX ) -Returns the index of the first element in a strided array which has the same value as a provided search element using alternative indexing semantics. +Returns the first index of an element in a strided array which has the same value as a specified search element using alternative indexing semantics. ```javascript var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, 3.0 ]; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/repl.txt index 5de6c917b347..12798dd48fe7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( N, searchElement, x, strideX ) - Returns the index of the first element in a strided array which has the same - value as a provided search element. + Returns the first index of an element in a strided array which has the same + value as a specified search element. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. @@ -50,8 +50,8 @@ {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) - Returns the index of the first element in a strided array which has the same - value as a provided search element using alternative indexing semantics. + Returns the first index of an element in a strided array which has the same + value as a specified search element using alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting @@ -86,7 +86,7 @@ > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) 1 - // Advanced indexing: + // Using an index offset: > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; > var idx = {{alias}}.ndarray( 3, -1.0, x, 2, 1 ) 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/types/index.d.ts index bd82c8151ece..b0b0191e701c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/types/index.d.ts @@ -32,7 +32,7 @@ type InputArray = Collection | AccessorArrayLike; */ interface Routine { /** - * Returns the index of the first element in a strided array which has the same value as a provided search element. + * Returns the first index of an element in a strided array which has the same value as a specified search element. * * ## Notes * @@ -53,7 +53,7 @@ interface Routine { ( N: number, searchElement: unknown, x: InputArray, strideX: number ): number; /** - * Returns the index of the first element in a strided array which has the same value as a provided search element using alternative indexing semantics. + * Returns the first index of an element in a strided array which has the same value as a specified search element using alternative indexing semantics. * * ## Notes * @@ -76,7 +76,7 @@ interface Routine { } /** -* Returns the index of the first element in a strided array which has the same value as a provided search element. +* Returns the first index of an element in a strided array which has the same value as a specified search element. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/types/test.ts index 45303172e20f..b5b75176d2bd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/types/test.ts @@ -39,6 +39,7 @@ import gindexOfSameValue = require( './index' ); gindexOfSameValue( false, 2.0, x, 1 ); // $ExpectError gindexOfSameValue( null, 2.0, x, 1 ); // $ExpectError gindexOfSameValue( {}, 2.0, x, 1 ); // $ExpectError + gindexOfSameValue( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a collection... @@ -48,6 +49,7 @@ import gindexOfSameValue = require( './index' ); gindexOfSameValue( x.length, 1.0, false, 1 ); // $ExpectError gindexOfSameValue( x.length, 1.0, null, 1 ); // $ExpectError gindexOfSameValue( x.length, 1.0, {}, 1 ); // $ExpectError + gindexOfSameValue( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -59,6 +61,7 @@ import gindexOfSameValue = require( './index' ); gindexOfSameValue( x.length, 2.0, x, false ); // $ExpectError gindexOfSameValue( x.length, 2.0, x, null ); // $ExpectError gindexOfSameValue( x.length, 2.0, x, {} ); // $ExpectError + gindexOfSameValue( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -86,6 +89,7 @@ import gindexOfSameValue = require( './index' ); gindexOfSameValue.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError gindexOfSameValue.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError gindexOfSameValue.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + gindexOfSameValue.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... @@ -95,6 +99,7 @@ import gindexOfSameValue = require( './index' ); gindexOfSameValue.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError gindexOfSameValue.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError gindexOfSameValue.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + gindexOfSameValue.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -106,6 +111,7 @@ import gindexOfSameValue = require( './index' ); gindexOfSameValue.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError gindexOfSameValue.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError gindexOfSameValue.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + gindexOfSameValue.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -117,6 +123,7 @@ import gindexOfSameValue = require( './index' ); gindexOfSameValue.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError gindexOfSameValue.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError gindexOfSameValue.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + gindexOfSameValue.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/accessors.js index 67aec8c59246..1065bdcb6c2a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/accessors.js @@ -26,7 +26,7 @@ var isSameValue = require( '@stdlib/assert/is-same-value' ); // MAIN // /** -* Returns the index of the first element in a strided array which has the same value as a provided search element. +* Returns the first index of an element in a strided array which has the same value as a specified search element. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/index.js index c33ba5acd785..70da907560db 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Return the index of the first element in a strided array which has the same value as a provided search element. +* Return the first index of an element in a strided array which has the same value as a specified search element. * * @module @stdlib/blas/ext/base/gindex-of-same-value * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/main.js index 3152e658afef..3f82cde8da20 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/main.js @@ -27,7 +27,7 @@ var ndarray = require( './ndarray.js' ); // MAIN // /** -* Returns the index of the first element in a strided array which has the same value as a provided search element. +* Returns the first index of an element in a strided array which has the same value as a specified search element. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/ndarray.js index 498194cb040c..cda635344004 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/lib/ndarray.js @@ -28,7 +28,7 @@ var accessors = require( './accessors.js' ); // MAIN // /** -* Returns the index of the first element in a strided array which has the same value as a provided search element using alternative indexing semantics. +* Returns the first index of an element in a strided array which has the same value as a specified search element using alternative indexing semantics. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/package.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/package.json index 1e2b154954bd..862e68544600 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/ext/base/gindex-of-same-value", "version": "0.0.0", - "description": "Return the index of the first element in a strided array which has the same value as a provided search element.", + "description": "Return the first index of an element in a strided array which has the same value as a specified search element.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/test/test.main.js index be9e03d4951a..fc3274ec7406 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/test/test.main.js @@ -45,32 +45,9 @@ tape( 'the function returns the first index of an element which has the same val x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... - actual = gindexOfSameValue( x.length, 1.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfSameValue( x.length, 2.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfSameValue( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfSameValue( x.length, 4.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfSameValue( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfSameValue( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfSameValue( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfSameValue( x.length, 4.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -80,32 +57,9 @@ tape( 'the function returns the first index of an element which has the same val x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... - actual = gindexOfSameValue( x.length, 1.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfSameValue( x.length, 2.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfSameValue( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfSameValue( x.length, 4.0, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfSameValue( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfSameValue( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfSameValue( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfSameValue( x.length, 4.0, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -151,7 +105,7 @@ tape( 'the function returns the first index when searching for `NaN` (accessors) t.end(); }); -tape( 'the function distinguishes between -0 and +0', function test( t ) { +tape( 'the function distinguishes between `-0` and `+0`', function test( t ) { var actual; actual = gindexOfSameValue( 1, 0.0, [ -0.0 ], 1 ); @@ -169,7 +123,7 @@ tape( 'the function distinguishes between -0 and +0', function test( t ) { t.end(); }); -tape( 'the function distinguishes between -0 and +0 (accessors)', function test( t ) { +tape( 'the function distinguishes between `-0` and `+0` (accessors)', function test( t ) { var actual; actual = gindexOfSameValue( 1, 0.0, toAccessorArray( [ -0.0 ] ), 1 ); @@ -223,7 +177,7 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; @@ -241,7 +195,7 @@ tape( 'the function supports negative strides', function test( t ) { t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; @@ -278,23 +232,32 @@ tape( 'the function supports complex access patterns', function test( t ) { t.end(); }); -tape( 'the function supports view offsets', function test( t ) { +tape( 'the function supports complex access patterns (accessors)', function test( t ) { var actual; - var x0; - var x1; + var x; - // Initial array... - x0 = new Float64Array([ - 1.0, - 2.0, // 0 + x = toAccessorArray([ + 1.0, // 0 + 2.0, 3.0, // 1 4.0, 5.0, // 2 6.0 ]); - // Create offset view... - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + actual = gindexOfSameValue( 3, 3.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); actual = gindexOfSameValue( 3, 4.0, x1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/test/test.ndarray.js index 0a9db7c83df4..7d82811e028f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/test/test.ndarray.js @@ -44,32 +44,9 @@ tape( 'the function returns the first index of an element which has the same val x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... - actual = gindexOfSameValue( x.length, 1.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfSameValue( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfSameValue( x.length-2, 3.0, x, 1, 2 ); + actual = gindexOfSameValue( x.length, 2.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfSameValue( x.length-2, 4.0, x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfSameValue( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfSameValue( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfSameValue( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfSameValue( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -79,32 +56,9 @@ tape( 'the function returns the first index of an element which has the same val x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... - actual = gindexOfSameValue( x.length, 1.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfSameValue( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfSameValue( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfSameValue( x.length-2, 4.0, x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfSameValue( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfSameValue( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfSameValue( 3, 1.0, x, -2, x.length-2 ); + actual = gindexOfSameValue( x.length, 2.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfSameValue( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -153,7 +107,7 @@ tape( 'the function returns the first index when searching for `NaN` (accessors) t.end(); }); -tape( 'the function distinguishes between -0 and +0', function test( t ) { +tape( 'the function distinguishes between `-0` and `+0`', function test( t ) { var actual; actual = gindexOfSameValue( 1, 0.0, [ -0.0 ], 1, 0 ); @@ -171,7 +125,7 @@ tape( 'the function distinguishes between -0 and +0', function test( t ) { t.end(); }); -tape( 'the function distinguishes between -0 and +0 (accessors)', function test( t ) { +tape( 'the function distinguishes between `-0` and `+0` (accessors)', function test( t ) { var actual; actual = gindexOfSameValue( 1, 0.0, toAccessorArray( [ -0.0 ] ), 1, 0 ); @@ -225,7 +179,7 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; @@ -243,7 +197,7 @@ tape( 'the function supports negative strides', function test( t ) { t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; @@ -266,17 +220,15 @@ tape( 'the function supports an `x` offset', function test( t ) { var x; x = [ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0 // 3 + 6.0, + 1.0, // 0 + 6.0, + 2.0, // 1 + 6.0, + 3.0 // 2 ]; - actual = gindexOfSameValue( 4, 2.0, x, 2, 1 ); + actual = gindexOfSameValue( 3, 3.0, x, 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); @@ -287,17 +239,15 @@ tape( 'the function supports an `x` offset (accessors)', function test( t ) { var x; x = toAccessorArray([ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0 // 3 + 6.0, + 1.0, // 0 + 6.0, + 2.0, // 1 + 6.0, + 3.0 // 2 ]); - actual = gindexOfSameValue( 4, 2.0, x, 2, 1 ); + actual = gindexOfSameValue( 3, 3.0, x, 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); @@ -308,16 +258,35 @@ tape( 'the function supports complex access patterns', function test( t ) { var x; x = [ + 6.0, 1.0, // 0 - 2.0, - 3.0, // 1 - 4.0, - 5.0, // 2 - 6.0 + 6.0, + 2.0, // 1 + 6.0, + 3.0 // 2 ]; - actual = gindexOfSameValue( 3, 3.0, x, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gindexOfSameValue( 3, 3.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray([ + 6.0, + 1.0, // 0 + 6.0, + 2.0, // 1 + 6.0, + 3.0 // 2 + ]); + + actual = gindexOfSameValue( 3, 3.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); From 446ae2a6e99e86507561009057a6c215179f4af5 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 11:03:55 +0500 Subject: [PATCH 13/68] fix: refactor `index-of-almost-same-value` --- .../gindex-of-almost-same-value/README.md | 8 +- .../gindex-of-almost-same-value/docs/repl.txt | 20 +-- .../docs/types/index.d.ts | 6 +- .../lib/accessors.js | 2 +- .../gindex-of-almost-same-value/lib/index.js | 2 +- .../gindex-of-almost-same-value/lib/main.js | 2 +- .../lib/ndarray.js | 2 +- .../gindex-of-almost-same-value/package.json | 2 +- .../test/test.main.js | 87 ++++--------- .../test/test.ndarray.js | 123 +++++++----------- 10 files changed, 93 insertions(+), 161 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/README.md index 6f6600a320cc..808303ce301f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/README.md @@ -20,7 +20,7 @@ limitations under the License. # gindexOfAlmostSameValue -> Return the index of the first element in a strided array which is almost the same value as a provided search element. +> Return the first index of an element in a strided array which is almost the same value as a specified search element. @@ -42,7 +42,7 @@ var gindexOfAlmostSameValue = require( '@stdlib/blas/ext/base/gindex-of-almost-s #### gindexOfAlmostSameValue( N, searchElement, maxULP, x, strideX ) -Returns the index of the first element in a strided array which is almost the same value as a provided search element. +Returns the first index of an element in a strided array which is almost the same value as a specified search element. ```javascript var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, 3.0 ]; @@ -99,7 +99,7 @@ var idx = gindexOfAlmostSameValue( 3, -6.0, 1, x1, 2 ); -Returns the index of the first element in a strided array which is almost the same value as a provided search element using alternative indexing semantics. +Returns the first index of an element in a strided array which is almost the same value as a specified search element using alternative indexing semantics. ```javascript var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, 3.0 ]; @@ -131,7 +131,7 @@ var idx = gindexOfAlmostSameValue.ndarray( 3, 3.0, 1, x, 1, x.length-3 ); ## Notes -- When searching for a search element, the functions test whether elements are approximately the same value within a specified number of ULPs (units in the last place). In contrast to the strict equality operator `===`, the functions distinguish between `+0` and `-0` and treats `NaNs` as the same value. +- When searching for a search element, the functions test whether elements are approximately the same value within a specified number of ULPs (units in the last place). In contrast to the strict equality operator `===`, the functions distinguish between `+0` and `-0` and treat `NaN` values as the same value. - 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-almost-same-value/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/docs/repl.txt index 196a87143140..d4f12bdcd987 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( N, searchElement, maxULP, x, strideX ) - Returns the index of the first element in a strided array which is almost - the same value as a provided search element. + Returns the first index of an element in a strided array which is almost the + same value as a specified search element. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. @@ -41,20 +41,20 @@ 1 // Using `N` and stride parameters: - > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; + > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; > var idx = {{alias}}( 3, 4.0, 1, x, 2 ) 2 // Using view offsets: - > var x0 = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > var idx = {{alias}}( 3, -1.0, 1, x1, 2 ) - 2 + > var idx = {{alias}}( 2, 3.0, 1, x1, 1 ) + 1 {{alias}}.ndarray( N, searchElement, maxULP, x, strideX, offsetX ) - Returns the index of the first element in a strided array which is almost - the same value as a provided search element using alternative indexing + Returns the first index of an element in a strided array which is almost the + same value as a specified search element using alternative indexing semantics. While typed array views mandate a view offset based on the underlying @@ -93,8 +93,8 @@ > var idx = {{alias}}.ndarray( x.length, 1.0, 1, x, 1, 0 ) 1 - // Advanced indexing: - > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; + // Using an index offset: + > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; > var idx = {{alias}}.ndarray( 3, -1.0, 1, x, 2, 1 ) 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/docs/types/index.d.ts index f0b524f14744..1a86c70c3eb9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/docs/types/index.d.ts @@ -32,7 +32,7 @@ type InputArray = Collection | AccessorArrayLike; */ interface Routine { /** - * Returns the index of the first element in a strided array which is almost the same value as a provided search element. + * Returns the first index of an element in a strided array which is almost the same value as a specified search element. * * ## Notes * @@ -54,7 +54,7 @@ interface Routine { ( N: number, searchElement: unknown, maxULP: number, x: InputArray, strideX: number ): number; /** - * Returns the index of the first element in a strided array which is almost the same value as a provided search element using alternative indexing semantics. + * Returns the first index of an element in a strided array which is almost the same value as a specified search element using alternative indexing semantics. * * ## Notes * @@ -78,7 +78,7 @@ interface Routine { } /** -* Returns the index of the first element in a strided array which is almost the same value as a provided search element. +* Returns the first index of an element in a strided array which is almost the same value as a specified search element. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/accessors.js index 41d2144cc99f..38f5c2c51de0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/accessors.js @@ -26,7 +26,7 @@ var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); // MAIN // /** -* Returns the index of the first element in a strided array which is almost the same value as a provided search element. +* Returns the first index of an element in a strided array which is almost the same value as a specified search element. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/index.js index 1fe0aafd3713..6351dc38fea8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Return the index of the first element in a strided array which is almost the same value as a provided search element. +* Return the first index of an element in a strided array which is almost the same value as a specified search element. * * @module @stdlib/blas/ext/base/gindex-of-almost-same-value * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/main.js index a740100b3169..51a248c839fe 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/main.js @@ -27,7 +27,7 @@ var ndarray = require( './ndarray.js' ); // MAIN // /** -* Returns the index of the first element in a strided array which is almost the same value as a provided search element. +* Returns the first index of an element in a strided array which is almost the same value as a specified search element. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/ndarray.js index e93b0b9c612e..04acee8d234f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/lib/ndarray.js @@ -28,7 +28,7 @@ var accessors = require( './accessors.js' ); // MAIN // /** -* Returns the index of the first element in a strided array which is almost the same value as a provided search element using alternative indexing semantics. +* Returns the first index of an element in a strided array which is almost the same value as a specified search element using alternative indexing semantics. * * ## Notes * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/package.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/package.json index de729bbff848..59bae4c7900f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/ext/base/gindex-of-almost-same-value", "version": "0.0.0", - "description": "Return the index of the first element in a strided array which is almost the same value as a provided search element.", + "description": "Return the first index of an element in a strided array which is almost the same value as a specified search element.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/test/test.main.js index eb1ff8051579..5d76d4444913 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/test/test.main.js @@ -46,32 +46,9 @@ tape( 'the function returns the first index of an element which is almost the sa x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... - actual = gindexOfAlmostSameValue( x.length, 1.0, 1, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfAlmostSameValue( x.length, 2.0, 1, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfAlmostSameValue( x.length, 3.0, 1, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length, 4.0, 1, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfAlmostSameValue( x.length, 1.0, 1, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length, 2.0, 1, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length, 3.0, 1, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length, 4.0, 1, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -81,32 +58,9 @@ tape( 'the function returns the first index of an element which is almost the sa x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... - actual = gindexOfAlmostSameValue( x.length, 1.0, 1, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - actual = gindexOfAlmostSameValue( x.length, 2.0, 1, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfAlmostSameValue( x.length, 3.0, 1, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length, 4.0, 1, x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfAlmostSameValue( x.length, 1.0, 1, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length, 2.0, 1, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length, 3.0, 1, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length, 4.0, 1, x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -200,7 +154,7 @@ tape( 'the function treats `NaN` values as the same (accessors)', function test( t.end(); }); -tape( 'the function treats -0 and +0 as distinct', function test( t ) { +tape( 'the function treats `-0` and `+0` as distinct', function test( t ) { var actual; actual = gindexOfAlmostSameValue( 1, 0.0, 0, [ -0.0 ], 1 ); @@ -209,7 +163,7 @@ tape( 'the function treats -0 and +0 as distinct', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as distinct (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as distinct (accessors)', function test( t ) { var actual; actual = gindexOfAlmostSameValue( 1, 0.0, 0, toAccessorArray( [ -0.0 ] ), 1 ); @@ -254,7 +208,7 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; @@ -272,7 +226,7 @@ tape( 'the function supports negative strides', function test( t ) { t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; @@ -309,23 +263,32 @@ tape( 'the function supports complex access patterns', function test( t ) { t.end(); }); +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]); + + actual = gindexOfAlmostSameValue( 3, 3.0, 1, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var actual; var x0; var x1; - // Initial array... - x0 = new Float64Array([ - 1.0, - 2.0, // 0 - 3.0, - 4.0, // 1 - 5.0, - 6.0 // 2 - ]); - - // Create offset view... - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); actual = gindexOfAlmostSameValue( 3, 4.0, 1, x1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/test/test.ndarray.js index ebf646700015..cb3f8b4b6a79 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-almost-same-value/test/test.ndarray.js @@ -45,32 +45,9 @@ tape( 'the function returns the first index of an element which is almost the sa x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; - // Nonnegative stride... - actual = gindexOfAlmostSameValue( x.length, 1.0, 1, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length-1, 2.0, 1, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length-2, 3.0, 1, x, 1, 2 ); + actual = gindexOfAlmostSameValue( x.length, 2.0, 1, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfAlmostSameValue( x.length-2, 4.0, 1, x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfAlmostSameValue( x.length, 1.0, 1, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( 3, 2.0, 1, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( 3, 1.0, 1, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length, 4.0, 1, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -80,32 +57,9 @@ tape( 'the function returns the first index of an element which is almost the sa x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... - actual = gindexOfAlmostSameValue( x.length, 1.0, 1, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length-1, 2.0, 1, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length-2, 3.0, 1, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( x.length-2, 4.0, 1, x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = gindexOfAlmostSameValue( x.length, 1.0, 1, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( 3, 2.0, 1, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = gindexOfAlmostSameValue( 3, 1.0, 1, x, -2, x.length-2 ); + actual = gindexOfAlmostSameValue( x.length, 2.0, 1, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = gindexOfAlmostSameValue( x.length, 4.0, 1, x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -202,7 +156,7 @@ tape( 'the function treats `NaN` values as the same (accessors)', function test( t.end(); }); -tape( 'the function treats -0 and +0 as distinct', function test( t ) { +tape( 'the function treats `-0` and `+0` as distinct', function test( t ) { var actual; actual = gindexOfAlmostSameValue( 1, 0.0, 0, [ -0.0 ], 1, 0 ); @@ -211,7 +165,7 @@ tape( 'the function treats -0 and +0 as distinct', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as distinct (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as distinct (accessors)', function test( t ) { var actual; actual = gindexOfAlmostSameValue( 1, 0.0, 0, toAccessorArray( [ -0.0 ] ), 1, 0 ); @@ -256,7 +210,7 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; @@ -274,7 +228,7 @@ tape( 'the function supports negative strides', function test( t ) { t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { var actual; var x; @@ -297,17 +251,15 @@ tape( 'the function supports an `x` offset', function test( t ) { var x; x = [ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0 // 3 + 6.0, + 1.0, // 0 + 6.0, + 2.0, // 1 + 6.0, + 3.0 // 2 ]; - actual = gindexOfAlmostSameValue( 4, 2.0, 1, x, 2, 1 ); + actual = gindexOfAlmostSameValue( 3, 3.0, 1, x, 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); @@ -318,17 +270,15 @@ tape( 'the function supports an `x` offset (accessors)', function test( t ) { var x; x = toAccessorArray([ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0 // 3 + 6.0, + 1.0, // 0 + 6.0, + 2.0, // 1 + 6.0, + 3.0 // 2 ]); - actual = gindexOfAlmostSameValue( 4, 2.0, 1, x, 2, 1 ); + actual = gindexOfAlmostSameValue( 3, 3.0, 1, x, 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); @@ -339,16 +289,35 @@ tape( 'the function supports complex access patterns', function test( t ) { var x; x = [ + 6.0, 1.0, // 0 - 2.0, - 3.0, // 1 - 4.0, - 5.0, // 2 - 6.0 + 6.0, + 2.0, // 1 + 6.0, + 3.0 // 2 ]; - actual = gindexOfAlmostSameValue( 3, 3.0, 1, x, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gindexOfAlmostSameValue( 3, 3.0, 1, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray([ + 6.0, + 1.0, // 0 + 6.0, + 2.0, // 1 + 6.0, + 3.0 // 2 + ]); + + actual = gindexOfAlmostSameValue( 3, 3.0, 1, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); From c28ed5193d5570a7dc0d726c94296dddaa748ebd Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 11:03:56 +0500 Subject: [PATCH 14/68] docs: fix REPL examples in `gindex-of-same-value` --- .../blas/ext/base/gindex-of-same-value/docs/repl.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/repl.txt index 12798dd48fe7..d55c6aad9515 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-same-value/docs/repl.txt @@ -38,15 +38,15 @@ 1 // Using `N` and stride parameters: - > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; + > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; > var idx = {{alias}}( 3, 4.0, x, 2 ) 2 // Using view offsets: - > var x0 = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > var idx = {{alias}}( 3, -1.0, x1, 2 ) - 2 + > var idx = {{alias}}( 2, 3.0, x1, 1 ) + 1 {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) @@ -87,7 +87,7 @@ 1 // Using an index offset: - > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; + > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; > var idx = {{alias}}.ndarray( 3, -1.0, x, 2, 1 ) 2 From 7a7bb7c686a50302e83d3dd2f0cd53410ae49280 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 11:37:48 +0500 Subject: [PATCH 15/68] fix: refactor `index-of-row` --- .../blas/ext/base/cindex-of-row/README.md | 20 +++++++++---------- .../blas/ext/base/cindex-of-row/docs/repl.txt | 8 ++++---- .../base/cindex-of-row/docs/types/index.d.ts | 8 ++++---- .../base/cindex-of-row/lib/cindex_of_row.js | 2 +- .../cindex-of-row/lib/cindex_of_row.native.js | 2 +- .../ext/base/cindex-of-row/lib/ndarray.js | 4 ++-- .../base/cindex-of-row/lib/ndarray.native.js | 4 ++-- .../blas/ext/base/cindex-of-row/src/main.c | 6 +++--- .../blas/ext/base/dindex-of-row/README.md | 20 +++++++++---------- .../blas/ext/base/dindex-of-row/docs/repl.txt | 8 ++++---- .../base/dindex-of-row/docs/types/index.d.ts | 8 ++++---- .../base/dindex-of-row/lib/dindex_of_row.js | 2 +- .../dindex-of-row/lib/dindex_of_row.native.js | 2 +- .../ext/base/dindex-of-row/lib/ndarray.js | 4 ++-- .../base/dindex-of-row/lib/ndarray.native.js | 4 ++-- .../blas/ext/base/dindex-of-row/src/main.c | 6 +++--- .../blas/ext/base/gindex-of-row/README.md | 10 +++++----- .../blas/ext/base/gindex-of-row/docs/repl.txt | 8 ++++---- .../base/gindex-of-row/docs/types/index.d.ts | 8 ++++---- .../ext/base/gindex-of-row/lib/accessors.js | 4 ++-- .../blas/ext/base/gindex-of-row/lib/base.js | 4 ++-- .../blas/ext/base/gindex-of-row/lib/main.js | 2 +- .../ext/base/gindex-of-row/lib/ndarray.js | 4 ++-- .../blas/ext/base/sindex-of-row/README.md | 20 +++++++++---------- .../blas/ext/base/sindex-of-row/docs/repl.txt | 8 ++++---- .../base/sindex-of-row/docs/types/index.d.ts | 8 ++++---- .../ext/base/sindex-of-row/lib/ndarray.js | 4 ++-- .../base/sindex-of-row/lib/ndarray.native.js | 4 ++-- .../base/sindex-of-row/lib/sindex_of_row.js | 2 +- .../sindex-of-row/lib/sindex_of_row.native.js | 2 +- .../blas/ext/base/sindex-of-row/src/main.c | 6 +++--- .../blas/ext/base/zindex-of-row/README.md | 20 +++++++++---------- .../blas/ext/base/zindex-of-row/docs/repl.txt | 8 ++++---- .../ext/base/zindex-of-row/docs/types/test.ts | 1 + .../ext/base/zindex-of-row/lib/ndarray.js | 4 ++-- .../base/zindex-of-row/lib/ndarray.native.js | 4 ++-- .../base/zindex-of-row/lib/zindex_of_row.js | 2 +- .../zindex-of-row/lib/zindex_of_row.native.js | 2 +- .../blas/ext/base/zindex-of-row/src/main.c | 6 +++--- 39 files changed, 125 insertions(+), 124 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/README.md index 459e19506a2d..7e091edc0ea5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/README.md @@ -68,11 +68,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Complex64Array`][@stdlib/array/complex64]. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: search vector stored as a [`Complex64Array`][@stdlib/array/complex64]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -166,14 +166,14 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Complex64Array`][@stdlib/array/complex64]. -- **strideA1**: stride of the first dimension of `A`. -- **strideA2**: stride of the second dimension of `A`. +- **strideA1**: stride length for the first dimension of `A`. +- **strideA2**: stride length for the second dimension of `A`. - **offsetA**: starting index for `A`. - **x**: search vector stored as a [`Complex64Array`][@stdlib/array/complex64]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. - **offsetW**: starting index for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -302,7 +302,7 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] stdlib_complex64_t*` input matrix. -- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: `[in] CBLAS_INT` stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **X**: `[in] stdlib_complex64_t*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **workspace**: `[inout] uint8_t*` workspace array for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. @@ -350,8 +350,8 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] stdlib_complex64_t*` input matrix. -- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. -- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **strideA1**: `[in] CBLAS_INT` stride length for the first dimension of `A`. +- **strideA2**: `[in] CBLAS_INT` stride length for the second dimension of `A`. - **offsetA**: `[in] CBLAS_INT` index offset for `A`. - **X**: `[in] stdlib_complex64_t*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/docs/repl.txt index 15c9e6f2e275..5149ecd62b23 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/docs/repl.txt @@ -25,8 +25,8 @@ Input matrix `A`. LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + Stride length for the first dimension of `A` (a.k.a., leading dimension + of the matrix `A`). x: Complex64Array Search vector. @@ -79,10 +79,10 @@ Input matrix `A`. sa1: integer - Stride of the first dimension of `A`. + Stride length for the first dimension of `A`. sa2: integer - Stride of the second dimension of `A`. + Stride length for the second dimension of `A`. oa: integer Starting index for `A`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/docs/types/index.d.ts index 6708680594ce..c192bd14a8db 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/docs/types/index.d.ts @@ -39,7 +39,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking row match candidates @@ -70,8 +70,8 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param strideA1 - stride of the first dimension of `A` - * @param strideA2 - stride of the second dimension of `A` + * @param strideA1 - stride length for the first dimension of `A` + * @param strideA2 - stride length for the second dimension of `A` * @param offsetA - starting index for `A` * @param x - search vector * @param strideX - stride length for `x` @@ -107,7 +107,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix -* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/cindex_of_row.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/cindex_of_row.js index 050b6059d03d..3aa256baf00d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/cindex_of_row.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/cindex_of_row.js @@ -43,7 +43,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Complex64Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Complex64Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/cindex_of_row.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/cindex_of_row.native.js index 9bb434a1e9f0..5c2ca1b6efc6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/cindex_of_row.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/cindex_of_row.native.js @@ -43,7 +43,7 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Complex64Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Complex64Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/ndarray.js index e84982cdb957..1a3827c45873 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/ndarray.js @@ -39,8 +39,8 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Complex64Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Complex64Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/ndarray.native.js index 58119cef40d6..a38387c30b90 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/lib/ndarray.native.js @@ -39,8 +39,8 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Complex64Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Complex64Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/src/main.c index 684bfcea30d3..f0d881dc50eb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/src/main.c @@ -31,7 +31,7 @@ * @param M number of rows in `A` * @param N number of columns in `A` * @param A input matrix -* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param X search vector * @param strideX stride length for `X` * @param workspace workspace array for tracking row match candidates @@ -62,8 +62,8 @@ CBLAS_INT API_SUFFIX(stdlib_strided_cindex_of_row)( const CBLAS_LAYOUT order, co * @param M number of rows in `A` * @param N number of columns in `A` * @param A input matrix -* @param strideA1 stride of the first dimension of `A` -* @param strideA2 stride of the second dimension of `A` +* @param strideA1 stride length for the first dimension of `A` +* @param strideA2 stride length for the second dimension of `A` * @param offsetA index offset for `A` * @param X search vector * @param strideX stride length for `X` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/README.md index f9ea6756947e..e047b27285ed 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/README.md @@ -69,11 +69,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Float64Array`][mdn-float64array]. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: search vector stored as a [`Float64Array`][mdn-float64array]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -170,14 +170,14 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Float64Array`][mdn-float64array]. -- **strideA1**: stride of the first dimension of `A`. -- **strideA2**: stride of the second dimension of `A`. +- **strideA1**: stride length for the first dimension of `A`. +- **strideA2**: stride length for the second dimension of `A`. - **offsetA**: starting index for `A`. - **x**: search vector stored as a [`Float64Array`][mdn-float64array]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. - **offsetW**: starting index for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -299,7 +299,7 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] double*` input matrix. -- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: `[in] CBLAS_INT` stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **X**: `[in] double*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **workspace**: `[inout] uint8_t*` workspace array for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. @@ -345,8 +345,8 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] double*` input matrix. -- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. -- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **strideA1**: `[in] CBLAS_INT` stride length for the first dimension of `A`. +- **strideA2**: `[in] CBLAS_INT` stride length for the second dimension of `A`. - **offsetA**: `[in] CBLAS_INT` index offset for `A`. - **X**: `[in] double*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/repl.txt index 5afc1bfb78f2..42b92988550c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/repl.txt @@ -25,8 +25,8 @@ Input matrix `A`. LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + Stride length for the first dimension of `A` (a.k.a., leading dimension + of the matrix `A`). x: Float64Array Search vector. @@ -79,10 +79,10 @@ Input matrix `A`. sa1: integer - Stride of the first dimension of `A`. + Stride length for the first dimension of `A`. sa2: integer - Stride of the second dimension of `A`. + Stride length for the second dimension of `A`. oa: integer Starting index for `A`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts index 687ffad9cece..b0017ba3ea0f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts @@ -38,7 +38,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking row match candidates @@ -69,8 +69,8 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param strideA1 - stride of the first dimension of `A` - * @param strideA2 - stride of the second dimension of `A` + * @param strideA1 - stride length for the first dimension of `A` + * @param strideA2 - stride length for the second dimension of `A` * @param offsetA - starting index for `A` * @param x - search vector * @param strideX - stride length for `x` @@ -106,7 +106,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix -* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.js index 3046f4acce61..cc7d0bdd41b1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.js @@ -43,7 +43,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.native.js index 2903b2055bcd..b70acd228086 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.native.js @@ -42,7 +42,7 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.js index 0f3c0d0c2ec3..d037419a8993 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.js @@ -38,8 +38,8 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.native.js index 7a11ef64c024..d1d3a8f80aa4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.native.js @@ -38,8 +38,8 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/src/main.c index 06b691d266bc..5c051cac51fd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/src/main.c @@ -28,7 +28,7 @@ * @param M number of rows in `A` * @param N number of columns in `A` * @param A input matrix -* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param X search vector * @param strideX stride length for `X` * @param workspace workspace array for tracking row match candidates @@ -59,8 +59,8 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_row)( const CBLAS_LAYOUT order, co * @param M number of rows in `A` * @param N number of columns in `A` * @param A input matrix -* @param strideA1 stride of the first dimension of `A` -* @param strideA2 stride of the second dimension of `A` +* @param strideA1 stride length for the first dimension of `A` +* @param strideA2 stride length for the second dimension of `A` * @param offsetA index offset for `A` * @param X search vector * @param strideX stride length for `X` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/README.md index 1ce3983051bc..49a6dc751edf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/README.md @@ -55,9 +55,9 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix as a linear array. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: search vector. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. If the function is unable to find a matching row, the function returns `-1`. @@ -112,11 +112,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix as a linear array. -- **strideA1**: stride of the first dimension of `A`. -- **strideA2**: stride of the second dimension of `A`. +- **strideA1**: stride length for the first dimension of `A`. +- **strideA2**: stride length for the second dimension of `A`. - **offsetA**: starting index for `A`. - **x**: search vector. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/docs/repl.txt index 0949dad6afe3..1f17b87c2b89 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/docs/repl.txt @@ -25,8 +25,8 @@ Input matrix `A`. LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + Stride length for the first dimension of `A` (a.k.a., leading dimension + of the matrix `A`). x: Array|TypedArray Search vector. @@ -70,10 +70,10 @@ Input matrix `A`. strideA1: integer - Stride of the first dimension of `A`. + Stride length for the first dimension of `A`. strideA2: integer - Stride of the second dimension of `A`. + Stride length for the second dimension of `A`. offsetA: integer Starting index for `A`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/docs/types/index.d.ts index e89bf0ef345a..1ee932fb42e7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/docs/types/index.d.ts @@ -43,7 +43,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @returns row index @@ -67,8 +67,8 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param strideA1 - stride of the first dimension of `A` - * @param strideA2 - stride of the second dimension of `A` + * @param strideA1 - stride length for the first dimension of `A` + * @param strideA2 - stride length for the second dimension of `A` * @param offsetA - starting index for `A` * @param x - search vector * @param strideX - stride length for `x` @@ -96,7 +96,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix -* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @returns row index diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/accessors.js index 2e8a7c7b63fb..ea413705d50e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/accessors.js @@ -39,8 +39,8 @@ var ones = require( '@stdlib/array/base/ones' ); * @param {Object} A - input matrix object * @param {Collection} A.data - input matrix data * @param {Array} A.accessors - matrix element accessors -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Object} x - search vector object * @param {Collection} x.data - search vector data diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/base.js index d864eebc50f1..d0d523f4699b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/base.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/base.js @@ -39,8 +39,8 @@ var accessors = require( './accessors.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Collection} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Collection} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/main.js index 1e911fd1fda0..7dc07c1f9b98 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/main.js @@ -42,7 +42,7 @@ var base = require( './base.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Collection} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Collection} x - search vector * @param {integer} strideX - stride length for `x` * @throws {TypeError} first argument must be a valid order diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/ndarray.js index 368d80421416..65d6803a59db 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-row/lib/ndarray.js @@ -35,8 +35,8 @@ var base = require( './base.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Collection} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Collection} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/README.md index ac548eb9d27d..b52bbcd5d9e2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/README.md @@ -69,11 +69,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Float32Array`][mdn-float32array]. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: search vector stored as a [`Float32Array`][mdn-float32array]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -170,14 +170,14 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Float32Array`][mdn-float32array]. -- **strideA1**: stride of the first dimension of `A`. -- **strideA2**: stride of the second dimension of `A`. +- **strideA1**: stride length for the first dimension of `A`. +- **strideA2**: stride length for the second dimension of `A`. - **offsetA**: starting index for `A`. - **x**: search vector stored as a [`Float32Array`][mdn-float32array]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. - **offsetW**: starting index for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -299,7 +299,7 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] float*` input matrix. -- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: `[in] CBLAS_INT` stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **X**: `[in] float*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **workspace**: `[inout] uint8_t*` workspace array for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. @@ -345,8 +345,8 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] float*` input matrix. -- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. -- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **strideA1**: `[in] CBLAS_INT` stride length for the first dimension of `A`. +- **strideA2**: `[in] CBLAS_INT` stride length for the second dimension of `A`. - **offsetA**: `[in] CBLAS_INT` index offset for `A`. - **X**: `[in] float*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/repl.txt index 84fcb8418f65..cfe02b2e3b8c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/repl.txt @@ -25,8 +25,8 @@ Input matrix `A`. LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + Stride length for the first dimension of `A` (a.k.a., leading dimension + of the matrix `A`). x: Float32Array Search vector. @@ -79,10 +79,10 @@ Input matrix `A`. sa1: integer - Stride of the first dimension of `A`. + Stride length for the first dimension of `A`. sa2: integer - Stride of the second dimension of `A`. + Stride length for the second dimension of `A`. oa: integer Starting index for `A`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/types/index.d.ts index 3bc01ed37d05..a23293005bdd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/types/index.d.ts @@ -38,7 +38,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking row match candidates @@ -69,8 +69,8 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param strideA1 - stride of the first dimension of `A` - * @param strideA2 - stride of the second dimension of `A` + * @param strideA1 - stride length for the first dimension of `A` + * @param strideA2 - stride length for the second dimension of `A` * @param offsetA - starting index for `A` * @param x - search vector * @param strideX - stride length for `x` @@ -106,7 +106,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix -* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/ndarray.js index a02d240ba84d..75dab54045f8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/ndarray.js @@ -38,8 +38,8 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float32Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Float32Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/ndarray.native.js index 15ddd0ed497c..1a4621f6472c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/ndarray.native.js @@ -38,8 +38,8 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float32Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Float32Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/sindex_of_row.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/sindex_of_row.js index e124f41cddd4..5f12b44110db 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/sindex_of_row.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/sindex_of_row.js @@ -43,7 +43,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float32Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float32Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/sindex_of_row.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/sindex_of_row.native.js index 04b76dd1188c..d5e04c034293 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/sindex_of_row.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/lib/sindex_of_row.native.js @@ -42,7 +42,7 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float32Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float32Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/src/main.c index 95007b9ff68a..83defa239419 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/src/main.c @@ -28,7 +28,7 @@ * @param M number of rows in `A` * @param N number of columns in `A` * @param A input matrix -* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param X search vector * @param strideX stride length for `X` * @param workspace workspace array for tracking row match candidates @@ -59,8 +59,8 @@ CBLAS_INT API_SUFFIX(stdlib_strided_sindex_of_row)( const CBLAS_LAYOUT order, co * @param M number of rows in `A` * @param N number of columns in `A` * @param A input matrix -* @param strideA1 stride of the first dimension of `A` -* @param strideA2 stride of the second dimension of `A` +* @param strideA1 stride length for the first dimension of `A` +* @param strideA2 stride length for the second dimension of `A` * @param offsetA index offset for `A` * @param X search vector * @param strideX stride length for `X` diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/README.md index 3d718471604d..5794c30f69c9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/README.md @@ -68,11 +68,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Complex128Array`][@stdlib/array/complex128]. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: search vector stored as a [`Complex128Array`][@stdlib/array/complex128]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -166,14 +166,14 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Complex128Array`][@stdlib/array/complex128]. -- **strideA1**: stride of the first dimension of `A`. -- **strideA2**: stride of the second dimension of `A`. +- **strideA1**: stride length for the first dimension of `A`. +- **strideA2**: stride length for the second dimension of `A`. - **offsetA**: starting index for `A`. - **x**: search vector stored as a [`Complex128Array`][@stdlib/array/complex128]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. - **offsetW**: starting index for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -302,7 +302,7 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] stdlib_complex128_t*` input matrix. -- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: `[in] CBLAS_INT` stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **X**: `[in] stdlib_complex128_t*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **workspace**: `[inout] uint8_t*` workspace array for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. @@ -350,8 +350,8 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] stdlib_complex128_t*` input matrix. -- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. -- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **strideA1**: `[in] CBLAS_INT` stride length for the first dimension of `A`. +- **strideA2**: `[in] CBLAS_INT` stride length for the second dimension of `A`. - **offsetA**: `[in] CBLAS_INT` index offset for `A`. - **X**: `[in] stdlib_complex128_t*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/docs/repl.txt index 1992dfa86825..875c2a0f05ce 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/docs/repl.txt @@ -25,8 +25,8 @@ Input matrix `A`. LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + Stride length for the first dimension of `A` (a.k.a., leading dimension + of the matrix `A`). x: Complex128Array Search vector. @@ -79,10 +79,10 @@ Input matrix `A`. sa1: integer - Stride of the first dimension of `A`. + Stride length for the first dimension of `A`. sa2: integer - Stride of the second dimension of `A`. + Stride length for the second dimension of `A`. oa: integer Starting index for `A`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/docs/types/test.ts index 49f901c67316..95887ff97a0b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import Complex128Array = require( '@stdlib/array/complex128' ); import zindexOfRow = require( './index' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/ndarray.js index 34b1c8c1183e..e56f779027a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/ndarray.js @@ -39,8 +39,8 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Complex128Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Complex128Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/ndarray.native.js index 779bf37b1f1d..d2ee6e911d7a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/ndarray.native.js @@ -39,8 +39,8 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Complex128Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Complex128Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/zindex_of_row.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/zindex_of_row.js index 8cc10b7462b1..be05d640113a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/zindex_of_row.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/zindex_of_row.js @@ -43,7 +43,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Complex128Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Complex128Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/zindex_of_row.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/zindex_of_row.native.js index a32c234148f8..46fe1a7e69e3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/zindex_of_row.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/lib/zindex_of_row.native.js @@ -43,7 +43,7 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Complex128Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Complex128Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/src/main.c index f9da8ba805b1..07d89b5263ab 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-row/src/main.c @@ -31,7 +31,7 @@ * @param M number of rows in `A` * @param N number of columns in `A` * @param A input matrix -* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param X search vector * @param strideX stride length for `X` * @param workspace workspace array for tracking row match candidates @@ -62,8 +62,8 @@ CBLAS_INT API_SUFFIX(stdlib_strided_zindex_of_row)( const CBLAS_LAYOUT order, co * @param M number of rows in `A` * @param N number of columns in `A` * @param A input matrix -* @param strideA1 stride of the first dimension of `A` -* @param strideA2 stride of the second dimension of `A` +* @param strideA1 stride length for the first dimension of `A` +* @param strideA2 stride length for the second dimension of `A` * @param offsetA index offset for `A` * @param X search vector * @param strideX stride length for `X` From b766e73f34177eeac5c3a80e9de01c3ddad04780 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 14:39:29 +0500 Subject: [PATCH 16/68] fix: refactor `index-of-column` --- .../blas/ext/base/cindex-of-column/README.md | 1 - .../base/cindex-of-column/docs/types/test.ts | 1 + .../cindex-of-column/lib/cindex_of_column.js | 2 +- .../lib/cindex_of_column.native.js | 2 +- .../blas/ext/base/dindex-of-column/README.md | 20 +++++++++---------- .../ext/base/dindex-of-column/docs/repl.txt | 9 ++++----- .../dindex-of-column/docs/types/index.d.ts | 16 +++++++-------- .../dindex-of-column/lib/dindex_of_column.js | 2 +- .../lib/dindex_of_column.native.js | 2 +- .../ext/base/dindex-of-column/lib/ndarray.js | 4 ++-- .../dindex-of-column/lib/ndarray.native.js | 4 ++-- .../blas/ext/base/dindex-of-column/src/main.c | 6 +++--- .../blas/ext/base/gindex-of-column/README.md | 10 +++++----- .../ext/base/gindex-of-column/docs/repl.txt | 8 ++++---- .../gindex-of-column/docs/types/index.d.ts | 8 ++++---- .../base/gindex-of-column/lib/accessors.js | 4 ++-- .../ext/base/gindex-of-column/lib/base.js | 4 ++-- .../ext/base/gindex-of-column/lib/main.js | 2 +- .../ext/base/gindex-of-column/lib/ndarray.js | 4 ++-- .../blas/ext/base/sindex-of-column/README.md | 1 - .../sindex-of-column/lib/sindex_of_column.js | 2 +- .../lib/sindex_of_column.native.js | 2 +- .../blas/ext/base/zindex-of-column/README.md | 1 - .../base/zindex-of-column/docs/types/test.ts | 1 + .../zindex-of-column/lib/zindex_of_column.js | 2 +- .../lib/zindex_of_column.native.js | 2 +- 26 files changed, 59 insertions(+), 61 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/README.md b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/README.md index d8452e9cd87b..308095adfab1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/README.md @@ -200,7 +200,6 @@ var out = cindexOfColumn.ndarray( 2, 2, A, 1, 2, 0, x, 1, 0, workspace, 1, 0 ); ## Notes -- If `M <= 0` or `N <= 0`, both functions return `-1`. - When searching for a matching column, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same. diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/docs/types/test.ts index 93ecff0894be..50202b6926fc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import Complex64Array = require( '@stdlib/array/complex64' ); import cindexOfColumn = require( './index' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.js index 1dcdba459234..77089ece1368 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.js @@ -76,7 +76,7 @@ function cindexOfColumn( order, M, N, A, LDA, x, strideX, workspace, strideW ) { s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } if ( isColumnMajor( order ) ) { sa1 = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.native.js index 9e3681d579b8..69daa5e28f89 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.native.js @@ -74,7 +74,7 @@ function cindexOfColumn( order, M, N, A, LDA, x, strideX, workspace, strideW ) { s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } return addon( resolveOrder( order ), M, N, reinterpret( A, 0 ), LDA, reinterpret( x, 0 ), strideX, workspace, strideW ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/README.md b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/README.md index acc7b2d69a52..64a1b3e4eebd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/README.md @@ -69,11 +69,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Float64Array`][mdn-float64array]. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: search vector stored as a [`Float64Array`][mdn-float64array]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking column match candidates. This parameter is ignored if the function is provided an input matrix stored in column-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. When an input matrix is stored in column-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -170,14 +170,14 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Float64Array`][mdn-float64array]. -- **strideA1**: stride of the first dimension of `A`. -- **strideA2**: stride of the second dimension of `A`. +- **strideA1**: stride length for the first dimension of `A`. +- **strideA2**: stride length for the second dimension of `A`. - **offsetA**: starting index for `A`. - **x**: search vector stored as a [`Float64Array`][mdn-float64array]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking column match candidates. This parameter is ignored if the function is provided an input matrix stored in column-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. - **offsetW**: starting index for `workspace`. When an input matrix is stored in column-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -299,7 +299,7 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] double*` input matrix. -- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: `[in] CBLAS_INT` stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **X**: `[in] double*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **workspace**: `[inout] uint8_t*` workspace array for tracking column match candidates. This parameter is ignored if the function is provided an input matrix stored in column-major order. @@ -345,8 +345,8 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] double*` input matrix. -- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. -- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **strideA1**: `[in] CBLAS_INT` stride length for the first dimension of `A`. +- **strideA2**: `[in] CBLAS_INT` stride length for the second dimension of `A`. - **offsetA**: `[in] CBLAS_INT` starting index for `A`. - **X**: `[in] double*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/repl.txt index 25637fd1b4e3..94b3160dbb98 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/repl.txt @@ -25,8 +25,8 @@ Input matrix `A`. LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + Stride length for the first dimension of `A` (a.k.a., leading dimension + of the matrix `A`). x: Float64Array Search vector. @@ -79,10 +79,10 @@ Input matrix `A`. sa1: integer - Stride of the first dimension of `A`. + Stride length for the first dimension of `A`. sa2: integer - Stride of the second dimension of `A`. + Stride length for the second dimension of `A`. oa: integer Starting index for `A`. @@ -121,4 +121,3 @@ See Also -------- - diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/index.d.ts index ad877713f204..d857b8ac6942 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/index.d.ts @@ -38,7 +38,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking column match candidates @@ -49,7 +49,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * - * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0, 0.0 ] ); * var workspace = new Uint8Array( 2 ); * @@ -69,8 +69,8 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param strideA1 - stride of the first dimension of `A` - * @param strideA2 - stride of the second dimension of `A` + * @param strideA1 - stride length for the first dimension of `A` + * @param strideA2 - stride length for the second dimension of `A` * @param offsetA - starting index for `A` * @param x - search vector * @param strideX - stride length for `x` @@ -84,7 +84,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * - * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0, 0.0 ] ); * var workspace = new Uint8Array( 2 ); * @@ -106,7 +106,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix -* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking column match candidates @@ -117,7 +117,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0, 0.0 ] ); * var workspace = new Uint8Array( 2 ); * @@ -128,7 +128,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0, 0.0 ] ); * var workspace = new Uint8Array( 2 ); * diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.js index 6ff35470c6bf..11134bddb4d1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.js @@ -43,7 +43,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking column match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.native.js index 36ab6c8caa9f..bc873160ed52 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.native.js @@ -42,7 +42,7 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking column match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.js index 774fcedff3cf..5bfa373f63c9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.js @@ -38,8 +38,8 @@ var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.native.js index 5247becb2eca..28e2d81408aa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.native.js @@ -38,8 +38,8 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/src/main.c index b5426833962a..a9ba1d7341b7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/src/main.c @@ -28,7 +28,7 @@ * @param M number of rows in `A` * @param N number of columns in `A` * @param A input matrix -* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param X search vector * @param strideX stride length for `X` * @param workspace workspace array for tracking column match candidates @@ -59,8 +59,8 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_column)( const CBLAS_LAYOUT order, * @param M number of rows in `A` * @param N number of columns in `A` * @param A input matrix -* @param strideA1 stride of the first dimension of `A` -* @param strideA2 stride of the second dimension of `A` +* @param strideA1 stride length for the first dimension of `A` +* @param strideA2 stride length for the second dimension of `A` * @param offsetA starting index for `A` * @param X search vector * @param strideX stride length for `X` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/README.md index 167d35495aed..25073cec024a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/README.md @@ -55,9 +55,9 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix as a linear array. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: search vector. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. If the function is unable to find a matching column, the function returns `-1`. @@ -116,11 +116,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix as a linear array. -- **strideA1**: stride of the first dimension of `A`. -- **strideA2**: stride of the second dimension of `A`. +- **strideA1**: stride length for the first dimension of `A`. +- **strideA2**: stride length for the second dimension of `A`. - **offsetA**: starting index for `A`. - **x**: search vector. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/docs/repl.txt index a5a472ecfee6..8ff56240d26b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/docs/repl.txt @@ -25,8 +25,8 @@ Input matrix `A`. LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + Stride length for the first dimension of `A` (a.k.a., leading dimension + of the matrix `A`). x: Array|TypedArray Search vector. @@ -70,10 +70,10 @@ Input matrix `A`. strideA1: integer - Stride of the first dimension of `A`. + Stride length for the first dimension of `A`. strideA2: integer - Stride of the second dimension of `A`. + Stride length for the second dimension of `A`. offsetA: integer Starting index for `A`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/docs/types/index.d.ts index 82d5b62bdf8f..4c71226f821b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/docs/types/index.d.ts @@ -43,7 +43,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @returns column index @@ -67,8 +67,8 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param strideA1 - stride of the first dimension of `A` - * @param strideA2 - stride of the second dimension of `A` + * @param strideA1 - stride length for the first dimension of `A` + * @param strideA2 - stride length for the second dimension of `A` * @param offsetA - starting index for `A` * @param x - search vector * @param strideX - stride length for `x` @@ -96,7 +96,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix -* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @returns column index diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/accessors.js index 9cb89eb292f6..e97f709f8808 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/accessors.js @@ -39,8 +39,8 @@ var ones = require( '@stdlib/array/base/ones' ); * @param {Object} A - input matrix object * @param {Collection} A.data - input matrix data * @param {Array} A.accessors - matrix element accessors -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Object} x - search vector object * @param {Collection} x.data - search vector data diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/base.js index 3da2e8fb2b2a..a6b45da4c534 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/base.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/base.js @@ -39,8 +39,8 @@ var accessors = require( './accessors.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Collection} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Collection} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/main.js index 76deffae2a71..cf74d4c566a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/main.js @@ -42,7 +42,7 @@ var base = require( './base.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Collection} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Collection} x - search vector * @param {integer} strideX - stride length for `x` * @throws {TypeError} first argument must be a valid order diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/ndarray.js index 68a4a8e5e597..a1cde17d34f0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-column/lib/ndarray.js @@ -35,8 +35,8 @@ var base = require( './base.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Collection} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Collection} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/README.md b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/README.md index d34cd5529eee..7e1f483e7579 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/README.md @@ -198,7 +198,6 @@ var out = sindexOfColumn.ndarray( 3, 2, A, 1, 3, 0, x, 1, 0, workspace, 1, 0 ); ## Notes -- If `M <= 0` or `N <= 0`, both functions return `-1`. - When searching for a matching column, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same. diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/lib/sindex_of_column.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/lib/sindex_of_column.js index 9ec5cdeab99f..9cf7483bdd1b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/lib/sindex_of_column.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/lib/sindex_of_column.js @@ -76,7 +76,7 @@ function sindexOfColumn( order, M, N, A, LDA, x, strideX, workspace, strideW ) { s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } if ( isColumnMajor( order ) ) { sa1 = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/lib/sindex_of_column.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/lib/sindex_of_column.native.js index cb9b6c17231d..313ea6c3331e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/lib/sindex_of_column.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-column/lib/sindex_of_column.native.js @@ -73,7 +73,7 @@ function sindexOfColumn( order, M, N, A, LDA, x, strideX, workspace, strideW ) { s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } return addon( resolveOrder( order ), M, N, A, LDA, x, strideX, workspace, strideW ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/README.md b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/README.md index 3c1f61d77b54..3fc5e3dc20ac 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/README.md @@ -200,7 +200,6 @@ var out = zindexOfColumn.ndarray( 2, 2, A, 1, 2, 0, x, 1, 0, workspace, 1, 0 ); ## Notes -- If `M <= 0` or `N <= 0`, both functions return `-1`. - When searching for a matching column, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same. diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/docs/types/test.ts index baeb51f39bd0..2eaf31757af9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import Complex128Array = require( '@stdlib/array/complex128' ); import zindexOfColumn = require( './index' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/lib/zindex_of_column.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/lib/zindex_of_column.js index 201caa5c3551..6baeca9945cd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/lib/zindex_of_column.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/lib/zindex_of_column.js @@ -76,7 +76,7 @@ function zindexOfColumn( order, M, N, A, LDA, x, strideX, workspace, strideW ) { s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } if ( isColumnMajor( order ) ) { sa1 = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/lib/zindex_of_column.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/lib/zindex_of_column.native.js index 794ef0dc3bbf..bb4b865f002c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/lib/zindex_of_column.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of-column/lib/zindex_of_column.native.js @@ -74,7 +74,7 @@ function zindexOfColumn( order, M, N, A, LDA, x, strideX, workspace, strideW ) { s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } return addon( resolveOrder( order ), M, N, reinterpret( A, 0 ), LDA, reinterpret( x, 0 ), strideX, workspace, strideW ); // eslint-disable-line max-len } From ec532f558069ea59a942fd1003793b9a623c1a1e Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 14:39:49 +0500 Subject: [PATCH 17/68] docs: add matrix visualization comments in `index-of-row` --- .../blas/ext/base/dindex-of-row/docs/types/index.d.ts | 8 ++++---- .../blas/ext/base/sindex-of-row/docs/types/index.d.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts index b0017ba3ea0f..c72af4ab87a2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts @@ -49,7 +49,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * - * var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); + * var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * @@ -84,7 +84,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * - * var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); + * var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * @@ -117,7 +117,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * -* var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * @@ -128,7 +128,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * -* var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/types/index.d.ts index a23293005bdd..46fd0e8f183f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of-row/docs/types/index.d.ts @@ -49,7 +49,7 @@ interface Routine { * var Float32Array = require( '@stdlib/array/float32' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * - * var A = new Float32Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); + * var A = new Float32Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float32Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * @@ -84,7 +84,7 @@ interface Routine { * var Float32Array = require( '@stdlib/array/float32' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * - * var A = new Float32Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); + * var A = new Float32Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float32Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * @@ -117,7 +117,7 @@ interface Routine { * var Float32Array = require( '@stdlib/array/float32' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * -* var A = new Float32Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); +* var A = new Float32Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float32Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * @@ -128,7 +128,7 @@ interface Routine { * var Float32Array = require( '@stdlib/array/float32' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * -* var A = new Float32Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); +* var A = new Float32Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float32Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * From a257723b0f17b4b394468448a437fb2044f1c345 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 14:49:52 +0500 Subject: [PATCH 18/68] fix: refactor `last-index-of-row` --- .../@stdlib/blas/ext/base/clast-index-of-row/docs/types/test.ts | 1 + .../blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.js | 2 +- .../base/dlast-index-of-row/lib/dlast_index_of_row.native.js | 2 +- .../@stdlib/blas/ext/base/zlast-index-of-row/docs/types/test.ts | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/docs/types/test.ts index 68c4b4d8c060..bb72e8e15c4c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import Complex64Array = require( '@stdlib/array/complex64' ); import clastIndexOfRow = require( './index' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.js index a77bbde25303..83cb74e8f9f3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.js @@ -76,7 +76,7 @@ function dlastIndexOfRow( order, M, N, A, LDA, x, strideX, workspace, strideW ) s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } if ( isColumnMajor( order ) ) { sa1 = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.native.js index ed0de8cc5d5b..8bbd7edde978 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.native.js @@ -73,7 +73,7 @@ function dlastIndexOfRow( order, M, N, A, LDA, x, strideX, workspace, strideW ) s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } return addon( resolveOrder( order ), M, N, A, LDA, x, strideX, workspace, strideW ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-row/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-row/docs/types/test.ts index 2ddad24a73b0..7c6fdade1554 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-row/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/zlast-index-of-row/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import Complex128Array = require( '@stdlib/array/complex128' ); import zlastIndexOfRow = require( './index' ); From 44034594f62c67079751ddcca2d6b2f12bd8fe9f Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 15:22:07 +0500 Subject: [PATCH 19/68] fix: refactor `gindex-of-truthy-row` and `gindex-of-falsy-row` --- .../blas/ext/base/gindex-of-falsy-row/README.md | 2 +- .../blas/ext/base/gindex-of-falsy-row/docs/repl.txt | 4 ++-- .../base/gindex-of-falsy-row/docs/types/index.d.ts | 12 ++++++------ .../blas/ext/base/gindex-of-falsy-row/lib/index.js | 2 +- .../blas/ext/base/gindex-of-falsy-row/lib/main.js | 2 +- .../blas/ext/base/gindex-of-falsy-row/lib/ndarray.js | 1 + .../blas/ext/base/gindex-of-truthy-row/README.md | 2 +- .../blas/ext/base/gindex-of-truthy-row/docs/repl.txt | 4 ++-- .../base/gindex-of-truthy-row/docs/types/index.d.ts | 12 ++++++------ .../blas/ext/base/gindex-of-truthy-row/lib/index.js | 2 +- .../blas/ext/base/gindex-of-truthy-row/lib/main.js | 2 +- 11 files changed, 23 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/README.md index 65a3f55b7edf..bcfd73f325ff 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/README.md @@ -57,7 +57,7 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix as a linear array. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). If the function is unable to find a row in which all elements are falsy, the function returns `-1`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/docs/repl.txt index 3815365a7ed5..386254c750bd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/docs/repl.txt @@ -25,8 +25,8 @@ Input matrix. LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + Stride length for the first dimension of `A` (a.k.a., leading dimension + of the matrix `A`). Returns ------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/docs/types/index.d.ts index 5f038141cd01..efd550c36a4e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/docs/types/index.d.ts @@ -43,11 +43,11 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @returns row index * * @example - * var A = [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ]; + * var A = [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ]; // => [ [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 1.0, 1.0, 1.0 ] ] * * var out = gindexOfFalsyRow( 'row-major', 4, 4, A, 4 ); * // returns 1 @@ -70,7 +70,7 @@ interface Routine { * @returns row index * * @example - * var A = [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ]; + * var A = [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ]; // => [ [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 1.0, 1.0, 1.0 ] ] * * var out = gindexOfFalsyRow.ndarray( 4, 4, A, 4, 1, 0 ); * // returns 1 @@ -89,17 +89,17 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix -* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @returns row index * * @example -* var A = [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ]; +* var A = [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ]; // => [ [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 1.0, 1.0, 1.0 ] ] * * var out = gindexOfFalsyRow( 'row-major', 4, 4, A, 4 ); * // returns 1 * * @example -* var A = [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ]; +* var A = [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ]; // => [ [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 1.0, 1.0, 1.0 ] ] * * var out = gindexOfFalsyRow.ndarray( 4, 4, A, 4, 1, 0 ); * // returns 1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/index.js index a4777ab16277..babb70d185f5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/index.js @@ -34,7 +34,7 @@ * @example * var gindexOfFalsyRow = require( '@stdlib/blas/ext/base/gindex-of-falsy-row' ); * -* var A = [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ]; +* var A = [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ]; // => [ [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 1.0, 1.0, 1.0 ] ] * * var out = gindexOfFalsyRow.ndarray( 4, 4, A, 4, 1, 0 ); * // returns 1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/main.js index 7b779e4da343..35d3f0fcbe7d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/main.js @@ -40,7 +40,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Collection} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @throws {TypeError} first argument must be a valid order * @throws {RangeError} fifth argument must be a valid stride length * @returns {integer} row index diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/ndarray.js index 64960382d2ab..68a2b2cc2dad 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-falsy-row/lib/ndarray.js @@ -62,6 +62,7 @@ function gindexOfFalsyRow( M, N, A, strideA1, strideA2, offsetA ) { var ia; var i; + // Check whether the matrix is an empty matrix... if ( M <= 0 || N <= 0 ) { return -1; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md index c8b951ee7902..904cc99db5e5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md @@ -57,7 +57,7 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix as a linear array. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). If the function is unable to find a row with at least one truthy element, the function returns `-1`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/repl.txt index d5eb9eb65b87..9247904224cf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/repl.txt @@ -25,8 +25,8 @@ Input matrix. LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + Stride length for the first dimension of `A` (a.k.a., leading dimension + of the matrix `A`). Returns ------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts index ef733c8ef99c..b99c95f270f5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts @@ -43,11 +43,11 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @returns row index * * @example - * var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; + * var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 0.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] * * var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); * // returns 1 @@ -70,7 +70,7 @@ interface Routine { * @returns row index * * @example - * var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; + * var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 0.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] * * var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 0 ); * // returns 1 @@ -89,17 +89,17 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix -* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @returns row index * * @example -* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 0.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] * * var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); * // returns 1 * * @example -* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 0.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] * * var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 0 ); * // returns 1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js index ef6d96b84479..f85c3e9adf7d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js @@ -34,7 +34,7 @@ * @example * var gindexOfTruthyRow = require( '@stdlib/blas/ext/base/gindex-of-truthy-row' ); * -* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 0.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] * * var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 0 ); * // returns 1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/main.js index 0e2cb1ca568e..ee9ab2d38963 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/main.js @@ -40,7 +40,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Collection} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @throws {TypeError} first argument must be a valid order * @throws {RangeError} fifth argument must be a valid stride length * @returns {integer} row index From 7ccdfb79b969297795f12fe0e2dd9b88fc10a00e Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:03:34 +0500 Subject: [PATCH 20/68] fix: refactor `first-index-equal` --- .../ext/base/dfirst-index-equal/README.md | 2 +- .../dfirst-index-equal/docs/types/index.d.ts | 8 +- .../lib/dfirst_index_equal.js | 4 + .../base/dfirst-index-equal/lib/ndarray.js | 4 + .../test/test.dfirst_index_equal.js | 4 +- .../test/test.dfirst_index_equal.native.js | 4 +- .../dfirst-index-equal/test/test.ndarray.js | 52 +++++- .../test/test.ndarray.native.js | 52 +++++- .../base/gfirst-index-equal/lib/accessors.js | 4 + .../ext/base/gfirst-index-equal/lib/main.js | 4 + .../base/gfirst-index-equal/lib/ndarray.js | 4 + .../base/gfirst-index-equal/test/test.main.js | 36 +++- .../gfirst-index-equal/test/test.ndarray.js | 168 +++++++++++++++++- .../sfirst-index-equal/docs/types/index.d.ts | 6 +- .../base/sfirst-index-equal/lib/ndarray.js | 4 + .../lib/sfirst_index_equal.js | 4 + .../sfirst-index-equal/test/test.ndarray.js | 54 +++++- .../test/test.ndarray.native.js | 54 +++++- .../test/test.sfirst_index_equal.js | 4 +- .../test/test.sfirst_index_equal.native.js | 4 +- 20 files changed, 442 insertions(+), 34 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md index b2d20792db3f..abeb6c81badf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md @@ -62,7 +62,7 @@ The function has the following parameters: - **y**: second input [`Float64Array`][@stdlib/array/float64]. - **strideY**: stride length for `y`. -If the function is unable to find a match, the function returns `-1`. +If the function is unable to find matching elements, the function returns `-1`. ```javascript var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts index 834ebef251fa..0a2666ed8bab 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find matching elements, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -52,7 +52,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find matching elements, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -78,6 +78,10 @@ interface Routine { /** * Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param N - number of indexed elements * @param x - first input array * @param strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js index 6578f671efc0..b9d4f429d273 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js index 3078c67046b8..f1b3bb25ee34 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js index 2c0353416ab5..94639f83f8cd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js @@ -114,7 +114,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ NaN ] ), 1, new Float64Array( [ NaN ] ), 1 ); @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, new Float64Array( [ 0.0 ] ), 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js index 6b1e78b9a70e..125b8b7bf8d5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ NaN ] ), 1, new Float64Array( [ NaN ] ), 1 ); @@ -132,7 +132,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, new Float64Array( [ 0.0 ] ), 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js index f236de9a4f42..37521df26a4a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js @@ -114,7 +114,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ NaN ] ), 1, 0, new Float64Array( [ NaN ] ), 1, 0 ); @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, 0, new Float64Array( [ 0.0 ] ), 1, 0 ); @@ -210,6 +210,54 @@ tape( 'the function supports negative strides', function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 5.0, + 5.0, + 5.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = dfirstIndexEqual( 3, x, 1, 2, y, 1, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 0.0, + 0.0, + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = dfirstIndexEqual( 3, x, 1, 0, y, 1, 2 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports complex access patterns', function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js index 3d08120524fb..16adf71860cb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ NaN ] ), 1, 0, new Float64Array( [ NaN ] ), 1, 0 ); @@ -132,7 +132,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, 0, new Float64Array( [ 0.0 ] ), 1, 0 ); @@ -219,6 +219,54 @@ tape( 'the function supports negative strides', opts, function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 5.0, + 5.0, + 5.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = dfirstIndexEqual( 3, x, 1, 2, y, 1, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 0.0, + 0.0, + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = dfirstIndexEqual( 3, x, 1, 0, y, 1, 2 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports complex access patterns', opts, function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/accessors.js index e9b7d1895c24..bb9c95d4fe6f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/accessors.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element in a strided array equal to a corresponding element in another strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @private * @param {PositiveInteger} N - number of indexed elements * @param {Object} x - first input array object diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/main.js index 6880c0cef142..3f1e356f53e0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/main.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element in a strided array equal to a corresponding element in another strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/ndarray.js index d835f9601dbb..b6cb5a96c0c2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/lib/ndarray.js @@ -29,6 +29,10 @@ var accessors = require( './accessors.js' ); /** * Returns the index of the first element in a strided array equal to a corresponding element in another strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/test/test.main.js index e8f8c989ce8d..bd42abdd466a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/test/test.main.js @@ -185,7 +185,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = gfirstIndexEqual( 1, [ NaN ], 1, [ NaN ], 1 ); @@ -194,7 +194,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN`', f t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN` (accessors)', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors)', function test( t ) { var actual; actual = gfirstIndexEqual( 1, toAccessorArray( [ NaN ] ), 1, toAccessorArray( [ NaN ] ), 1 ); @@ -203,7 +203,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN` (ac t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = gfirstIndexEqual( 1, [ -0.0 ], 1, [ 0.0 ], 1 ); @@ -212,7 +212,7 @@ tape( 'the function treats -0 and +0 as equal', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = gfirstIndexEqual( 1, toAccessorArray( [ -0.0 ] ), 1, toAccessorArray( [ 0.0 ] ), 1 ); @@ -405,6 +405,34 @@ tape( 'the function supports complex access patterns', function test( t ) { t.end(); }); +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 5.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0, + 0.0 + ]; + + actual = gfirstIndexEqual( 3, toAccessorArray( x ), 2, toAccessorArray( y ), -1 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var actual; var x0; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/test/test.ndarray.js index 654f26045608..5a9272e9cfff 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/test/test.ndarray.js @@ -160,7 +160,7 @@ tape( 'the function returns the first index of an element which equals a corresp t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gfirstIndexEqual( 0, [ 1.0, 2.0, 3.0 ], 1, 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); @@ -172,7 +172,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gfirstIndexEqual( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -184,7 +184,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = gfirstIndexEqual( 1, [ NaN ], 1, 0, [ NaN ], 1, 0 ); @@ -193,7 +193,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN`', f t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN` (accessors)', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors)', function test( t ) { var actual; actual = gfirstIndexEqual( 1, toAccessorArray( [ NaN ] ), 1, 0, toAccessorArray( [ NaN ] ), 1, 0 ); @@ -202,7 +202,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN` (ac t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = gfirstIndexEqual( 1, [ -0.0 ], 1, 0, [ 0.0 ], 1, 0 ); @@ -211,7 +211,7 @@ tape( 'the function treats -0 and +0 as equal', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = gfirstIndexEqual( 1, toAccessorArray( [ -0.0 ] ), 1, 0, toAccessorArray( [ 0.0 ] ), 1, 0 ); @@ -376,6 +376,134 @@ tape( 'the function supports negative strides (accessors)', function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + var y; + + x = [ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0 // 3 + ]; + y = [ + 9.0, // 0 + 9.0, // 1 + 2.0, // 2 + 9.0, // 3 + 9.0, + 9.0, + 9.0, + 9.0 + ]; + + actual = gfirstIndexEqual( 4, x, 2, 1, y, 1, 0 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0 // 3 + ]; + y = [ + 9.0, // 0 + 9.0, // 1 + 2.0, // 2 + 9.0, // 3 + 9.0, + 9.0, + 9.0, + 9.0 + ]; + + actual = gfirstIndexEqual( 4, toAccessorArray( x ), 2, 1, toAccessorArray( y ), 1, 0 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var actual; + var x; + var y; + + x = [ + 2.0, // 0 + 1.0, // 1 + 2.0, // 2 + -2.0, // 3 + -2.0, + 2.0, + 3.0, + 4.0 + ]; + y = [ + 9.0, + 9.0, // 0 + 9.0, + 1.0, // 1 + 9.0, + 9.0, // 2 + 9.0, + 9.0 // 3 + ]; + + actual = gfirstIndexEqual( 4, x, 1, 0, y, 2, 1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 2.0, // 0 + 1.0, // 1 + 2.0, // 2 + -2.0, // 3 + -2.0, + 2.0, + 3.0, + 4.0 + ]; + y = [ + 9.0, + 9.0, // 0 + 9.0, + 1.0, // 1 + 9.0, + 9.0, // 2 + 9.0, + 9.0 // 3 + ]; + + actual = gfirstIndexEqual( 4, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 2, 1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports complex access patterns', function test( t ) { var actual; var x; @@ -403,3 +531,31 @@ tape( 'the function supports complex access patterns', function test( t ) { t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); + +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 5.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0, + 0.0 + ]; + + actual = gfirstIndexEqual( 3, toAccessorArray( x ), 2, 0, toAccessorArray( y ), -1, 2 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/docs/types/index.d.ts index af32c7f83e17..c90220579ec4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find matching elements, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -52,7 +52,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find matching elements, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -80,7 +80,7 @@ interface Routine { * * ## Notes * -* - If the function is unable to find a match, the function returns `-1`. +* - If the function is unable to find matching elements, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/ndarray.js index e14ff1a81129..d1d90ecf5ce5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/ndarray.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element in a single-precision floating-point strided array equal to a corresponding element in another single-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/sfirst_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/sfirst_index_equal.js index 16f24e419eb0..0fe5b7e08810 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/sfirst_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/sfirst_index_equal.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element in a single-precision floating-point strided array equal to a corresponding element in another single-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.ndarray.js index e51f28fd3f6f..031fd14332f8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.ndarray.js @@ -102,7 +102,7 @@ tape( 'the function returns the first index of an element which equals a corresp t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = sfirstIndexEqual( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len @@ -114,7 +114,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = sfirstIndexEqual( 1, new Float32Array( [ NaN ] ), 1, 0, new Float32Array( [ NaN ] ), 1, 0 ); // eslint-disable-line max-len @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN`', f t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = sfirstIndexEqual( 1, new Float32Array( [ -0.0 ] ), 1, 0, new Float32Array( [ 0.0 ] ), 1, 0 ); // eslint-disable-line max-len @@ -210,6 +210,54 @@ tape( 'the function supports negative strides', function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 5.0, + 5.0, + 5.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float32Array([ + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = sfirstIndexEqual( 3, x, 1, 2, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float32Array([ + 0.0, + 0.0, + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = sfirstIndexEqual( 3, x, 1, 0, y, 1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports complex access patterns', function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.ndarray.native.js index 2ef56b8ad53e..cb0c79c8ad73 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.ndarray.native.js @@ -111,7 +111,7 @@ tape( 'the function returns the first index of an element which equals a corresp t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = sfirstIndexEqual( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = sfirstIndexEqual( 1, new Float32Array( [ NaN ] ), 1, 0, new Float32Array( [ NaN ] ), 1, 0 ); // eslint-disable-line max-len @@ -132,7 +132,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN`', o t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = sfirstIndexEqual( 1, new Float32Array( [ -0.0 ] ), 1, 0, new Float32Array( [ 0.0 ] ), 1, 0 ); // eslint-disable-line max-len @@ -219,6 +219,54 @@ tape( 'the function supports negative strides', opts, function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 5.0, + 5.0, + 5.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float32Array([ + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = sfirstIndexEqual( 3, x, 1, 2, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a `y` offset', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float32Array([ + 0.0, + 0.0, + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = sfirstIndexEqual( 3, x, 1, 0, y, 1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports complex access patterns', opts, function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.sfirst_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.sfirst_index_equal.js index 3d8e115069ef..33d42a73fec5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.sfirst_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.sfirst_index_equal.js @@ -119,7 +119,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = sfirstIndexEqual( 1, new Float32Array( [ NaN ] ), 1, new Float32Array( [ NaN ] ), 1 ); // eslint-disable-line max-len @@ -128,7 +128,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN`', f t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = sfirstIndexEqual( 1, new Float32Array( [ -0.0 ] ), 1, new Float32Array( [ 0.0 ] ), 1 ); // eslint-disable-line max-len diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.sfirst_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.sfirst_index_equal.native.js index 5dcea9e9048c..4e05543f47fa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.sfirst_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/test/test.sfirst_index_equal.native.js @@ -128,7 +128,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = sfirstIndexEqual( 1, new Float32Array( [ NaN ] ), 1, new Float32Array( [ NaN ] ), 1 ); // eslint-disable-line max-len @@ -137,7 +137,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN`', o t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = sfirstIndexEqual( 1, new Float32Array( [ -0.0 ] ), 1, new Float32Array( [ 0.0 ] ), 1 ); // eslint-disable-line max-len From 3cead0b45a8368b6b105cec8e78a9a0ee23c36fa Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:03:35 +0500 Subject: [PATCH 21/68] fix: refactor `first-index-less-than` --- .../lib/dfirst_index_less_than.js | 4 + .../dfirst-index-less-than/lib/ndarray.js | 4 + .../test/test.dfirst_index_less_than.js | 7 +- .../test.dfirst_index_less_than.native.js | 7 +- .../test/test.ndarray.js | 7 +- .../test/test.ndarray.native.js | 7 +- .../gfirst-index-less-than/lib/accessors.js | 4 + .../base/gfirst-index-less-than/lib/main.js | 4 + .../gfirst-index-less-than/lib/ndarray.js | 4 + .../gfirst-index-less-than/test/test.main.js | 4 +- .../test/test.ndarray.js | 100 +++++++++++++++++- .../sfirst-index-less-than/lib/ndarray.js | 4 + .../lib/sfirst_index_less_than.js | 4 + .../test/test.ndarray.js | 7 +- .../test/test.ndarray.native.js | 7 +- .../test/test.sfirst_index_less_than.js | 2 +- .../test.sfirst_index_less_than.native.js | 7 +- 17 files changed, 171 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.js index 55d7a1df75bd..72610cfe580f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.js index 0962e0980740..718b16e8e900 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js index 7c95a2a21eb7..2dcc565a9a20 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js @@ -33,6 +33,11 @@ tape( 'main export is a function', function test( t ) { t.end(); }); +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( dfirstIndexLessThan.length, 5, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the first index of an element which is less than a corresponding element in another array', function test( t ) { var actual; var x; @@ -91,7 +96,7 @@ tape( 'the function returns the first index of an element which is less than a c t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; var y; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js index 01af96a0fc89..688918bff026 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js @@ -42,6 +42,11 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); +tape( 'the function has an arity of 5', opts, function test( t ) { + t.strictEqual( dfirstIndexLessThan.length, 5, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the first index of an element which is less than a corresponding element in another array', opts, function test( t ) { var actual; var x; @@ -100,7 +105,7 @@ tape( 'the function returns the first index of an element which is less than a c t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; var y; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js index 11b1ebdf9046..1c7496cdbf87 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js @@ -33,6 +33,11 @@ tape( 'main export is a function', function test( t ) { t.end(); }); +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( dfirstIndexLessThan.length, 7, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the first index of an element which is less than a corresponding element in another array', function test( t ) { var actual; var x; @@ -91,7 +96,7 @@ tape( 'the function returns the first index of an element which is less than a c t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; var y; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js index 0aff544155b6..b475a8171d87 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js @@ -42,6 +42,11 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); +tape( 'the function has an arity of 7', opts, function test( t ) { + t.strictEqual( dfirstIndexLessThan.length, 7, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the first index of an element which is less than a corresponding element in another array', opts, function test( t ) { var actual; var x; @@ -100,7 +105,7 @@ tape( 'the function returns the first index of an element which is less than a c t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; var y; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/accessors.js index 534eddd017b7..98f1cbabccce 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/accessors.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element in a strided array which is less than a corresponding element in another strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @private * @param {PositiveInteger} N - number of indexed elements * @param {Object} x - first input array object diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/main.js index 9f57a4e6cfdc..c20f21ddaefa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/main.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element in a strided array which is less than a corresponding element in another strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/ndarray.js index f93b5755d738..ee3abfd52bed 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/lib/ndarray.js @@ -29,6 +29,10 @@ var accessors = require( './accessors.js' ); /** * Returns the index of the first element in a strided array which is less than a corresponding element in another strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/test/test.main.js index 45e02ab563ea..e5df77bbcfef 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/test/test.main.js @@ -155,7 +155,7 @@ tape( 'the function returns the first index of an element which is less than a c t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gfirstIndexLessThan( 0, [ 1.0, 2.0, 3.0 ], 1, [ 1.0, 2.0, 3.0 ], 1 ); @@ -167,7 +167,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gfirstIndexLessThan( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/test/test.ndarray.js index cb4f429eaf73..ccbd8ab0ab96 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/test/test.ndarray.js @@ -154,7 +154,7 @@ tape( 'the function returns the first index of an element which is less than a c t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gfirstIndexLessThan( 0, [ 1.0, 2.0, 3.0 ], 1, 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); @@ -166,7 +166,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gfirstIndexLessThan( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -376,6 +376,102 @@ tape( 'the function supports negative strides (accessors)', function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + var y; + + x = [ + 5.0, + 5.0, + 5.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]; + y = [ + 5.0, // 0 + 2.0, // 1 + 4.0 // 2 + ]; + + actual = gfirstIndexLessThan( 3, x, 1, 2, y, 1, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 5.0, + 5.0, + 5.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]; + y = [ + 5.0, // 0 + 2.0, // 1 + 4.0 // 2 + ]; + + actual = gfirstIndexLessThan( 3, toAccessorArray( x ), 1, 2, toAccessorArray( y ), 1, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var actual; + var x; + var y; + + x = [ + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]; + y = [ + 0.0, + 0.0, + 5.0, // 0 + 2.0, // 1 + 4.0 // 2 + ]; + + actual = gfirstIndexLessThan( 3, x, 1, 0, y, 1, 2 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]; + y = [ + 0.0, + 0.0, + 5.0, // 0 + 2.0, // 1 + 4.0 // 2 + ]; + + actual = gfirstIndexLessThan( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 2 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports complex access patterns', function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/ndarray.js index 4b796422e586..d7df641ea9f7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/ndarray.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element in a single-precision floating-point strided array which is less than a corresponding element in another single-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/sfirst_index_less_than.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/sfirst_index_less_than.js index 9f838d730c89..d9acab8dddc2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/sfirst_index_less_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/sfirst_index_less_than.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element in a single-precision floating-point strided array which is less than a corresponding element in another single-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.js index 156732b8ff03..9417876679f1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.js @@ -33,6 +33,11 @@ tape( 'main export is a function', function test( t ) { t.end(); }); +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( sfirstIndexLessThan.length, 7, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the first index of an element which is less than a corresponding element in another array', function test( t ) { var actual; var x; @@ -91,7 +96,7 @@ tape( 'the function returns the first index of an element which is less than a c t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; var y; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.native.js index 2aaf68fb7bee..8dd8b827b407 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.native.js @@ -42,6 +42,11 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); +tape( 'the function has an arity of 7', opts, function test( t ) { + t.strictEqual( sfirstIndexLessThan.length, 7, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the first index of an element which is less than a corresponding element in another array', opts, function test( t ) { var actual; var x; @@ -100,7 +105,7 @@ tape( 'the function returns the first index of an element which is less than a c t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; var y; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.js index f23f0a316404..7076c8f5a93e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.js @@ -94,7 +94,7 @@ tape( 'the function returns the first index of an element which is less than a c t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; var y; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.native.js index a7fafb965efd..e88539f0813b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.native.js @@ -42,6 +42,11 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); +tape( 'the function has an arity of 5', opts, function test( t ) { + t.strictEqual( sfirstIndexLessThan.length, 5, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the first index of an element which is less than a corresponding element in another array', opts, function test( t ) { var actual; var x; @@ -100,7 +105,7 @@ tape( 'the function returns the first index of an element which is less than a c t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; var y; From f9a0d7ee3289c33fdf7d02385dfa99ce28b070f5 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:03:36 +0500 Subject: [PATCH 22/68] fix: refactor `first-index-greater-than` --- .../lib/dfirst_index_greater_than.js | 4 +++ .../dfirst-index-greater-than/lib/ndarray.js | 4 +++ .../test/test.dfirst_index_greater_than.js | 2 +- .../test.dfirst_index_greater_than.native.js | 2 +- .../test/test.ndarray.js | 2 +- .../test/test.ndarray.native.js | 2 +- .../lib/accessors.js | 4 +++ .../gfirst-index-greater-than/lib/main.js | 4 +++ .../gfirst-index-greater-than/lib/ndarray.js | 4 +++ .../test/test.main.js | 32 +++++++++++++++++-- .../test/test.ndarray.js | 32 +++++++++++++++++-- 11 files changed, 84 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js index 99a28faef530..5fcc94d36e22 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js index dba855c95fce..94ad57706123 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js index e127ed25195d..acc3478511be 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js @@ -126,7 +126,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dfirstIndexGreaterThan( 1, new Float64Array( [ 0.0 ] ), 1, new Float64Array( [ -0.0 ] ), 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js index 6ba30ee59430..4ed4d49c9cdd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js @@ -135,7 +135,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dfirstIndexGreaterThan( 1, new Float64Array( [ 0.0 ] ), 1, new Float64Array( [ -0.0 ] ), 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js index be1485b60734..98710d07dbeb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js @@ -126,7 +126,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dfirstIndexGreaterThan( 1, new Float64Array( [ 0.0 ] ), 1, 0, new Float64Array( [ -0.0 ] ), 1, 0 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js index 6257fa8eb007..0577ee220042 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js @@ -135,7 +135,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dfirstIndexGreaterThan( 1, new Float64Array( [ 0.0 ] ), 1, 0, new Float64Array( [ -0.0 ] ), 1, 0 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/accessors.js index 869c4f71aa53..9269344b7678 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/accessors.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element in a strided array which is greater than a corresponding element in another strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. +* * @private * @param {PositiveInteger} N - number of indexed elements * @param {Object} x - first input array object diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/main.js index a993d370c91b..7ce13a6155f1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/main.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element in a strided array which is greater than a corresponding element in another strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/ndarray.js index a0432966ab91..f9a5481c0552 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/ndarray.js @@ -29,6 +29,10 @@ var accessors = require( './accessors.js' ); /** * Returns the index of the first element in a strided array which is greater than a corresponding element in another strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.main.js index 4289f03ef0ec..867d692029a7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.main.js @@ -215,7 +215,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors) t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = gfirstIndexGreaterThan( 1, [ 0.0 ], 1, [ -0.0 ], 1 ); @@ -224,7 +224,7 @@ tape( 'the function treats -0 and +0 as equal', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = gfirstIndexGreaterThan( 1, toAccessorArray( [ 0.0 ] ), 1, toAccessorArray( [ -0.0 ] ), 1 ); @@ -417,6 +417,34 @@ tape( 'the function supports complex access patterns', function test( t ) { t.end(); }); +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 0.0, // 2 + 9.0, // 1 + 9.0, // 0 + 9.0, + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 3, toAccessorArray( x ), 2, toAccessorArray( y ), -1 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var actual; var x0; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.ndarray.js index 07e155ed20a9..a52f348e4dfd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.ndarray.js @@ -208,7 +208,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors) t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = gfirstIndexGreaterThan( 1, [ 0.0 ], 1, 0, [ -0.0 ], 1, 0 ); @@ -217,7 +217,7 @@ tape( 'the function treats -0 and +0 as equal', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = gfirstIndexGreaterThan( 1, toAccessorArray( [ 0.0 ] ), 1, 0, toAccessorArray( [ -0.0 ] ), 1, 0 ); @@ -537,3 +537,31 @@ tape( 'the function supports complex access patterns', function test( t ) { t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); + +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 0.0, // 2 + 9.0, // 1 + 9.0, // 0 + 9.0, + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 3, toAccessorArray( x ), 2, 0, toAccessorArray( y ), -1, 2 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); From 4120aebe3e58f0dbe834cd76029842c80a863b9f Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:03:37 +0500 Subject: [PATCH 23/68] fix: refactor `gfirst-index-greater-than-equal` --- .../test/test.main.js | 32 +++++++++++++++++-- .../test/test.ndarray.js | 32 +++++++++++++++++-- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/test/test.main.js index 1e5efd2d6a57..f938b0ad9899 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/test/test.main.js @@ -215,7 +215,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors) t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = gfirstIndexGreaterThanEqual( 1, [ -0.0 ], 1, [ 0.0 ], 1 ); @@ -224,7 +224,7 @@ tape( 'the function treats -0 and +0 as equal', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = gfirstIndexGreaterThanEqual( 1, toAccessorArray( [ -0.0 ] ), 1, toAccessorArray( [ 0.0 ] ), 1 ); @@ -417,6 +417,34 @@ tape( 'the function supports complex access patterns', function test( t ) { t.end(); }); +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 0.0, // 2 + 9.0, // 1 + 9.0, // 0 + 9.0, + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThanEqual( 3, toAccessorArray( x ), 2, toAccessorArray( y ), -1 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var actual; var x0; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/test/test.ndarray.js index cae3c2a7de72..e5482d0cbd49 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/test/test.ndarray.js @@ -208,7 +208,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors) t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = gfirstIndexGreaterThanEqual( 1, [ -0.0 ], 1, 0, [ 0.0 ], 1, 0 ); @@ -217,7 +217,7 @@ tape( 'the function treats -0 and +0 as equal', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = gfirstIndexGreaterThanEqual( 1, toAccessorArray( [ -0.0 ] ), 1, 0, toAccessorArray( [ 0.0 ] ), 1, 0 ); @@ -537,3 +537,31 @@ tape( 'the function supports complex access patterns', function test( t ) { t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); + +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 0.0, // 2 + 9.0, // 1 + 9.0, // 0 + 9.0, + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThanEqual( 3, toAccessorArray( x ), 2, 0, toAccessorArray( y ), -1, 2 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); From 3f9c3dcece81b617af750fd4408256e140a7c261 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:03:38 +0500 Subject: [PATCH 24/68] fix: refactor `gfirst-index-less-than-equal` --- .../ext/base/gfirst-index-less-than-equal/test/test.main.js | 4 ++-- .../base/gfirst-index-less-than-equal/test/test.ndarray.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/test/test.main.js index 927f788aff1a..16aae5b582f6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/test/test.main.js @@ -155,7 +155,7 @@ tape( 'the function returns the first index of an element which is less than or t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gfirstIndexLessThanEqual( 0, [ 1.0, 2.0, 3.0 ], 1, [ 1.0, 2.0, 3.0 ], 1 ); @@ -167,7 +167,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gfirstIndexLessThanEqual( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/test/test.ndarray.js index 3d370efe73f0..44058eb2fbfc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/test/test.ndarray.js @@ -154,7 +154,7 @@ tape( 'the function returns the first index of an element which is less than or t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gfirstIndexLessThanEqual( 0, [ 1.0, 2.0, 3.0 ], 1, 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); @@ -166,7 +166,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gfirstIndexLessThanEqual( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); From 074cac957a8cd42c7726224a45f8fb8d8a5b6f45 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:03:38 +0500 Subject: [PATCH 25/68] fix: refactor `gfirst-index-not-equal` --- .../ext/base/gfirst-index-not-equal/README.md | 8 +- .../base/gfirst-index-not-equal/docs/repl.txt | 17 ++- .../docs/types/index.d.ts | 12 +- .../gfirst-index-not-equal/lib/accessors.js | 6 +- .../base/gfirst-index-not-equal/lib/index.js | 2 +- .../base/gfirst-index-not-equal/lib/main.js | 6 +- .../gfirst-index-not-equal/lib/ndarray.js | 6 +- .../base/gfirst-index-not-equal/package.json | 2 +- .../gfirst-index-not-equal/test/test.main.js | 12 +- .../test/test.ndarray.js | 120 +++++++++--------- 10 files changed, 101 insertions(+), 90 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/README.md index 134951d415aa..74f2fbe09519 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/README.md @@ -20,7 +20,7 @@ limitations under the License. # gfirstIndexNotEqual -> Return the index of the first element in a strided array which is not equal to the corresponding element in another strided array. +> Return the index of the first element in a strided array which is not equal to a corresponding element in another strided array.
@@ -38,7 +38,7 @@ var gfirstIndexNotEqual = require( '@stdlib/blas/ext/base/gfirst-index-not-equal #### gfirstIndexNotEqual( N, x, strideX, y, strideY ) -Returns the index of the first element in a strided array which is not equal to the corresponding element in another strided array. +Returns the index of the first element in a strided array which is not equal to a corresponding element in another strided array. ```javascript var x = [ 0, 0, 1, 0 ]; @@ -56,7 +56,7 @@ The function has the following parameters: - **y**: second input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. - **strideY**: stride length for `y`. -If unable to find an element in `x` which is not equal to the corresponding element in `y`, the function returns `-1`. +If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. ```javascript var x = [ 0, 0, 0, 0 ]; @@ -95,7 +95,7 @@ var idx = gfirstIndexNotEqual( x1.length, x1, 1, y1, 1 ); #### gfirstIndexNotEqual.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) -Returns the index of the first element in a strided array which is not equal to the corresponding element in another strided array using alternative indexing semantics. +Returns the index of the first element in a strided array which is not equal to a corresponding element in another strided array using alternative indexing semantics. ```javascript var x = [ 0, 0, 1, 0 ]; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/repl.txt index fb1b3586817c..ef43901c7e2f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/repl.txt @@ -1,16 +1,15 @@ {{alias}}( N, x, strideX, y, strideY ) Returns the index of the first element in a strided array which is not - equal to the corresponding element in another strided array. + equal to a corresponding element in another strided array. - The `N` and stride parameters determine which elements in the strided - arrays are accessed at runtime. + The `N` and stride parameters determine which elements in the strided arrays + are accessed at runtime. - Indexing is relative to the first index. To introduce an offset, use - typed array views. + Indexing is relative to the first index. To introduce an offset, use a typed + array view. - If `N <= 0` or if unable to find an element in `x` which is not equal to - the corresponding element in `y`, the function returns `-1`. + If `N <= 0`, the function returns `-1`. Parameters ---------- @@ -58,8 +57,8 @@ {{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) Returns the index of the first element in a strided array which is not - equal to the corresponding element in another strided array using - alternative indexing semantics. + equal to a corresponding element in another strided array using alternative + indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/types/index.d.ts index d2912c974a27..9b5af48223d4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/types/index.d.ts @@ -32,11 +32,11 @@ type InputArray = Collection | AccessorArrayLike; */ interface Routine { /** - * Returns the index of the first element in a strided array which is not equal to the corresponding element in another strided array. + * Returns the index of the first element in a strided array which is not equal to a corresponding element in another strided array. * * ## Notes * - * - If unable to find an element in `x` which is not equal to the corresponding element in `y`, the function returns `-1`. + * - If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -55,11 +55,11 @@ interface Routine { ( N: number, x: InputArray, strideX: number, y: InputArray, strideY: number ): number; /** - * Returns the index of the first element in a strided array which is not equal to the corresponding element in another strided array using alternative indexing semantics. + * Returns the index of the first element in a strided array which is not equal to a corresponding element in another strided array using alternative indexing semantics. * * ## Notes * - * - If unable to find an element in `x` which is not equal to the corresponding element in `y`, the function returns `-1`. + * - If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -81,11 +81,11 @@ interface Routine { } /** -* Returns the index of the first element in a strided array which is not equal to the corresponding element in another strided array. +* Returns the index of the first element in a strided array which is not equal to a corresponding element in another strided array. * * ## Notes * -* - If unable to find an element in `x` which is not equal to the corresponding element in `y`, the function returns `-1`. +* - If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/accessors.js index bdecb9046ac9..1bf2653e69b1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/accessors.js @@ -21,7 +21,11 @@ // MAIN // /** -* Returns the index of the first element in a strided array which is not equal to the corresponding element in another strided array. +* Returns the index of the first element in a strided array which is not equal to a corresponding element in another strided array. +* +* ## Notes +* +* - If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. * * @private * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/index.js index 566db2a17318..f5fdfa3a7663 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Return the index of the first element in a strided array which is not equal to the corresponding element in another strided array. +* Return the index of the first element in a strided array which is not equal to a corresponding element in another strided array. * * @module @stdlib/blas/ext/base/gfirst-index-not-equal * diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/main.js index 4e4574936111..769467d83632 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/main.js @@ -27,7 +27,11 @@ var ndarray = require( './ndarray.js' ); // MAIN // /** -* Returns the index of the first element in a strided array which is not equal to the corresponding element in another strided array. +* Returns the index of the first element in a strided array which is not equal to a corresponding element in another strided array. +* +* ## Notes +* +* - If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/ndarray.js index e8c244bbc23c..636ee6d970bb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/lib/ndarray.js @@ -27,7 +27,11 @@ var accessors = require( './accessors.js' ); // MAIN // /** -* Returns the index of the first element in a strided array which is not equal to the corresponding element in another strided array using alternative indexing semantics. +* Returns the index of the first element in a strided array which is not equal to a corresponding element in another strided array using alternative indexing semantics. +* +* ## Notes +* +* - If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/package.json b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/package.json index 60594a62cec3..70fd6c07dcd8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/ext/base/gfirst-index-not-equal", "version": "0.0.0", - "description": "Return the index of the first element in a strided array which is not equal to the corresponding element in another strided array.", + "description": "Return the index of the first element in a strided array which is not equal to a corresponding element in another strided array.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/test/test.main.js index 1c040bfd9cb9..3b9533f90450 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/test/test.main.js @@ -39,7 +39,7 @@ tape( 'the function has an arity of 5', function test( t ) { t.end(); }); -tape( 'the function returns the index of the first element in `x` which is not equal to the corresponding element in `y`', function test( t ) { +tape( 'the function returns the first index of an element which is not equal to a corresponding element in another array', function test( t ) { var actual; var x; var y; @@ -59,7 +59,7 @@ tape( 'the function returns the index of the first element in `x` which is not e t.end(); }); -tape( 'the function returns the index of the first element in `x` which is not equal to the corresponding element in `y` (accessors)', function test( t ) { +tape( 'the function returns the first index of an element which is not equal to a corresponding element in another array (accessors)', function test( t ) { var actual; var x; var y; @@ -79,7 +79,7 @@ tape( 'the function returns the index of the first element in `x` which is not e t.end(); }); -tape( 'the function returns `-1` if every indexed element in `x` is equal to the corresponding element in `y`', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which is not equal to a corresponding element in another array', function test( t ) { var actual; var x; var y; @@ -93,7 +93,7 @@ tape( 'the function returns `-1` if every indexed element in `x` is equal to the t.end(); }); -tape( 'the function returns `-1` if every indexed element in `x` is equal to the corresponding element in `y` (accessors)', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which is not equal to a corresponding element in another array (accessors)', function test( t ) { var actual; var x; var y; @@ -107,7 +107,7 @@ tape( 'the function returns `-1` if every indexed element in `x` is equal to the t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; var y; @@ -124,7 +124,7 @@ tape( 'the function returns `-1` if provided an `N` parameter less than or equal t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; var x; var y; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/test/test.ndarray.js index d93e337a660b..6e04c175d1cf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/test/test.ndarray.js @@ -38,7 +38,7 @@ tape( 'the function has an arity of 7', function test( t ) { t.end(); }); -tape( 'the function returns the index of the first element in `x` which is not equal to the corresponding element in `y`', function test( t ) { +tape( 'the function returns the first index of an element which is not equal to a corresponding element in another array', function test( t ) { var actual; var x; var y; @@ -58,7 +58,7 @@ tape( 'the function returns the index of the first element in `x` which is not e t.end(); }); -tape( 'the function returns the index of the first element in `x` which is not equal to the corresponding element in `y` (accessors)', function test( t ) { +tape( 'the function returns the first index of an element which is not equal to a corresponding element in another array (accessors)', function test( t ) { var actual; var x; var y; @@ -78,7 +78,7 @@ tape( 'the function returns the index of the first element in `x` which is not e t.end(); }); -tape( 'the function returns `-1` if every indexed element in `x` is equal to the corresponding element in `y`', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which is not equal to a corresponding element in another array', function test( t ) { var actual; var x; var y; @@ -92,7 +92,7 @@ tape( 'the function returns `-1` if every indexed element in `x` is equal to the t.end(); }); -tape( 'the function returns `-1` if every indexed element in `x` is equal to the corresponding element in `y` (accessors)', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which is not equal to a corresponding element in another array (accessors)', function test( t ) { var actual; var x; var y; @@ -106,7 +106,7 @@ tape( 'the function returns `-1` if every indexed element in `x` is equal to the t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; var y; @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if provided an `N` parameter less than or equal t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; var x; var y; @@ -224,161 +224,161 @@ tape( 'the function supports an `x` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { +tape( 'the function supports a `y` stride', function test( t ) { var actual; var x; var y; - x = [ - 9.0, + x = [ 0.0, 0.0, 1.0 ]; + y = [ 0.0, // 0 9.0, 0.0, // 1 9.0, - 1.0 // 2 - ]; - y = [ - 0.0, // 0 - 0.0, // 1 0.0 // 2 ]; - actual = gfirstIndexNotEqual( 3, x, 2, 1, y, 1, 0 ); + actual = gfirstIndexNotEqual( 3, x, 1, 0, y, 2, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports an `x` offset (accessors)', function test( t ) { +tape( 'the function supports a `y` stride (accessors)', function test( t ) { var actual; var x; var y; - x = [ - 9.0, + x = [ 0.0, 0.0, 1.0 ]; + y = [ 0.0, // 0 9.0, 0.0, // 1 9.0, - 1.0 // 2 - ]; - y = [ - 0.0, // 0 - 0.0, // 1 0.0 // 2 ]; - actual = gfirstIndexNotEqual( 3, toAccessorArray( x ), 2, 1, toAccessorArray( y ), 1, 0 ); // eslint-disable-line max-len + actual = gfirstIndexNotEqual( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 2, 0 ); // eslint-disable-line max-len t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports a `y` stride', function test( t ) { +tape( 'the function supports negative strides', function test( t ) { var actual; var x; var y; - x = [ 0.0, 0.0, 1.0 ]; - y = [ - 0.0, // 0 - 9.0, - 0.0, // 1 - 9.0, - 0.0 // 2 - ]; + x = [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ]; + y = [ 5.0, 4.0, 3.0, 9.0, 1.0, 0.0 ]; - actual = gfirstIndexNotEqual( 3, x, 1, 0, y, 2, 0 ); + actual = gfirstIndexNotEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); // eslint-disable-line max-len t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports a `y` stride (accessors)', function test( t ) { +tape( 'the function supports negative strides (accessors)', function test( t ) { var actual; var x; var y; - x = [ 0.0, 0.0, 1.0 ]; - y = [ - 0.0, // 0 - 9.0, - 0.0, // 1 - 9.0, - 0.0 // 2 - ]; + x = [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ]; + y = [ 5.0, 4.0, 3.0, 9.0, 1.0, 0.0 ]; - actual = gfirstIndexNotEqual( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 2, 0 ); // eslint-disable-line max-len + actual = gfirstIndexNotEqual( x.length, toAccessorArray( x ), -1, x.length-1, toAccessorArray( y ), -1, y.length-1 ); // eslint-disable-line max-len t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports a `y` offset', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; var x; var y; - x = [ 0.0, 0.0, 1.0 ]; - y = [ + x = [ 9.0, 0.0, // 0 9.0, 0.0, // 1 9.0, + 1.0 // 2 + ]; + y = [ + 0.0, // 0 + 0.0, // 1 0.0 // 2 ]; - actual = gfirstIndexNotEqual( 3, x, 1, 0, y, 2, 1 ); + actual = gfirstIndexNotEqual( 3, x, 2, 1, y, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports a `y` offset (accessors)', function test( t ) { +tape( 'the function supports an `x` offset (accessors)', function test( t ) { var actual; var x; var y; - x = [ 0.0, 0.0, 1.0 ]; - y = [ + x = [ 9.0, 0.0, // 0 9.0, 0.0, // 1 9.0, + 1.0 // 2 + ]; + y = [ + 0.0, // 0 + 0.0, // 1 0.0 // 2 ]; - actual = gfirstIndexNotEqual( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 2, 1 ); // eslint-disable-line max-len + actual = gfirstIndexNotEqual( 3, toAccessorArray( x ), 2, 1, toAccessorArray( y ), 1, 0 ); // eslint-disable-line max-len t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a `y` offset', function test( t ) { var actual; var x; var y; - x = [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ]; - y = [ 5.0, 4.0, 3.0, 9.0, 1.0, 0.0 ]; + x = [ 0.0, 0.0, 1.0 ]; + y = [ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 0.0 // 2 + ]; - actual = gfirstIndexNotEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); // eslint-disable-line max-len + actual = gfirstIndexNotEqual( 3, x, 1, 0, y, 2, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a `y` offset (accessors)', function test( t ) { var actual; var x; var y; - x = [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ]; - y = [ 5.0, 4.0, 3.0, 9.0, 1.0, 0.0 ]; + x = [ 0.0, 0.0, 1.0 ]; + y = [ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 0.0 // 2 + ]; - actual = gfirstIndexNotEqual( x.length, toAccessorArray( x ), -1, x.length-1, toAccessorArray( y ), -1, y.length-1 ); // eslint-disable-line max-len + actual = gfirstIndexNotEqual( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 2, 1 ); // eslint-disable-line max-len t.strictEqual( actual, 2, 'returns expected value' ); t.end(); From 55bae325cfedd95661e147c2cb7267ff81e5246f Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:03:40 +0500 Subject: [PATCH 26/68] fix: refactor `gfirst-index-almost-same-value` --- .../test/test.main.js | 32 +++++++++++++++-- .../test/test.ndarray.js | 36 ++++++++++++++++--- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/test/test.main.js index a1d4309bdeb3..6aec5b8d12e4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/test/test.main.js @@ -256,7 +256,7 @@ tape( 'the function treats `NaN` values as the same (accessors)', function test( t.end(); }); -tape( 'the function treats -0 and +0 as distinct', function test( t ) { +tape( 'the function treats `-0` and `+0` as distinct', function test( t ) { var actual; actual = gfirstIndexAlmostSameValue( 1, 0, [ -0.0 ], 1, [ 0.0 ], 1 ); @@ -265,7 +265,7 @@ tape( 'the function treats -0 and +0 as distinct', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as distinct (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as distinct (accessors)', function test( t ) { var actual; actual = gfirstIndexAlmostSameValue( 1, 0, toAccessorArray( [ -0.0 ] ), 1, toAccessorArray( [ 0.0 ] ), 1 ); @@ -458,6 +458,34 @@ tape( 'the function supports complex access patterns', function test( t ) { t.end(); }); +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 5.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0, + 0.0 + ]; + + actual = gfirstIndexAlmostSameValue( 3, 1, toAccessorArray( x ), 2, toAccessorArray( y ), -1 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var actual; var x0; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/test/test.ndarray.js index 424a083e93c2..56fefb24d1f9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/test/test.ndarray.js @@ -207,7 +207,7 @@ tape( 'the function supports specifying a maximum allowed ULP difference (access t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gfirstIndexAlmostSameValue( 0, 1, [ 1.0, 2.0, 3.0 ], 1, 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); @@ -219,7 +219,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gfirstIndexAlmostSameValue( 0, 1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -255,7 +255,7 @@ tape( 'the function treats `NaN` values as the same (accessors)', function test( t.end(); }); -tape( 'the function treats -0 and +0 as distinct', function test( t ) { +tape( 'the function treats `-0` and `+0` as distinct', function test( t ) { var actual; actual = gfirstIndexAlmostSameValue( 1, 0, [ -0.0 ], 1, 0, [ 0.0 ], 1, 0 ); @@ -264,7 +264,7 @@ tape( 'the function treats -0 and +0 as distinct', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as distinct (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as distinct (accessors)', function test( t ) { var actual; actual = gfirstIndexAlmostSameValue( 1, 0, toAccessorArray( [ -0.0 ] ), 1, 0, toAccessorArray( [ 0.0 ] ), 1, 0 ); @@ -584,3 +584,31 @@ tape( 'the function supports complex access patterns', function test( t ) { t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); + +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 5.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0, + 0.0 + ]; + + actual = gfirstIndexAlmostSameValue( 3, 1, toAccessorArray( x ), 2, 0, toAccessorArray( y ), -1, 2 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); From bc0810a83366e49d47354eccf12d4da6aea76fda Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:17:02 +0500 Subject: [PATCH 27/68] fix: refactor `last-index-equal` --- .../blas/ext/base/dlast-index-equal/README.md | 2 +- .../dlast-index-equal/docs/types/index.d.ts | 4 +- .../lib/dlast_index_equal.js | 4 + .../ext/base/dlast-index-equal/lib/ndarray.js | 4 + .../test/test.dlast_index_equal.js | 4 +- .../test/test.dlast_index_equal.native.js | 4 +- .../dlast-index-equal/test/test.ndarray.js | 52 ++++++- .../test/test.ndarray.native.js | 52 ++++++- .../ext/base/glast-index-equal/lib/main.js | 4 + .../ext/base/glast-index-equal/lib/ndarray.js | 4 + .../base/glast-index-equal/test/test.main.js | 36 ++++- .../glast-index-equal/test/test.ndarray.js | 136 +++++++++++++++++- .../blas/ext/base/slast-index-equal/README.md | 2 +- .../slast-index-equal/docs/types/index.d.ts | 4 +- .../ext/base/slast-index-equal/lib/ndarray.js | 4 + .../lib/slast_index_equal.js | 4 + .../slast-index-equal/test/test.ndarray.js | 52 ++++++- .../test/test.ndarray.native.js | 52 ++++++- .../test/test.slast_index_equal.js | 4 +- .../test/test.slast_index_equal.native.js | 4 +- 20 files changed, 400 insertions(+), 32 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/README.md index 3f3fde33d301..64e30535dee1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/README.md @@ -62,7 +62,7 @@ The function has the following parameters: - **y**: second input [`Float64Array`][@stdlib/array/float64]. - **strideY**: stride length for `y`. -If the function is unable to find a match, the function returns `-1`. +If the function is unable to find matching elements, the function returns `-1`. ```javascript var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/types/index.d.ts index f45a739cd508..fbc5246edd63 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find matching elements, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -52,7 +52,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find matching elements, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.js index 585b9c5054eb..d566808146ab 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the last element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.js index ac2e6451aa84..3062c54a35bb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.js @@ -28,6 +28,10 @@ var dfirstIndexEqual = require( '@stdlib/blas/ext/base/dfirst-index-equal' ).nda /** * Returns the index of the last element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.js index 5904bec953b2..9a4df885b11d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.js @@ -114,7 +114,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ NaN ] ), 1, new Float64Array( [ NaN ] ), 1 ); @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, new Float64Array( [ 0.0 ] ), 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.native.js index e3b612ce564f..cb78b279e026 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.native.js @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ NaN ] ), 1, new Float64Array( [ NaN ] ), 1 ); @@ -132,7 +132,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, new Float64Array( [ 0.0 ] ), 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js index 2ce5c1a534a6..0f3ef61ef126 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js @@ -114,7 +114,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ NaN ] ), 1, 0, new Float64Array( [ NaN ] ), 1, 0 ); @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, 0, new Float64Array( [ 0.0 ] ), 1, 0 ); @@ -210,6 +210,54 @@ tape( 'the function supports negative strides', function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 5.0, + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 4.0, // 2 + 0.0 + ]); + + actual = dlastIndexEqual( 3, x, 1, 1, y, 1, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 0.0 + ]); + y = new Float64Array([ + 0.0, + 6.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = dlastIndexEqual( 3, x, 1, 0, y, 1, 1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports complex access patterns', function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js index 84bd9056df0c..2986f4f1a340 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ NaN ] ), 1, 0, new Float64Array( [ NaN ] ), 1, 0 ); @@ -132,7 +132,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, 0, new Float64Array( [ 0.0 ] ), 1, 0 ); @@ -219,6 +219,54 @@ tape( 'the function supports negative strides', opts, function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 5.0, + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 4.0, // 2 + 0.0 + ]); + + actual = dlastIndexEqual( 3, x, 1, 1, y, 1, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 0.0 + ]); + y = new Float64Array([ + 0.0, + 6.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = dlastIndexEqual( 3, x, 1, 0, y, 1, 1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports complex access patterns', opts, function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/lib/main.js index 84c927d2de7a..f62d9bfdd295 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/lib/main.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the last element in a strided array equal to a corresponding element in another strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/lib/ndarray.js index aa20112736b8..4e54d7ac7714 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/lib/ndarray.js @@ -28,6 +28,10 @@ var gfirstIndexEqual = require( '@stdlib/blas/ext/base/gfirst-index-equal' ).nda /** * Returns the index of the last element in a strided array equal to a corresponding element in another strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/test/test.main.js index 74f2f1c1a9cd..9d7d9e17d102 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/test/test.main.js @@ -185,7 +185,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = glastIndexEqual( 1, [ NaN ], 1, [ NaN ], 1 ); @@ -194,7 +194,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN`', f t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN` (accessors)', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors)', function test( t ) { var actual; actual = glastIndexEqual( 1, toAccessorArray( [ NaN ] ), 1, toAccessorArray( [ NaN ] ), 1 ); @@ -203,7 +203,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN` (ac t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = glastIndexEqual( 1, [ -0.0 ], 1, [ 0.0 ], 1 ); @@ -212,7 +212,7 @@ tape( 'the function treats -0 and +0 as equal', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = glastIndexEqual( 1, toAccessorArray( [ -0.0 ] ), 1, toAccessorArray( [ 0.0 ] ), 1 ); @@ -405,6 +405,34 @@ tape( 'the function supports complex access patterns', function test( t ) { t.end(); }); +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 5.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0, + 0.0 + ]; + + actual = glastIndexEqual( 3, toAccessorArray( x ), 2, toAccessorArray( y ), -1 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var actual; var x0; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/test/test.ndarray.js index 5966a6b45af9..b38672ee57bc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/test/test.ndarray.js @@ -160,7 +160,7 @@ tape( 'the function returns the last index of an element which equals a correspo t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = glastIndexEqual( 0, [ 1.0, 2.0, 3.0 ], 1, 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); @@ -172,7 +172,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = glastIndexEqual( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -184,7 +184,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = glastIndexEqual( 1, [ NaN ], 1, 0, [ NaN ], 1, 0 ); @@ -193,7 +193,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN`', f t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN` (accessors)', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors)', function test( t ) { var actual; actual = glastIndexEqual( 1, toAccessorArray( [ NaN ] ), 1, 0, toAccessorArray( [ NaN ] ), 1, 0 ); @@ -202,7 +202,7 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN` (ac t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = glastIndexEqual( 1, [ -0.0 ], 1, 0, [ 0.0 ], 1, 0 ); @@ -211,7 +211,7 @@ tape( 'the function treats -0 and +0 as equal', function test( t ) { t.end(); }); -tape( 'the function treats -0 and +0 as equal (accessors)', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal (accessors)', function test( t ) { var actual; actual = glastIndexEqual( 1, toAccessorArray( [ -0.0 ] ), 1, 0, toAccessorArray( [ 0.0 ] ), 1, 0 ); @@ -376,6 +376,102 @@ tape( 'the function supports negative strides (accessors)', function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + var y; + + x = [ + 5.0, + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]; + y = [ + 6.0, // 0 + 1.0, // 1 + 4.0, // 2 + 0.0 + ]; + + actual = glastIndexEqual( 3, x, 1, 1, y, 1, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 5.0, + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]; + y = [ + 6.0, // 0 + 1.0, // 1 + 4.0, // 2 + 0.0 + ]; + + actual = glastIndexEqual( 3, toAccessorArray( x ), 1, 1, toAccessorArray( y ), 1, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var actual; + var x; + var y; + + x = [ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 0.0 + ]; + y = [ + 0.0, + 6.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]; + + actual = glastIndexEqual( 3, x, 1, 0, y, 1, 1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 0.0 + ]; + y = [ + 0.0, + 6.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]; + + actual = glastIndexEqual( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports complex access patterns', function test( t ) { var actual; var x; @@ -403,3 +499,31 @@ tape( 'the function supports complex access patterns', function test( t ) { t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); + +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 5.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0, + 0.0 + ]; + + actual = glastIndexEqual( 3, toAccessorArray( x ), 2, 0, toAccessorArray( y ), -1, 2 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/README.md index 098032285827..632578675bb6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/README.md @@ -62,7 +62,7 @@ The function has the following parameters: - **y**: second input [`Float32Array`][@stdlib/array/float32]. - **strideY**: stride length for `y`. -If the function is unable to find a match, the function returns `-1`. +If the function is unable to find matching elements, the function returns `-1`. ```javascript var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/docs/types/index.d.ts index ee974671a7e5..ee8138f5273f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find matching elements, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -52,7 +52,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find matching elements, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/ndarray.js index b65ba1709033..e399c13b0574 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/ndarray.js @@ -28,6 +28,10 @@ var sfirstIndexEqual = require( '@stdlib/blas/ext/base/sfirst-index-equal' ).nda /** * Returns the index of the last element in a single-precision floating-point strided array equal to a corresponding element in another single-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/slast_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/slast_index_equal.js index 8fac8d2505b1..12f01c7e28bb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/slast_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/slast_index_equal.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the last element in a single-precision floating-point strided array equal to a corresponding element in another single-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.js index 5746f708dac5..088c698a7533 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.js @@ -114,7 +114,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = slastIndexEqual( 1, new Float32Array( [ NaN ] ), 1, 0, new Float32Array( [ NaN ] ), 1, 0 ); @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = slastIndexEqual( 1, new Float32Array( [ -0.0 ] ), 1, 0, new Float32Array( [ 0.0 ] ), 1, 0 ); @@ -210,6 +210,54 @@ tape( 'the function supports negative strides', function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 5.0, + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float32Array([ + 6.0, // 0 + 1.0, // 1 + 4.0, // 2 + 0.0 + ]); + + actual = slastIndexEqual( 3, x, 1, 1, y, 1, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 0.0 + ]); + y = new Float32Array([ + 0.0, + 6.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = slastIndexEqual( 3, x, 1, 0, y, 1, 1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports complex access patterns', function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.native.js index d7c98404d0c8..ae7660c10461 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.native.js @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = slastIndexEqual( 1, new Float32Array( [ NaN ] ), 1, 0, new Float32Array( [ NaN ] ), 1, 0 ); @@ -132,7 +132,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = slastIndexEqual( 1, new Float32Array( [ -0.0 ] ), 1, 0, new Float32Array( [ 0.0 ] ), 1, 0 ); @@ -219,6 +219,54 @@ tape( 'the function supports negative strides', opts, function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 5.0, + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float32Array([ + 6.0, // 0 + 1.0, // 1 + 4.0, // 2 + 0.0 + ]); + + actual = slastIndexEqual( 3, x, 1, 1, y, 1, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 0.0 + ]); + y = new Float32Array([ + 0.0, + 6.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = slastIndexEqual( 3, x, 1, 0, y, 1, 1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports complex access patterns', opts, function test( t ) { var actual; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.slast_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.slast_index_equal.js index 25e6451b8e61..914fb99cacd9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.slast_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.slast_index_equal.js @@ -114,7 +114,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = slastIndexEqual( 1, new Float32Array( [ NaN ] ), 1, new Float32Array( [ NaN ] ), 1 ); @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = slastIndexEqual( 1, new Float32Array( [ -0.0 ] ), 1, new Float32Array( [ 0.0 ] ), 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.slast_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.slast_index_equal.native.js index de384d518b05..8fa7066971a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.slast_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.slast_index_equal.native.js @@ -123,7 +123,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = slastIndexEqual( 1, new Float32Array( [ NaN ] ), 1, new Float32Array( [ NaN ] ), 1 ); @@ -132,7 +132,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = slastIndexEqual( 1, new Float32Array( [ -0.0 ] ), 1, new Float32Array( [ 0.0 ] ), 1 ); From cc2b4304c7454539a0af92c0b4ed1dd2794bfea3 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:17:03 +0500 Subject: [PATCH 28/68] fix: refactor `glast-index-less-than` --- .../glast-index-less-than/test/test.main.js | 4 +- .../test/test.ndarray.js | 96 +++++++++---------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-less-than/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-less-than/test/test.main.js index acc6e0698a32..d07f2a8ce8b8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-less-than/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-less-than/test/test.main.js @@ -161,7 +161,7 @@ tape( 'the function returns the last index of an element which is less than a co t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = glastIndexLessThan( 0, [ 1.0, 2.0, 3.0 ], 1, [ 1.0, 2.0, 3.0 ], 1 ); @@ -173,7 +173,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = glastIndexLessThan( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-less-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-less-than/test/test.ndarray.js index e6b965c2167b..6ab1cc099225 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-less-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-less-than/test/test.ndarray.js @@ -160,7 +160,7 @@ tape( 'the function returns the last index of an element which is less than a co t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = glastIndexLessThan( 0, [ 1.0, 2.0, 3.0 ], 1, 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); @@ -172,7 +172,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = glastIndexLessThan( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -330,149 +330,149 @@ tape( 'the function supports a `y` stride (accessors)', function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { +tape( 'the function supports negative strides', function test( t ) { var actual; var x; var y; x = [ - 5.0, - 6.0, // 0 + 6.0, // 2 + 2.0, 1.0, // 1 - 5.0 // 2 + 4.0, + 5.0 // 0 ]; y = [ - 5.0, // 0 + 3.0, // 2 2.0, // 1 - 4.0, // 2 + 5.0, // 0 + 0.0, 0.0 ]; - actual = glastIndexLessThan( 3, x, 1, 1, y, 1, 0 ); + actual = glastIndexLessThan( 3, x, -2, 4, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an `x` offset (accessors)', function test( t ) { +tape( 'the function supports negative strides (accessors)', function test( t ) { var actual; var x; var y; x = [ - 5.0, - 6.0, // 0 + 6.0, // 2 + 2.0, 1.0, // 1 - 5.0 // 2 + 4.0, + 5.0 // 0 ]; y = [ - 5.0, // 0 + 3.0, // 2 2.0, // 1 - 4.0, // 2 + 5.0, // 0 + 0.0, 0.0 ]; - actual = glastIndexLessThan( 3, toAccessorArray( x ), 1, 1, toAccessorArray( y ), 1, 0 ); + actual = glastIndexLessThan( 3, toAccessorArray( x ), -2, 4, toAccessorArray( y ), -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports a `y` offset', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; var x; var y; x = [ + 5.0, 6.0, // 0 1.0, // 1 - 5.0, // 2 - 0.0 + 5.0 // 2 ]; y = [ - 0.0, 5.0, // 0 2.0, // 1 - 4.0 // 2 + 4.0, // 2 + 0.0 ]; - actual = glastIndexLessThan( 3, x, 1, 0, y, 1, 1 ); + actual = glastIndexLessThan( 3, x, 1, 1, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports a `y` offset (accessors)', function test( t ) { +tape( 'the function supports an `x` offset (accessors)', function test( t ) { var actual; var x; var y; x = [ + 5.0, 6.0, // 0 1.0, // 1 - 5.0, // 2 - 0.0 + 5.0 // 2 ]; y = [ - 0.0, 5.0, // 0 2.0, // 1 - 4.0 // 2 + 4.0, // 2 + 0.0 ]; - actual = glastIndexLessThan( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 1 ); + actual = glastIndexLessThan( 3, toAccessorArray( x ), 1, 1, toAccessorArray( y ), 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a `y` offset', function test( t ) { var actual; var x; var y; x = [ - 6.0, // 2 - 2.0, + 6.0, // 0 1.0, // 1 - 4.0, - 5.0 // 0 + 5.0, // 2 + 0.0 ]; y = [ - 3.0, // 2 - 2.0, // 1 - 5.0, // 0 0.0, - 0.0 + 5.0, // 0 + 2.0, // 1 + 4.0 // 2 ]; - actual = glastIndexLessThan( 3, x, -2, 4, y, -1, 2 ); + actual = glastIndexLessThan( 3, x, 1, 0, y, 1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides (accessors)', function test( t ) { +tape( 'the function supports a `y` offset (accessors)', function test( t ) { var actual; var x; var y; x = [ - 6.0, // 2 - 2.0, + 6.0, // 0 1.0, // 1 - 4.0, - 5.0 // 0 + 5.0, // 2 + 0.0 ]; y = [ - 3.0, // 2 - 2.0, // 1 - 5.0, // 0 0.0, - 0.0 + 5.0, // 0 + 2.0, // 1 + 4.0 // 2 ]; - actual = glastIndexLessThan( 3, toAccessorArray( x ), -2, 4, toAccessorArray( y ), -1, 2 ); + actual = glastIndexLessThan( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); From 30f128d66bd3bed4346fde49a738c6ca59b47aa6 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:17:04 +0500 Subject: [PATCH 29/68] fix: refactor `glast-index-not-equal` --- .../ext/base/glast-index-not-equal/README.md | 8 +- .../base/glast-index-not-equal/docs/repl.txt | 4 +- .../docs/types/index.d.ts | 12 +- .../base/glast-index-not-equal/lib/index.js | 2 +- .../base/glast-index-not-equal/lib/main.js | 6 +- .../base/glast-index-not-equal/lib/ndarray.js | 6 +- .../base/glast-index-not-equal/package.json | 2 +- .../glast-index-not-equal/test/test.main.js | 30 +++- .../test/test.ndarray.js | 130 +++++++++++++++++- 9 files changed, 178 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/README.md index 9e66d297bd50..65129ce4cbff 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/README.md @@ -20,7 +20,7 @@ limitations under the License. # glastIndexNotEqual -> Return the index of the last element in a strided array which is not equal to the corresponding element in another strided array. +> Return the index of the last element in a strided array which is not equal to a corresponding element in another strided array.
@@ -38,7 +38,7 @@ var glastIndexNotEqual = require( '@stdlib/blas/ext/base/glast-index-not-equal' #### glastIndexNotEqual( N, x, strideX, y, strideY ) -Returns the index of the last element in a strided array which is not equal to the corresponding element in another strided array. +Returns the index of the last element in a strided array which is not equal to a corresponding element in another strided array. ```javascript var x = [ 1.0, 2.0, 3.0, 4.0 ]; @@ -56,7 +56,7 @@ The function has the following parameters: - **y**: second input array. - **strideY**: stride length for `y`. -If unable to find an element in `x` which is not equal to the corresponding element in `y`, the function returns `-1`. +If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. ```javascript var x = [ 0.0, 0.0, 0.0, 0.0 ]; @@ -95,7 +95,7 @@ var idx = glastIndexNotEqual( x1.length, x1, 1, y1, 1 ); #### glastIndexNotEqual.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) -Returns the index of the last element in a strided array which is not equal to the corresponding element in another strided array using alternative indexing semantics. +Returns the index of the last element in a strided array which is not equal to a corresponding element in another strided array using alternative indexing semantics. ```javascript var x = [ 1.0, 2.0, 3.0, 4.0 ]; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/repl.txt index 50c426350031..9a23897e82c7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( N, x, strideX, y, strideY ) Returns the index of the last element in a strided array which is not equal - to the corresponding element in another strided array. + to a corresponding element in another strided array. The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. @@ -58,7 +58,7 @@ {{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) Returns the index of the last element in a strided array which is not equal - to the corresponding element in another strided array using alternative + to a corresponding element in another strided array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/types/index.d.ts index 978dadfffd04..67797795f40f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/types/index.d.ts @@ -32,11 +32,11 @@ type InputArray = Collection | AccessorArrayLike; */ interface Routine { /** - * Returns the index of the last element in a strided array which is not equal to the corresponding element in another strided array. + * Returns the index of the last element in a strided array which is not equal to a corresponding element in another strided array. * * ## Notes * - * - If unable to find an element in `x` which is not equal to the corresponding element in `y`, the function returns `-1`. + * - If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -55,11 +55,11 @@ interface Routine { ( N: number, x: InputArray, strideX: number, y: InputArray, strideY: number ): number; /** - * Returns the index of the last element in a strided array which is not equal to the corresponding element in another strided array using alternative indexing semantics. + * Returns the index of the last element in a strided array which is not equal to a corresponding element in another strided array using alternative indexing semantics. * * ## Notes * - * - If unable to find an element in `x` which is not equal to the corresponding element in `y`, the function returns `-1`. + * - If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -81,11 +81,11 @@ interface Routine { } /** -* Returns the index of the last element in a strided array which is not equal to the corresponding element in another strided array. +* Returns the index of the last element in a strided array which is not equal to a corresponding element in another strided array. * * ## Notes * -* - If unable to find an element in `x` which is not equal to the corresponding element in `y`, the function returns `-1`. +* - If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/index.js index 9de95a174062..9be8b7c783d7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Return the index of the last element in a strided array which is not equal to the corresponding element in another strided array. +* Return the index of the last element in a strided array which is not equal to a corresponding element in another strided array. * * @module @stdlib/blas/ext/base/glast-index-not-equal * diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/main.js index 5de62b5bb6f9..781f5a65a795 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/main.js @@ -27,7 +27,11 @@ var ndarray = require( './ndarray.js' ); // MAIN // /** -* Returns the index of the last element in a strided array which is not equal to the corresponding element in another strided array. +* Returns the index of the last element in a strided array which is not equal to a corresponding element in another strided array. +* +* ## Notes +* +* - If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/ndarray.js index 2c324a3ad2e5..2ebf8a444b46 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/lib/ndarray.js @@ -26,7 +26,11 @@ var gfirstIndexNotEqual = require( '@stdlib/blas/ext/base/gfirst-index-not-equal // MAIN // /** -* Returns the index of the last element in a strided array which is not equal to the corresponding element in another strided array using alternative indexing semantics. +* Returns the index of the last element in a strided array which is not equal to a corresponding element in another strided array using alternative indexing semantics. +* +* ## Notes +* +* - If the function is unable to find an element in `x` which is not equal to a corresponding element in `y`, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - first input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/package.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/package.json index 82bf1f570685..b4f6eaa67bbc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/ext/base/glast-index-not-equal", "version": "0.0.0", - "description": "Return the index of the last element in a strided array which is not equal to the corresponding element in another strided array.", + "description": "Return the index of the last element in a strided array which is not equal to a corresponding element in another strided array.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/test/test.main.js index 3d0aa5d73ac7..2f9a21287311 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/test/test.main.js @@ -67,7 +67,7 @@ tape( 'the function returns the last index of an element which is not equal to a t.end(); }); -tape( 'the function returns `-1` if every indexed element in `x` is equal to the corresponding element in `y`', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which is not equal to a corresponding element in another array', function test( t ) { var actual; var x; var y; @@ -81,7 +81,7 @@ tape( 'the function returns `-1` if every indexed element in `x` is equal to the t.end(); }); -tape( 'the function returns `-1` if every indexed element in `x` is equal to the corresponding element in `y` (accessors)', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which is not equal to a corresponding element in another array (accessors)', function test( t ) { var actual; var x; var y; @@ -305,6 +305,32 @@ tape( 'the function supports complex access patterns', function test( t ) { t.end(); }); +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; + y = [ + 0.0, // 2 + 0.0, // 1 + 0.0, // 0 + 9.0, + 9.0 + ]; + + actual = glastIndexNotEqual( 3, toAccessorArray( x ), 2, toAccessorArray( y ), -1 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var actual; var x0; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/test/test.ndarray.js index 283ee4a7d604..f5d5a334b044 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/test/test.ndarray.js @@ -66,7 +66,7 @@ tape( 'the function returns the last index of an element which is not equal to a t.end(); }); -tape( 'the function returns `-1` if every indexed element in `x` is equal to the corresponding element in `y`', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which is not equal to a corresponding element in another array', function test( t ) { var actual; var x; var y; @@ -80,7 +80,7 @@ tape( 'the function returns `-1` if every indexed element in `x` is equal to the t.end(); }); -tape( 'the function returns `-1` if every indexed element in `x` is equal to the corresponding element in `y` (accessors)', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which is not equal to a corresponding element in another array (accessors)', function test( t ) { var actual; var x; var y; @@ -94,7 +94,7 @@ tape( 'the function returns `-1` if every indexed element in `x` is equal to the t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = glastIndexNotEqual( 0, [ 1.0, 2.0, 3.0 ], 1, 0, [ 4.0, 5.0, 6.0 ], 1, 0 ); @@ -106,7 +106,7 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = glastIndexNotEqual( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0, toAccessorArray( [ 4.0, 5.0, 6.0 ] ), 1, 0 ); @@ -302,6 +302,102 @@ tape( 'the function supports negative strides (accessors)', function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + var y; + + x = [ + 5.0, + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]; + y = [ + 6.0, // 0 + 1.0, // 1 + 4.0, // 2 + 0.0 + ]; + + actual = glastIndexNotEqual( 3, x, 1, 1, y, 1, 0 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 5.0, + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]; + y = [ + 6.0, // 0 + 1.0, // 1 + 4.0, // 2 + 0.0 + ]; + + actual = glastIndexNotEqual( 3, toAccessorArray( x ), 1, 1, toAccessorArray( y ), 1, 0 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var actual; + var x; + var y; + + x = [ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 0.0 + ]; + y = [ + 0.0, + 6.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]; + + actual = glastIndexNotEqual( 3, x, 1, 0, y, 1, 1 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 0.0 + ]; + y = [ + 0.0, + 6.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]; + + actual = glastIndexNotEqual( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 1 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports complex access patterns', function test( t ) { var actual; var x; @@ -327,3 +423,29 @@ tape( 'the function supports complex access patterns', function test( t ) { t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); + +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; + y = [ + 0.0, // 2 + 0.0, // 1 + 0.0, // 0 + 9.0, + 9.0 + ]; + + actual = glastIndexNotEqual( 3, toAccessorArray( x ), 2, 0, toAccessorArray( y ), -1, 2 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); From 289d39b042de43ad814a83f68ab74e6d794c246f Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:34:36 +0500 Subject: [PATCH 30/68] fix: refactor `gfind-index` --- .../blas/ext/base/gfind-index/README.md | 2 +- .../blas/ext/base/gfind-index/docs/repl.txt | 19 +- .../base/gfind-index/docs/types/index.d.ts | 6 +- .../ext/base/gfind-index/lib/accessors.js | 4 + .../blas/ext/base/gfind-index/lib/main.js | 4 + .../blas/ext/base/gfind-index/lib/ndarray.js | 6 +- .../ext/base/gfind-index/test/test.main.js | 169 +++++++++++++-- .../ext/base/gfind-index/test/test.ndarray.js | 204 ++++++++++++++++-- 8 files changed, 370 insertions(+), 44 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/README.md index d19d7efb767c..f7a5af3a9dbb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/README.md @@ -45,7 +45,7 @@ var idx = gfindIndex( x.length, x, 1, isEven ); // returns 3 ``` -If no element passes a test implemented by a predicate function, the function returns `-1`. +If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. ```javascript function isEven( v ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/docs/repl.txt index 3011a40e41a0..f3c5dbe2d903 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/docs/repl.txt @@ -6,11 +6,10 @@ The `N` and stride parameters determine which elements in the strided array are accessed at runtime. - Indexing is relative to the first index. To introduce an offset, use typed - array views. + Indexing is relative to the first index. To introduce an offset, use a typed + array view. - If `N <= 0` or no element passes a test implemented by a predicate function, - the function returns `-1`. + If `N <= 0`, the function returns `-1`. The callback function is provided the following arguments: @@ -43,7 +42,7 @@ Examples -------- - // Standard Usage: + // Standard usage: > function f( v ) { return v % 2.0 === 0.0; }; > var x = [ 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; > {{alias}}( x.length, x, 1, f ) @@ -51,7 +50,7 @@ // Using `N` and stride parameters: > x = [ 1.0, 3.0, 4.0, -5.0, -1.0, -3.0 ]; - > {{alias}}( x.length, x, 2, f ) + > {{alias}}( 3, x, 2, f ) 1 // Using view offsets: @@ -96,9 +95,15 @@ Examples -------- + // Standard usage: > function f( v ) { return v % 2.0 === 0.0; }; > var x = [ 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; - > {{alias}}.ndarray( x.length, x, 1, 2, f ) + > {{alias}}.ndarray( x.length, x, 1, 0, f ) + 3 + + // Using an index offset: + > x = [ 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ]; + > {{alias}}.ndarray( 3, x, 2, 1, f ) 1 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/docs/types/index.d.ts index f09df89d479c..13feaeedb44f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/docs/types/index.d.ts @@ -99,7 +99,7 @@ interface Routine { * - `sidx`: strided index (offset + aidx*stride) * - `array`: input array * - * - If no element passes a test implemented by a predicate function, the function returns `-1`. + * - If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. * * @param N - number of indexed elements * @param x - input array @@ -132,7 +132,7 @@ interface Routine { * - `sidx`: strided index (offset + aidx*stride) * - `array`: input array * - * - If no element passes a test implemented by a predicate function, the function returns `-1`. + * - If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. * * @param N - number of indexed elements * @param x - input array @@ -167,7 +167,7 @@ interface Routine { * - `sidx`: strided index (offset + aidx*stride) * - `array`: input array * -* - If no element passes a test implemented by a predicate function, the function returns `-1`. +* - If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. * * @param N - number of indexed elements * @param x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/accessors.js index f24bce7b73ba..7f80b483f98f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/accessors.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element which passes a test implemented by a predicate function. * +* ## Notes +* +* - If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. +* * @private * @param {PositiveInteger} N - number of indexed elements * @param {Object} x - input array object diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/main.js index 30f2c7f3db78..50cc6b07b3b4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/main.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element which passes a test implemented by a predicate function. * +* ## Notes +* +* - If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array * @param {integer} strideX - stride length diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/ndarray.js index e528e3d7201c..08bf7ca58fd5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/lib/ndarray.js @@ -27,7 +27,11 @@ var accessors = require( './accessors.js' ); // MAIN // /** -* Returns the index of the first element which passes a test implemented by a predicate function. +* Returns the index of the first element which passes a test implemented by a predicate function using alternative indexing semantics. +* +* ## Notes +* +* - If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/test/test.main.js index 9eb9e8d8bc27..c9190104c839 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/test/test.main.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var gfindIndex = require( './../lib' ); @@ -44,14 +45,9 @@ tape( 'the function returns the index of the first element which passes a test i x = [ 1.0, 1.0, 2.0, 3.0, 2.0, 3.0 ]; - // Nonnegative stride... actual = gfindIndex( x.length, x, 1, clbk ); t.strictEqual( actual, 2, 'returns expected value' ); - // Negative stride... - actual = gfindIndex( x.length, x, -1, clbk ); - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); function clbk( v ) { @@ -65,14 +61,9 @@ tape( 'the function returns the index of the first element which passes a test i x = toAccessorArray( [ 1.0, 1.0, 2.0, 3.0, 2.0, 3.0 ] ); - // Nonnegative stride... actual = gfindIndex( x.length, x, 1, clbk ); t.strictEqual( actual, 2, 'returns expected value' ); - // Negative stride... - actual = gfindIndex( x.length, x, -1, clbk ); - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); function clbk( v ) { @@ -80,7 +71,7 @@ tape( 'the function returns the index of the first element which passes a test i } }); -tape( 'the function returns `-1` if the provided `N` parameter is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gfindIndex( 0, [ 1.0, 2.0, 3.0 ], 1, clbk ); @@ -96,7 +87,7 @@ tape( 'the function returns `-1` if the provided `N` parameter is less than or e } }); -tape( 'the function returns `-1` if the provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gfindIndex( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, clbk ); @@ -112,7 +103,7 @@ tape( 'the function returns `-1` if the provided `N` parameter is less than or e } }); -tape( 'the function returns `-1` if no element passes the test implemented by a predicate function', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which passes a test implemented by a predicate function', function test( t ) { var actual; var x; @@ -128,7 +119,7 @@ tape( 'the function returns `-1` if no element passes the test implemented by a } }); -tape( 'the function returns `-1` if no element passes the test implemented by a predicate function (accessors)', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which passes a test implemented by a predicate function (accessors)', function test( t ) { var actual; var x; @@ -143,3 +134,153 @@ tape( 'the function returns `-1` if no element passes the test implemented by a return v % 2.0 === 0.0; } }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 3.0, + 2.0, // 1 + 7.0, + 5.0 // 2 + ]; + + actual = gfindIndex( 3, x, 2, clbk ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 3.0, + 2.0, // 1 + 7.0, + 5.0 // 2 + ]; + + actual = gfindIndex( 3, toAccessorArray( x ), 2, clbk ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + 3.0, + 5.0, // 1 + 7.0, + 1.0 // 0 + ]; + + actual = gfindIndex( 3, x, -2, clbk ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + 3.0, + 5.0, // 1 + 7.0, + 1.0 // 0 + ]; + + actual = gfindIndex( 3, toAccessorArray( x ), -2, clbk ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = gfindIndex( 3, x1, 2, clbk ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports providing a callback execution context', function test( t ) { + var actual; + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + + actual = gfindIndex( x.length, x, 1, clbk, ctx ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports providing a callback execution context (accessors)', function test( t ) { + var actual; + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + + actual = gfindIndex( x.length, toAccessorArray( x ), 1, clbk, ctx ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v % 2.0 === 0.0; + } +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/test/test.ndarray.js index fc88ed59e9fc..318310fc4754 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/test/test.ndarray.js @@ -44,13 +44,8 @@ tape( 'the function returns the index of the first element which passes a test i x = [ 1.0, 1.0, 2.0, 3.0, 2.0, 3.0 ]; - // Nonnegative stride... - actual = gfindIndex( 3, x, 1, 3, clbk ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - actual = gfindIndex( 3, x, -1, 3, clbk ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gfindIndex( x.length, x, 1, 0, clbk ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); @@ -65,13 +60,8 @@ tape( 'the function returns the index of the first element which passes a test i x = toAccessorArray( [ 1.0, 1.0, 2.0, 3.0, 2.0, 3.0 ] ); - // Nonnegative stride... - actual = gfindIndex( 3, x, 1, 3, clbk ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - actual = gfindIndex( 3, x, -1, 3, clbk ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gfindIndex( x.length, x, 1, 0, clbk ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); @@ -80,7 +70,7 @@ tape( 'the function returns the index of the first element which passes a test i } }); -tape( 'the function returns `-1` if the provided `N` parameter is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gfindIndex( 0, [ 1.0, 2.0, 3.0 ], 1, 0, clbk ); @@ -96,7 +86,7 @@ tape( 'the function returns `-1` if the provided `N` parameter is less than or e } }); -tape( 'the function returns `-1` if the provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gfindIndex( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0, clbk ); @@ -112,7 +102,7 @@ tape( 'the function returns `-1` if the provided `N` parameter is less than or e } }); -tape( 'the function returns `-1` if no element passes the test implemented by a predicate function', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which passes a test implemented by a predicate function', function test( t ) { var actual; var x; @@ -128,7 +118,7 @@ tape( 'the function returns `-1` if no element passes the test implemented by a } }); -tape( 'the function returns `-1` if no element passes the test implemented by a predicate function (accessors)', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which passes a test implemented by a predicate function (accessors)', function test( t ) { var actual; var x; @@ -143,3 +133,181 @@ tape( 'the function returns `-1` if no element passes the test implemented by a return v % 2.0 === 0.0; } }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 3.0, + 2.0, // 1 + 7.0, + 5.0 // 2 + ]; + + actual = gfindIndex( 3, x, 2, 0, clbk ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 3.0, + 2.0, // 1 + 7.0, + 5.0 // 2 + ]; + + actual = gfindIndex( 3, toAccessorArray( x ), 2, 0, clbk ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + 3.0, + 5.0, // 1 + 7.0, + 1.0 // 0 + ]; + + actual = gfindIndex( 3, x, -2, x.length-1, clbk ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + 3.0, + 5.0, // 1 + 7.0, + 1.0 // 0 + ]; + + actual = gfindIndex( 3, toAccessorArray( x ), -2, x.length-1, clbk ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = [ + 1.0, + 1.0, // 0 + 2.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]; + + actual = gfindIndex( 3, x, 2, 1, clbk ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports an `x` offset (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, + 1.0, // 0 + 2.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]; + + actual = gfindIndex( 3, toAccessorArray( x ), 2, 1, clbk ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports providing a callback execution context', function test( t ) { + var actual; + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + + actual = gfindIndex( x.length, x, 1, 0, clbk, ctx ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports providing a callback execution context (accessors)', function test( t ) { + var actual; + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + + actual = gfindIndex( x.length, toAccessorArray( x ), 1, 0, clbk, ctx ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v % 2.0 === 0.0; + } +}); From 8d5e45523f06cb674208928ae2536525dfb4b493 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 16:34:37 +0500 Subject: [PATCH 31/68] fix: refactor `gfind-last-index` --- .../blas/ext/base/gfind-last-index/README.md | 2 +- .../ext/base/gfind-last-index/docs/repl.txt | 21 +- .../gfind-last-index/docs/types/index.d.ts | 6 +- .../ext/base/gfind-last-index/lib/main.js | 4 + .../ext/base/gfind-last-index/lib/ndarray.js | 6 +- .../base/gfind-last-index/test/test.main.js | 169 +++++++++++++-- .../gfind-last-index/test/test.ndarray.js | 204 ++++++++++++++++-- 7 files changed, 367 insertions(+), 45 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/README.md index 805a1fb364c4..317b7788e36d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/README.md @@ -45,7 +45,7 @@ var idx = gfindLastIndex( x.length, x, 1, isEven ); // returns 3 ``` -If no element passes a test implemented by a predicate function, the function returns `-1`. +If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. ```javascript function isEven( v ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/docs/repl.txt index f47ff2f7a899..1290d5d73505 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/docs/repl.txt @@ -6,11 +6,10 @@ The `N` and stride parameters determine which elements in the strided array are accessed at runtime. - Indexing is relative to the first index. To introduce an offset, use typed - array views. + Indexing is relative to the first index. To introduce an offset, use a typed + array view. - If `N <= 0` or no element passes a test implemented by a predicate function, - the function returns `-1`. + If `N <= 0`, the function returns `-1`. The callback function is provided the following arguments: @@ -43,7 +42,7 @@ Examples -------- - // Standard Usage: + // Standard usage: > function f( v ) { return v % 2.0 === 0.0; }; > var x = [ 1.0, 2.0, -3.0, 4.0, -5.0, 6.0 ]; > {{alias}}( x.length, x, 1, f ) @@ -51,7 +50,7 @@ // Using `N` and stride parameters: > x = [ 1.0, 3.0, 4.0, -5.0, -6.0, -3.0 ]; - > {{alias}}( x.length, x, 2, f ) + > {{alias}}( 3, x, 2, f ) 2 // Using view offsets: @@ -96,10 +95,16 @@ Examples -------- + // Standard usage: > function f( v ) { return v % 2.0 === 0.0; }; > var x = [ 1.0, 2.0, -3.0, 4.0, -5.0, -6.0 ]; - > {{alias}}.ndarray( 4, x, 1, 2, f ) - 3 + > {{alias}}.ndarray( x.length, x, 1, 0, f ) + 5 + + // Using an index offset: + > x = [ 1.0, 2.0, -3.0, 4.0, -5.0, -6.0 ]; + > {{alias}}.ndarray( 3, x, 2, 1, f ) + 2 See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/docs/types/index.d.ts index 67050723d247..7be9b1bce493 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/docs/types/index.d.ts @@ -99,7 +99,7 @@ interface Routine { * - `sidx`: strided index (offset + aidx*stride) * - `array`: input array * - * - If no element passes a test implemented by a predicate function, the function returns `-1`. + * - If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. * * @param N - number of indexed elements * @param x - input array @@ -132,7 +132,7 @@ interface Routine { * - `sidx`: strided index (offset + aidx*stride) * - `array`: input array * - * - If no element passes a test implemented by a predicate function, the function returns `-1`. + * - If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. * * @param N - number of indexed elements * @param x - input array @@ -167,7 +167,7 @@ interface Routine { * - `sidx`: strided index (offset + aidx*stride) * - `array`: input array * -* - If no element passes a test implemented by a predicate function, the function returns `-1`. +* - If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. * * @param N - number of indexed elements * @param x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/lib/main.js index a0a81c7b98e9..5a6ef7ce192b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/lib/main.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the last element which passes a test implemented by a predicate function. * +* ## Notes +* +* - If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array * @param {integer} strideX - stride length diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/lib/ndarray.js index ddd30561008d..f6599eb6feca 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/lib/ndarray.js @@ -26,7 +26,11 @@ var gfindIndex = require( '@stdlib/blas/ext/base/gfind-index' ).ndarray; // MAIN // /** -* Returns the index of the last element which passes a test implemented by a predicate function. +* Returns the index of the last element which passes a test implemented by a predicate function using alternative indexing semantics. +* +* ## Notes +* +* - If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/test/test.main.js index bcb3274f2754..a8c8a5c8a4b3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/test/test.main.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var gfindLastIndex = require( './../lib' ); @@ -44,14 +45,9 @@ tape( 'the function returns the index of the last element which passes a test im x = [ 1.0, 1.0, 2.0, 3.0, 2.0, 3.0 ]; - // Nonnegative stride... actual = gfindLastIndex( x.length, x, 1, clbk ); t.strictEqual( actual, 4, 'returns expected value' ); - // Negative stride... - actual = gfindLastIndex( x.length, x, -1, clbk ); - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); function clbk( v ) { @@ -65,14 +61,9 @@ tape( 'the function returns the index of the last element which passes a test im x = toAccessorArray( [ 1.0, 1.0, 2.0, 3.0, 2.0, 3.0 ] ); - // Nonnegative stride... actual = gfindLastIndex( x.length, x, 1, clbk ); t.strictEqual( actual, 4, 'returns expected value' ); - // Negative stride... - actual = gfindLastIndex( x.length, x, -1, clbk ); - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); function clbk( v ) { @@ -80,7 +71,7 @@ tape( 'the function returns the index of the last element which passes a test im } }); -tape( 'the function returns `-1` if the provided `N` parameter is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gfindLastIndex( 0, [ 1.0, 2.0, 3.0 ], 1, clbk ); @@ -96,7 +87,7 @@ tape( 'the function returns `-1` if the provided `N` parameter is less than or e } }); -tape( 'the function returns `-1` if the provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gfindLastIndex( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, clbk ); @@ -112,7 +103,7 @@ tape( 'the function returns `-1` if the provided `N` parameter is less than or e } }); -tape( 'the function returns `-1` if no element passes the test implemented by a predicate function', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which passes a test implemented by a predicate function', function test( t ) { var actual; var x; @@ -128,7 +119,7 @@ tape( 'the function returns `-1` if no element passes the test implemented by a } }); -tape( 'the function returns `-1` if no element passes the test implemented by a predicate function (accessors)', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which passes a test implemented by a predicate function (accessors)', function test( t ) { var actual; var x; @@ -143,3 +134,153 @@ tape( 'the function returns `-1` if no element passes the test implemented by a return v % 2.0 === 0.0; } }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 0 + 3.0, + 4.0, // 1 + 7.0, + 5.0 // 2 + ]; + + actual = gfindLastIndex( 3, x, 2, clbk ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 0 + 3.0, + 4.0, // 1 + 7.0, + 5.0 // 2 + ]; + + actual = gfindLastIndex( 3, toAccessorArray( x ), 2, clbk ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + 3.0, + 4.0, // 1 + 7.0, + 1.0 // 0 + ]; + + actual = gfindLastIndex( 3, x, -2, clbk ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + 3.0, + 4.0, // 1 + 7.0, + 1.0 // 0 + ]; + + actual = gfindLastIndex( 3, toAccessorArray( x ), -2, clbk ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array( [ 1.0, 1.0, 2.0, 4.0, 5.0, 6.0 ] ); + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = gfindLastIndex( 3, x1, 2, clbk ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports providing a callback execution context', function test( t ) { + var actual; + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + + actual = gfindLastIndex( x.length, x, 1, clbk, ctx ); + + t.strictEqual( actual, 3, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports providing a callback execution context (accessors)', function test( t ) { + var actual; + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + + actual = gfindLastIndex( x.length, toAccessorArray( x ), 1, clbk, ctx ); + + t.strictEqual( actual, 3, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v % 2.0 === 0.0; + } +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/test/test.ndarray.js index bc1c2df3a589..b533a80c8c57 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-last-index/test/test.ndarray.js @@ -44,13 +44,8 @@ tape( 'the function returns the index of the last element which passes a test im x = [ 1.0, 1.0, 2.0, 3.0, 2.0, 2.0 ]; - // Nonnegative stride... - actual = gfindLastIndex( 3, x, 1, 3, clbk ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = gfindLastIndex( 3, x, -1, 3, clbk ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gfindLastIndex( x.length, x, 1, 0, clbk ); + t.strictEqual( actual, 5, 'returns expected value' ); t.end(); @@ -65,13 +60,8 @@ tape( 'the function returns the index of the last element which passes a test im x = toAccessorArray( [ 1.0, 1.0, 2.0, 3.0, 2.0, 2.0 ] ); - // Nonnegative stride... - actual = gfindLastIndex( 3, x, 1, 3, clbk ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = gfindLastIndex( 3, x, -1, 3, clbk ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = gfindLastIndex( x.length, x, 1, 0, clbk ); + t.strictEqual( actual, 5, 'returns expected value' ); t.end(); @@ -80,7 +70,7 @@ tape( 'the function returns the index of the last element which passes a test im } }); -tape( 'the function returns `-1` if the provided `N` parameter is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = gfindLastIndex( 0, [ 1.0, 2.0, 3.0 ], 1, 0, clbk ); @@ -96,7 +86,7 @@ tape( 'the function returns `-1` if the provided `N` parameter is less than or e } }); -tape( 'the function returns `-1` if the provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { var actual; actual = gfindLastIndex( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0, clbk ); @@ -112,7 +102,7 @@ tape( 'the function returns `-1` if the provided `N` parameter is less than or e } }); -tape( 'the function returns `-1` if no element passes the test implemented by a predicate function', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which passes a test implemented by a predicate function', function test( t ) { var actual; var x; @@ -128,7 +118,7 @@ tape( 'the function returns `-1` if no element passes the test implemented by a } }); -tape( 'the function returns `-1` if no element passes the test implemented by a predicate function (accessors)', function test( t ) { +tape( 'the function returns `-1` if unable to find an element which passes a test implemented by a predicate function (accessors)', function test( t ) { var actual; var x; @@ -143,3 +133,181 @@ tape( 'the function returns `-1` if no element passes the test implemented by a return v % 2.0 === 0.0; } }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 0 + 3.0, + 4.0, // 1 + 7.0, + 5.0 // 2 + ]; + + actual = gfindLastIndex( 3, x, 2, 0, clbk ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 0 + 3.0, + 4.0, // 1 + 7.0, + 5.0 // 2 + ]; + + actual = gfindLastIndex( 3, toAccessorArray( x ), 2, 0, clbk ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + 3.0, + 4.0, // 1 + 7.0, + 1.0 // 0 + ]; + + actual = gfindLastIndex( 3, x, -2, x.length-1, clbk ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports a negative `x` stride (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 2.0, // 2 + 3.0, + 4.0, // 1 + 7.0, + 1.0 // 0 + ]; + + actual = gfindLastIndex( 3, toAccessorArray( x ), -2, x.length-1, clbk ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = [ + 1.0, + 1.0, // 0 + 2.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]; + + actual = gfindLastIndex( 3, x, 2, 1, clbk ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports an `x` offset (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 1.0, + 1.0, // 0 + 2.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]; + + actual = gfindLastIndex( 3, toAccessorArray( x ), 2, 1, clbk ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports providing a callback execution context', function test( t ) { + var actual; + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + + actual = gfindLastIndex( x.length, x, 1, 0, clbk, ctx ); + + t.strictEqual( actual, 3, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v % 2.0 === 0.0; + } +}); + +tape( 'the function supports providing a callback execution context (accessors)', function test( t ) { + var actual; + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + + actual = gfindLastIndex( x.length, toAccessorArray( x ), 1, 0, clbk, ctx ); + + t.strictEqual( actual, 3, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + t.end(); + + function clbk( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v % 2.0 === 0.0; + } +}); From a8f553ce8ea1395b5a6a2b01010269a9492ebfa3 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 17:13:30 +0500 Subject: [PATCH 32/68] fix: address audit findings in index-returning packages --- .../ext/base/dfirst-index-equal/docs/repl.txt | 2 +- .../dfirst-index-greater-than/docs/repl.txt | 2 +- .../ext/base/dlast-index-equal/docs/repl.txt | 8 ++--- .../dlast-index-equal/test/test.ndarray.js | 28 --------------- .../test/test.ndarray.native.js | 28 --------------- .../docs/repl.txt | 2 +- .../ext/base/gfirst-index-equal/docs/repl.txt | 4 +-- .../docs/repl.txt | 2 +- .../gfirst-index-greater-than/docs/repl.txt | 2 +- .../base/gfirst-index-not-equal/docs/repl.txt | 35 ++++++++++--------- .../ext/base/glast-index-equal/docs/repl.txt | 4 +-- .../base/glast-index-not-equal/docs/repl.txt | 2 +- .../ext/base/sfirst-index-equal/docs/repl.txt | 2 +- .../base/sfirst-index-less-than/docs/repl.txt | 2 +- .../ext/base/sindex-of/docs/types/index.d.ts | 3 +- .../ext/base/slast-index-equal/docs/repl.txt | 8 ++--- .../slast-index-equal/test/test.ndarray.js | 28 --------------- .../test/test.ndarray.native.js | 28 --------------- 18 files changed, 39 insertions(+), 151 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt index 649441ce9b41..afce38cabb0c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt @@ -102,7 +102,7 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using offsets: + // Using an index offset: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0 ] ); > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt index 6ffe98636d3d..9238ca9dff83 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt @@ -103,7 +103,7 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using offsets: + // Using an index offset: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0 ] ); > y = new {{alias:@stdlib/array/float64}}( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0, 0.0 ] ); > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/repl.txt index 2bc0e01c039d..9702555bb92a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/repl.txt @@ -102,11 +102,11 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using strides: + // Using an index offset: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > y = new {{alias:@stdlib/array/float64}}( [ 1.0, 0.0, 0.0, 0.0, 5.0, 0.0 ] ); - > idx = {{alias}}.ndarray( 3, x, 2, 0, y, 2, 0 ) - 2 + > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0 ] ); + > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) + -1 See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js index 0f3ef61ef126..4305aadefee9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js @@ -285,31 +285,3 @@ tape( 'the function supports complex access patterns', function test( t ) { t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); - -tape( 'the function supports an `x` offset', function test( t ) { - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( [ 0.0, 3.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 2, x, 1, 1, y, 1, 0 ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a `y` offset', function test( t ) { - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 3.0 ] ); - - actual = dlastIndexEqual( 2, x, 1, 1, y, 1, 2 ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); -}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js index 2986f4f1a340..e828653d3ca6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js @@ -294,31 +294,3 @@ tape( 'the function supports complex access patterns', opts, function test( t ) t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); - -tape( 'the function supports an `x` offset', opts, function test( t ) { - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( [ 0.0, 3.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 2, x, 1, 1, y, 1, 0 ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a `y` offset', opts, function test( t ) { - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 3.0 ] ); - - actual = dlastIndexEqual( 2, x, 1, 1, y, 1, 2 ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); -}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/docs/repl.txt index bcdd9f94266a..090db386e5a5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-almost-same-value/docs/repl.txt @@ -107,7 +107,7 @@ > var idx = {{alias}}.ndarray( x.length, 1, x, 1, 0, y, 1, 0 ) 2 - // Using offsets: + // Using an index offset: > x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; > y = [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ]; > idx = {{alias}}.ndarray( 3, 1, x, 2, 1, y, 2, 1 ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/docs/repl.txt index 8af16549ed83..4faaef9e51ca 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/docs/repl.txt @@ -101,9 +101,9 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using offsets: + // Using an index offset: > x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - > y = [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ]; + > y = [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0 ]; > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) -1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/docs/repl.txt index 4ac1bf073a68..54e991571199 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than-equal/docs/repl.txt @@ -101,7 +101,7 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 1 - // Using offsets: + // Using an index offset: > x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0 ]; > y = [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0, 0.0 ]; > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/docs/repl.txt index 2786a7cb1ccb..57f0987be79c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/docs/repl.txt @@ -101,7 +101,7 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using offsets: + // Using an index offset: > x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0 ]; > y = [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0, 0.0 ]; > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/repl.txt index ef43901c7e2f..70445d6d798e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-not-equal/docs/repl.txt @@ -36,23 +36,24 @@ Examples -------- // Standard usage: - > var x = [ 0, 0, 1, 0 ]; - > var y = [ 0, 0, 0, 0 ]; + > var x = [ 1.0, 2.0, 3.0, 4.0 ]; + > var y = [ 1.0, 2.0, 0.0, 4.0 ]; > var idx = {{alias}}( x.length, x, 1, y, 1 ) 2 // Using `N` and stride parameters: - > var x = [ 2, 4, 6, 8, 10 ]; - > var y = [ 2, 3, 4, 5, 6 ]; - > var idx = {{alias}}( 3, x, 2, y, 1 ) - 1 + > x = [ 0.0, 1.0, 0.0, 1.0, 1.0, 0.0 ]; + > y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > idx = {{alias}}( 3, x, 2, y, 2 ) + 2 - // View offsets: - > var x0 = new {{alias:@stdlib/array/float64}}( [ 0, 0, 1, 0 ] ); + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 1.0, 0.0, 0.0 ] ); + > var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > var y = [ 0, 0, 0 ]; - > var idx = {{alias}}( x1.length, x1, 1, y, 1 ) - 1 + > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + > idx = {{alias}}( 3, x1, 1, y1, 1 ) + 2 {{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) @@ -95,15 +96,15 @@ Examples -------- // Standard usage: - > var x = [ 0, 0, 1, 0 ]; - > var y = [ 0, 0, 0, 0 ]; + > var x = [ 1.0, 2.0, 3.0, 4.0 ]; + > var y = [ 1.0, 2.0, 0.0, 4.0 ]; > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Advanced indexing: - > var x = [ 2, 4, 6, 8, 10 ]; - > var y = [ 2, 3, 4, 5, 6 ]; - > var idx = {{alias}}.ndarray( 3, x, 2, 0, y, 1, 0 ) + // Using an index offset: + > x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; + > y = [ 0.0, 0.0, 0.0, 4.0, 0.0, 6.0 ]; + > idx = {{alias}}.ndarray( 3, x, 1, 3, y, 1, 3 ) 1 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/docs/repl.txt index 4ea27fa169e5..d91126c7f773 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-equal/docs/repl.txt @@ -101,9 +101,9 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using offsets: + // Using an index offset: > x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - > y = [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ]; + > y = [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0 ]; > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) -1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/repl.txt index 9a23897e82c7..16fc3144918e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-not-equal/docs/repl.txt @@ -101,7 +101,7 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 3 - // Using offsets: + // Using an index offset: > x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; > y = [ 0.0, 0.0, 0.0, 4.0, 0.0, 6.0 ]; > idx = {{alias}}.ndarray( 3, x, 1, 3, y, 1, 3 ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/docs/repl.txt index e13b62f90852..1812c97c496b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/docs/repl.txt @@ -102,7 +102,7 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using offsets: + // Using an index offset: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0 ] ); > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/repl.txt index 1d6ff9172673..83d795dbc721 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/repl.txt @@ -102,7 +102,7 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using offsets: + // Using an index offset: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0 ] ); > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/types/index.d.ts index 20ee2782240d..f832e8ca4a6a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/docs/types/index.d.ts @@ -19,8 +19,7 @@ // TypeScript Version: 4.1 /** -* Interface describing `sindexOf` -* +* Interface describing `sindexOf`. */ interface Routine { /** diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/docs/repl.txt index c0423cb4009e..57a2e01d9d1f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/docs/repl.txt @@ -102,11 +102,11 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using strides: + // Using an index offset: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 0.0, 0.0, 0.0, 5.0, 0.0 ] ); - > idx = {{alias}}.ndarray( 3, x, 2, 0, y, 2, 0 ) - 2 + > y = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0 ] ); + > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) + -1 See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.js index 088c698a7533..fe4cd4ba94e4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.js @@ -285,31 +285,3 @@ tape( 'the function supports complex access patterns', function test( t ) { t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); - -tape( 'the function supports an `x` offset', function test( t ) { - var actual; - var x; - var y; - - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float32Array( [ 0.0, 3.0, 0.0, 0.0 ] ); - - actual = slastIndexEqual( 2, x, 1, 1, y, 1, 0 ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a `y` offset', function test( t ) { - var actual; - var x; - var y; - - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float32Array( [ 0.0, 0.0, 2.0, 3.0 ] ); - - actual = slastIndexEqual( 2, x, 1, 1, y, 1, 2 ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); -}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.native.js index ae7660c10461..c4adddab8f38 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/test/test.ndarray.native.js @@ -294,31 +294,3 @@ tape( 'the function supports complex access patterns', opts, function test( t ) t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); - -tape( 'the function supports an `x` offset', opts, function test( t ) { - var actual; - var x; - var y; - - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float32Array( [ 0.0, 3.0, 0.0, 0.0 ] ); - - actual = slastIndexEqual( 2, x, 1, 1, y, 1, 0 ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports a `y` offset', opts, function test( t ) { - var actual; - var x; - var y; - - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float32Array( [ 0.0, 0.0, 2.0, 3.0 ] ); - - actual = slastIndexEqual( 2, x, 1, 1, y, 1, 2 ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); -}); From bba9d99ee9acfd9ea5d7a0f1b8a50b5b9a181b7c Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 10 Sep 2026 20:16:05 +0500 Subject: [PATCH 33/68] fix: apply suggestions from code review --- 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: na - task: lint_markdown_docs status: na - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/cindex-of/lib/cindex_of.native.js | 4 ++++ .../@stdlib/blas/ext/base/cindex-of/lib/ndarray.native.js | 4 ++++ .../base/dfirst-index-equal/lib/dfirst_index_equal.native.js | 4 ++++ .../blas/ext/base/dfirst-index-equal/lib/ndarray.native.js | 4 ++++ .../lib/dfirst_index_greater_than.native.js | 4 ++++ .../ext/base/dfirst-index-greater-than/lib/ndarray.native.js | 4 ++++ .../lib/dfirst_index_less_than.native.js | 4 ++++ .../ext/base/dfirst-index-less-than/lib/ndarray.native.js | 4 ++++ .../@stdlib/blas/ext/base/dindex-of/lib/dindex_of.native.js | 4 ++++ .../@stdlib/blas/ext/base/dindex-of/lib/ndarray.native.js | 4 ++++ .../base/dlast-index-equal/lib/dlast_index_equal.native.js | 4 ++++ .../blas/ext/base/dlast-index-equal/lib/ndarray.native.js | 4 ++++ .../blas/ext/base/dlast-index-of/lib/dlast_index_of.native.js | 4 ++++ .../blas/ext/base/dlast-index-of/lib/ndarray.native.js | 4 ++++ .../blas/ext/base/sfirst-index-equal/lib/ndarray.native.js | 4 ++++ .../base/sfirst-index-equal/lib/sfirst_index_equal.native.js | 4 ++++ .../ext/base/sfirst-index-less-than/lib/ndarray.native.js | 4 ++++ .../lib/sfirst_index_less_than.native.js | 4 ++++ .../@stdlib/blas/ext/base/sindex-of/lib/ndarray.native.js | 4 ++++ .../@stdlib/blas/ext/base/sindex-of/lib/sindex_of.native.js | 4 ++++ .../blas/ext/base/slast-index-equal/lib/ndarray.native.js | 4 ++++ .../base/slast-index-equal/lib/slast_index_equal.native.js | 4 ++++ .../blas/ext/base/slast-index-of/lib/ndarray.native.js | 4 ++++ .../blas/ext/base/slast-index-of/lib/slast_index_of.native.js | 4 ++++ .../@stdlib/blas/ext/base/zindex-of/lib/ndarray.native.js | 4 ++++ .../@stdlib/blas/ext/base/zindex-of/lib/zindex_of.native.js | 4 ++++ 26 files changed, 104 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.native.js index 5af67f0bc8a6..40dd62a43965 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.native.js @@ -29,6 +29,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a single-precision complex floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex64} searchElement - search element * @param {Complex64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.native.js index 719a3c289295..d9c371d7c0d5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.native.js @@ -29,6 +29,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a single-precision complex floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex64} searchElement - search element * @param {Complex64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js index 25cfab141d32..7686afc09093 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js index 881ede8dd73c..8fd410c7ed3d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js index a38ffae9acc1..25135ebfee62 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js index b471ae7fee00..20871b983b8d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.native.js index d80c07036777..bf2cf422e4ba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.native.js index 8b7b73c97e5d..f3b93c8a83fe 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.native.js index 26801cf3fce6..eb14fa125b8b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.native.js index a919095e29df..75688be5a151 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.native.js index e38fce2ae890..4b47d0ef89d6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the last element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.native.js index 2fea6fda3ee4..6618c8b22f40 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the last element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.native.js index 90fc1f154dae..60e1b250a438 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the last index of a specified search element in a double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.native.js index 0556514af354..67c2c4d6cdea 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the last index of a specified search element in a double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/ndarray.native.js index b1c0e88e4613..e881f164a003 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a single-precision floating-point strided array equal to a corresponding element in another single-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/sfirst_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/sfirst_index_equal.native.js index fc0974d7baed..ca1d49dcacec 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/sfirst_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-equal/lib/sfirst_index_equal.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a single-precision floating-point strided array equal to a corresponding element in another single-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/ndarray.native.js index d580ac4ee14e..31ca96f6ac09 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a single-precision floating-point strided array which is less than a corresponding element in another single-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/sfirst_index_less_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/sfirst_index_less_than.native.js index 2d5e8a3d2d84..a0aa1c142f79 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/sfirst_index_less_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/lib/sfirst_index_less_than.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a single-precision floating-point strided array which is less than a corresponding element in another single-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/ndarray.native.js index 8d1da2b2e5d3..d50662701ad8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a single-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float32Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/sindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/sindex_of.native.js index b7532aea91fe..250d4f0cf104 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/sindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sindex-of/lib/sindex_of.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a single-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float32Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/ndarray.native.js index d69ef7bb04a5..805169b811e2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the last element in a single-precision floating-point strided array equal to a corresponding element in another single-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/slast_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/slast_index_equal.native.js index 58a01a78c9cc..9b8bc0e8184a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/slast_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-equal/lib/slast_index_equal.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the last element in a single-precision floating-point strided array equal to a corresponding element in another single-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find matching elements, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/ndarray.native.js index df27efbcb401..df843ae5b843 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the last index of a specified search element in a single-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float32Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/slast_index_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/slast_index_of.native.js index 8396ab914e3f..a9c4b10e6f47 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/slast_index_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/slast-index-of/lib/slast_index_of.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the last index of a specified search element in a single-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float32Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/ndarray.native.js index 9556eaf4686b..e147002c937d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/ndarray.native.js @@ -29,6 +29,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a double-precision complex floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex128} searchElement - search element * @param {Complex128Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/zindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/zindex_of.native.js index dff0ed81796e..1fb554f3930a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/zindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zindex-of/lib/zindex_of.native.js @@ -29,6 +29,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a double-precision complex floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex128} searchElement - search element * @param {Complex128Array} x - input array From 295c63ed29af4a2f98f88ab738c43e37eea2c198 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 11 Sep 2026 14:25:04 +0500 Subject: [PATCH 34/68] fix: apply consistency fixes to `first-index-equal` --- .../ext/base/dfirst-index-equal/README.md | 36 ++-- .../dfirst-index-equal/benchmark/benchmark.js | 2 +- .../ext/base/dfirst-index-equal/docs/repl.txt | 8 +- .../dfirst-index-equal/docs/types/index.d.ts | 14 +- .../dfirst-index-equal/docs/types/test.ts | 12 ++ .../dfirst-index-equal/examples/c/example.c | 4 +- .../lib/dfirst_index_equal.js | 4 +- .../lib/dfirst_index_equal.native.js | 4 +- .../ext/base/dfirst-index-equal/lib/index.js | 4 +- .../base/dfirst-index-equal/lib/ndarray.js | 4 +- .../dfirst-index-equal/lib/ndarray.native.js | 4 +- .../test/test.dfirst_index_equal.js | 125 ++++++------ .../test/test.dfirst_index_equal.native.js | 125 ++++++------ .../dfirst-index-equal/test/test.ndarray.js | 94 ++++----- .../test/test.ndarray.native.js | 94 ++++----- .../ext/base/gfirst-index-equal/README.md | 8 +- .../ext/base/gfirst-index-equal/docs/repl.txt | 14 +- .../gfirst-index-equal/docs/types/index.d.ts | 6 +- .../gfirst-index-equal/docs/types/test.ts | 4 +- .../base/gfirst-index-equal/lib/accessors.js | 2 +- .../ext/base/gfirst-index-equal/lib/main.js | 2 +- .../base/gfirst-index-equal/lib/ndarray.js | 2 +- .../base/gfirst-index-equal/test/test.main.js | 175 +++++++---------- .../gfirst-index-equal/test/test.ndarray.js | 182 +++++++----------- .../ext/base/sfirst-index-equal/README.md | 6 +- .../ext/base/sfirst-index-equal/docs/repl.txt | 12 +- .../sfirst-index-equal/docs/types/index.d.ts | 6 +- .../sfirst-index-equal/docs/types/test.ts | 12 ++ .../base/sfirst-index-equal/lib/ndarray.js | 2 +- .../sfirst-index-equal/lib/ndarray.native.js | 2 +- .../lib/sfirst_index_equal.js | 2 +- .../lib/sfirst_index_equal.native.js | 2 +- .../ext/base/sfirst-index-equal/package.json | 2 + .../ext/base/sfirst-index-equal/src/addon.c | 2 +- .../ext/base/sfirst-index-equal/src/main.c | 28 +-- .../sfirst-index-equal/test/test.ndarray.js | 90 ++++----- .../test/test.ndarray.native.js | 90 ++++----- .../test/test.sfirst_index_equal.js | 95 ++++----- .../test/test.sfirst_index_equal.native.js | 95 ++++----- 39 files changed, 594 insertions(+), 781 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md index abeb6c81badf..977b450afdd5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md @@ -50,7 +50,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); -var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); // returns 2 ``` @@ -62,7 +62,7 @@ The function has the following parameters: - **y**: second input [`Float64Array`][@stdlib/array/float64]. - **strideY**: stride length for `y`. -If the function is unable to find matching elements, the function returns `-1`. +If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -70,20 +70,20 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Array( [ 5.0, 6.0, 7.0, 8.0 ] ); -var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); // returns -1 ``` -The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to search every other element: +The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compare every other element: ```javascript var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -var y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 5.0, 0.0 ] ); +var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); var idx = dfirstIndexEqual( 3, x, 2, y, 2 ); -// returns 2 +// returns 1 ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -114,7 +114,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); -var idx = dfirstIndexEqual.ndarray( 4, x, 1, 0, y, 1, 0 ); +var idx = dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, 0 ); // returns 2 ``` @@ -123,16 +123,16 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetY**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on a starting index. For example, to access only the last three elements of the strided arrays: +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to access only the last three elements of each strided array: ```javascript var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 6.0 ] ); +var y = new Float64Array( [ 0.0, 0.0, 0.0, 4.0, 5.0, 6.0 ] ); var idx = dfirstIndexEqual.ndarray( 3, x, 1, x.length-3, y, 1, y.length-3 ); -// returns 2 +// returns 0 ```
@@ -212,8 +212,8 @@ console.log( idx ); Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. ```c -double x[] = { 1.0, 2.0, 3.0, 4.0 }; -double y[] = { 0.0, 0.0, 3.0, 0.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double y[] = { 0.0, 0.0, 3.0, 0.0 }; int idx = stdlib_strided_dfirst_index_equal( 4, x, 1, y, 1 ); // returns 2 @@ -240,8 +240,8 @@ CBLAS_INT stdlib_strided_dfirst_index_equal( const CBLAS_INT N, const double *X, Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. ```c -double x[] = { 1.0, 2.0, 3.0, 4.0 }; -double y[] = { 0.0, 0.0, 3.0, 0.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double y[] = { 0.0, 0.0, 3.0, 0.0 }; int idx = stdlib_strided_dfirst_index_equal_ndarray( 4, x, 1, 0, y, 1, 0 ); // returns 2 @@ -285,8 +285,8 @@ CBLAS_INT stdlib_strided_dfirst_index_equal_ndarray( const CBLAS_INT N, const do int main( void ) { // Create strided arrays: - double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; - double y[] = { 0.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0 }; + const double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; + const double y[] = { 0.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0 }; // Specify the number of indexed elements: const int N = 8; @@ -295,11 +295,11 @@ int main( void ) { const int strideX = 1; const int strideY = 1; - // Find the first index of a match: + // Perform a search: int idx = stdlib_strided_dfirst_index_equal( N, x, strideX, y, strideY ); // Print the result: - printf( "first index: %d\n", idx ); + printf( "index value: %d\n", idx ); } ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/benchmark/benchmark.js index 924080c11b54..c8339d43ec6e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/benchmark/benchmark.js @@ -27,7 +27,7 @@ var oneTo = require( '@stdlib/array/one-to' ); var zeros = require( '@stdlib/array/zeros' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; -var dfirstIndexEqual = require( './../lib' ); +var dfirstIndexEqual = require( './../lib/dfirst_index_equal.js' ); // FUNCTIONS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt index afce38cabb0c..26a8b7420ea1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt @@ -44,16 +44,16 @@ // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0, 5.0, 0.0 ] ); + > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); > idx = {{alias}}( 3, x, 2, y, 2 ) - 2 + 1 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 3.0, 0.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 3.0, 0.0 ] ); > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); - > idx = {{alias}}( 2, x1, 1, y1, 1 ) + > var idx = {{alias}}( 2, x1, 1, y1, 1 ) 1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts index 0a2666ed8bab..0989affb6435 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find matching elements, the function returns `-1`. + * - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -42,7 +42,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * - * var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); + * var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); * // returns 2 */ ( N: number, x: Float64Array, strideX: number, y: Float64Array, strideY: number ): number; @@ -52,7 +52,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find matching elements, the function returns `-1`. + * - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -69,7 +69,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * - * var idx = dfirstIndexEqual.ndarray( 4, x, 1, 0, y, 1, 0 ); + * var idx = dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ ndarray( N: number, x: Float64Array, strideX: number, offsetX: number, y: Float64Array, strideY: number, offsetY: number ): number; @@ -80,7 +80,7 @@ interface Routine { * * ## Notes * -* - If the function is unable to find matching elements, the function returns `-1`. +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -95,7 +95,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +* var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); * // returns 2 * * @example @@ -104,7 +104,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual.ndarray( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ declare var dfirstIndexEqual: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/test.ts index b16ef3584fa3..455c3a3f6a56 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/test.ts @@ -39,6 +39,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual( false, x, 1, y, 1 ); // $ExpectError dfirstIndexEqual( null, x, 1, y, 1 ); // $ExpectError dfirstIndexEqual( {}, x, 1, y, 1 ); // $ExpectError + dfirstIndexEqual( ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... @@ -50,6 +51,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual( 3, false, 1, y, 1 ); // $ExpectError dfirstIndexEqual( 3, null, 1, y, 1 ); // $ExpectError dfirstIndexEqual( 3, {}, 1, y, 1 ); // $ExpectError + dfirstIndexEqual( 3, ( x: number ): number => x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -62,6 +64,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual( x.length, x, false, y, 1 ); // $ExpectError dfirstIndexEqual( x.length, x, null, y, 1 ); // $ExpectError dfirstIndexEqual( x.length, x, {}, y, 1 ); // $ExpectError + dfirstIndexEqual( x.length, x, ( x: number ): number => x, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... @@ -73,6 +76,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual( x.length, x, 1, false, 1 ); // $ExpectError dfirstIndexEqual( x.length, x, 1, null, 1 ); // $ExpectError dfirstIndexEqual( x.length, x, 1, {}, 1 ); // $ExpectError + dfirstIndexEqual( x.length, x, 1, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... @@ -85,6 +89,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual( x.length, x, 1, y, false ); // $ExpectError dfirstIndexEqual( x.length, x, 1, y, null ); // $ExpectError dfirstIndexEqual( x.length, x, 1, y, {} ); // $ExpectError + dfirstIndexEqual( x.length, x, 1, y, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -118,6 +123,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -129,6 +135,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( 3, false, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( 3, null, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( 3, {}, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( 3, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -141,6 +148,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -153,6 +161,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float64Array... @@ -164,6 +173,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( x.length, x, 1, 0, false, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, null, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, {}, 1, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( x.length, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... @@ -176,6 +186,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... @@ -188,6 +199,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError + dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/examples/c/example.c index ddc5695e011f..20d6e7074521 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/examples/c/example.c @@ -31,9 +31,9 @@ int main( void ) { const int strideX = 1; const int strideY = 1; - // Find the first index of a match: + // Perform a search: int idx = stdlib_strided_dfirst_index_equal( N, x, strideX, y, strideY ); // Print the result: - printf( "first index: %d\n", idx ); + printf( "index value: %d\n", idx ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js index b9d4f429d273..26f470e0491f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If the function is unable to find matching elements, the function returns `-1`. +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array @@ -46,7 +46,7 @@ var ndarray = require( './ndarray.js' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +* var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); * // returns 2 */ function dfirstIndexEqual( N, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js index 7686afc09093..19d2f0ae280e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If the function is unable to find matching elements, the function returns `-1`. +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array @@ -45,7 +45,7 @@ var addon = require( './../src/addon.node' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +* var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); * // returns 2 */ function dfirstIndexEqual( N, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/index.js index 95105b27e37c..56095cf3a877 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/index.js @@ -30,7 +30,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +* var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); * // returns 2 * * @example @@ -40,7 +40,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual.ndarray( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js index f1b3bb25ee34..48cdfb8c5507 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js @@ -25,7 +25,7 @@ * * ## Notes * -* - If the function is unable to find matching elements, the function returns `-1`. +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array @@ -42,7 +42,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexEqual( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ function dfirstIndexEqual( N, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js index 8fd410c7ed3d..644c2bd7da1b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If the function is unable to find matching elements, the function returns `-1`. +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array @@ -47,7 +47,7 @@ var addon = require( './../src/addon.node' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexEqual( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ function dfirstIndexEqual( N, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js index 94639f83f8cd..924d0d348fd7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js @@ -46,59 +46,9 @@ tape( 'the function returns the first index of an element which equals a corresp x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, 2, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 3.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -153,8 +103,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -179,12 +129,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -197,16 +147,42 @@ tape( 'the function supports negative strides', function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 - 3.0, // 1 0.0, // 0 + 3.0, // 1 + 0.0, // 2 0.0, 0.0 ]); - actual = dfirstIndexEqual( 3, x, -2, y, -1 ); + actual = dfirstIndexEqual( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 0.0, // 2 + 2.0, // 1 + 0.0, // 0 + 0.0, + 0.0 + ]); + + actual = dfirstIndexEqual( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -233,7 +209,42 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var y0; + var x1; + var y1; + + // Initial arrays... + x0 = new Float64Array([ + 1.0, + 2.0, // 2 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 0 + ]); + y0 = new Float64Array([ + 0.0, + 0.0, + 0.0, + 0.0, // 0 + 4.0, // 1 + 0.0 // 2 + ]); + + // Create offset views... + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at 4th element + + actual = dfirstIndexEqual( 3, x1, -2, y1, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js index 125b8b7bf8d5..9c5729b92f07 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js @@ -55,59 +55,9 @@ tape( 'the function returns the first index of an element which equals a corresp x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, 2, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 3.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -162,8 +112,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -188,12 +138,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -206,16 +156,42 @@ tape( 'the function supports negative strides', opts, function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 - 3.0, // 1 0.0, // 0 + 3.0, // 1 + 0.0, // 2 0.0, 0.0 ]); - actual = dfirstIndexEqual( 3, x, -2, y, -1 ); + actual = dfirstIndexEqual( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 0.0, // 2 + 2.0, // 1 + 0.0, // 0 + 0.0, + 0.0 + ]); + + actual = dfirstIndexEqual( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -242,7 +218,42 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexEqual( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var y0; + var x1; + var y1; + + // Initial arrays... + x0 = new Float64Array([ + 1.0, + 2.0, // 2 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 0 + ]); + y0 = new Float64Array([ + 0.0, + 0.0, + 0.0, + 0.0, // 0 + 4.0, // 1 + 0.0 // 2 + ]); + + // Create offset views... + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at 4th element + + actual = dfirstIndexEqual( 3, x1, -2, y1, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js index 37521df26a4a..7e79c7c0bbe0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js @@ -46,59 +46,9 @@ tape( 'the function returns the first index of an element which equals a corresp x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dfirstIndexEqual( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-1, x, 1, 1, y, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, -2, x.length-1, y, -2, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, -2, x.length-2, y, -2, y.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -153,8 +103,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -179,12 +129,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -197,16 +147,42 @@ tape( 'the function supports negative strides', function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 - 3.0, // 1 0.0, // 0 + 3.0, // 1 + 0.0, // 2 0.0, 0.0 ]); - actual = dfirstIndexEqual( 3, x, -2, 4, y, -1, 2 ); + actual = dfirstIndexEqual( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 0.0, // 2 + 2.0, // 1 + 0.0, // 0 + 0.0, + 0.0 + ]); + actual = dfirstIndexEqual( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -229,8 +205,8 @@ tape( 'the function supports an `x` offset', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, 2, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -253,8 +229,8 @@ tape( 'the function supports a `y` offset', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, 0, y, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -281,7 +257,7 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js index 16adf71860cb..3110b1284286 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js @@ -55,59 +55,9 @@ tape( 'the function returns the first index of an element which equals a corresp x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dfirstIndexEqual( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-1, x, 1, 1, y, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, -2, x.length-1, y, -2, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, -2, x.length-2, y, -2, y.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -162,8 +112,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -188,12 +138,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -206,16 +156,42 @@ tape( 'the function supports negative strides', opts, function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 - 3.0, // 1 0.0, // 0 + 3.0, // 1 + 0.0, // 2 0.0, 0.0 ]); - actual = dfirstIndexEqual( 3, x, -2, 4, y, -1, 2 ); + actual = dfirstIndexEqual( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 0.0, // 2 + 2.0, // 1 + 0.0, // 0 + 0.0, + 0.0 + ]); + actual = dfirstIndexEqual( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -238,8 +214,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, 2, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -262,8 +238,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, 0, y, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -290,7 +266,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexEqual( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/README.md index e3e72fdbac37..5d7e04e736d7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-equal/README.md @@ -55,12 +55,12 @@ var idx = gfirstIndexEqual( x.length, x, 1, y, 1 ); The function has the following parameters: - **N**: number of indexed elements. -- **x**: first input array. +- **x**: first input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. - **strideX**: stride length for `x`. -- **y**: second input array. +- **y**: second input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. - **strideY**: stride length for `y`. -If the function is unable to find matching elements, the function returns `-1`. +If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. ```javascript var x = [ 1.0, 2.0, 3.0, 4.0 ]; @@ -192,6 +192,8 @@ console.log( idx ); @@ -215,8 +215,8 @@ console.log( idx ); Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array. ```c -double x[] = { 0.0, 0.0, 0.0, 0.0 }; -double y[] = { 0.0, 0.0, 1.0, 0.0 }; +const double x[] = { 0.0, 0.0, 0.0, 0.0 }; +const double y[] = { 0.0, 0.0, 1.0, 0.0 }; int idx = stdlib_strided_dfirst_index_less_than( 4, x, 1, y, 1 ); // returns 2 @@ -226,9 +226,9 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **X**: `[in] double*` first input array. -- **strideX**: `[in] CBLAS_INT` stride length. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. - **Y**: `[in] double*` second input array. -- **strideY**: `[in] CBLAS_INT` stride length. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. ```c CBLAS_INT stdlib_strided_dfirst_index_less_than( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY ); @@ -243,8 +243,8 @@ CBLAS_INT stdlib_strided_dfirst_index_less_than( const CBLAS_INT N, const double Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. ```c -double x[] = { 0.0, 0.0, 0.0, 0.0 }; -double y[] = { 0.0, 0.0, 1.0, 0.0 }; +const double x[] = { 0.0, 0.0, 0.0, 0.0 }; +const double y[] = { 0.0, 0.0, 1.0, 0.0 }; int idx = stdlib_strided_dfirst_index_less_than_ndarray( 4, x, 1, 0, y, 1, 0 ); // returns 2 @@ -254,11 +254,11 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **X**: `[in] double*` first input array. -- **strideX**: `[in] CBLAS_INT` stride length. -- **offsetX**: `[in] CBLAS_INT` starting index. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. - **Y**: `[in] double*` second input array. -- **strideY**: `[in] CBLAS_INT` stride length. -- **offsetY**: `[in] CBLAS_INT` starting index. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. ```c CBLAS_INT stdlib_strided_dfirst_index_less_than_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); @@ -294,7 +294,7 @@ int main( void ) { // Specify the number of indexed elements: const int N = 8; - // Specify stride lengths: + // Specify strides: const int strideX = 1; const int strideY = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/repl.txt index 4f8e1407a594..9de1414d2bc9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/repl.txt @@ -63,8 +63,8 @@ precision floating-point strided array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the offset parameters support indexing semantics based on - starting indices. + buffer, the offset parameters support indexing semantics based on starting + indices. Parameters ---------- @@ -102,12 +102,6 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using `N` and stride parameters: - > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - > idx = {{alias}}.ndarray( 3, x, 2, 0, y, 2, 0 ) - 2 - // Using an index offset: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); > y = new {{alias:@stdlib/array/float64}}( [ 9.0, 2.0, 9.0, 9.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/types/test.ts index 2d3f8236839b..98cb0f141d51 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/types/test.ts @@ -39,18 +39,19 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan( false, x, 1, y, 1 ); // $ExpectError dfirstIndexLessThan( null, x, 1, y, 1 ); // $ExpectError dfirstIndexLessThan( {}, x, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... { - var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - dfirstIndexLessThan( x.length, '1', 1, y, 1 ); // $ExpectError - dfirstIndexLessThan( x.length, true, 1, y, 1 ); // $ExpectError - dfirstIndexLessThan( x.length, false, 1, y, 1 ); // $ExpectError - dfirstIndexLessThan( x.length, null, 1, y, 1 ); // $ExpectError - dfirstIndexLessThan( x.length, {}, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, '1', 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, true, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, false, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, null, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, {}, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, ( x: number ): number => x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -63,6 +64,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan( x.length, x, false, y, 1 ); // $ExpectError dfirstIndexLessThan( x.length, x, null, y, 1 ); // $ExpectError dfirstIndexLessThan( x.length, x, {}, y, 1 ); // $ExpectError + dfirstIndexLessThan( x.length, x, ( x: number ): number => x, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... @@ -74,6 +76,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan( x.length, x, 1, false, 1 ); // $ExpectError dfirstIndexLessThan( x.length, x, 1, null, 1 ); // $ExpectError dfirstIndexLessThan( x.length, x, 1, {}, 1 ); // $ExpectError + dfirstIndexLessThan( x.length, x, 1, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... @@ -86,6 +89,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan( x.length, x, 1, y, false ); // $ExpectError dfirstIndexLessThan( x.length, x, 1, y, null ); // $ExpectError dfirstIndexLessThan( x.length, x, 1, y, {} ); // $ExpectError + dfirstIndexLessThan( x.length, x, 1, y, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -94,6 +98,7 @@ import dfirstIndexLessThan = require( './index' ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); dfirstIndexLessThan(); // $ExpectError + dfirstIndexLessThan( 3 ); // $ExpectError dfirstIndexLessThan( 3, x ); // $ExpectError dfirstIndexLessThan( 3, x, 1 ); // $ExpectError dfirstIndexLessThan( 3, x, 1, y ); // $ExpectError @@ -118,18 +123,19 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... { - var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - dfirstIndexLessThan.ndarray( x.length, '1', 1, 0, y, 1, 0 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, true, 1, 0, y, 1, 0 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, false, 1, 0, y, 1, 0 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, null, 1, 0, y, 1, 0 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, {}, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, '1', 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, true, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, false, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, null, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, {}, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -142,6 +148,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -154,6 +161,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float64Array... @@ -165,6 +173,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( x.length, x, 1, 0, false, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, null, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, {}, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( x.length, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... @@ -177,6 +186,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... @@ -189,19 +199,20 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError + dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError } - // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... { var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); dfirstIndexLessThan.ndarray(); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x, 1 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x, 1, 0 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, 0, {} ); // $ExpectError + dfirstIndexLessThan.ndarray( 3 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x, 1 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x, 1, 0, y ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x, 1, 0, y, 1 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x, 1, 0, y, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/examples/c/example.c index 73c81b87173c..e510574d06c6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/examples/c/example.c @@ -27,7 +27,7 @@ int main( void ) { // Specify the number of indexed elements: const int N = 8; - // Specify stride lengths: + // Specify strides: const int strideX = 1; const int strideY = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/package.json b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/package.json index 2dad59ffe2dc..babda7c8b011 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/package.json @@ -59,6 +59,8 @@ "index", "search", "element", + "less", + "compare", "array", "ndarray", "strided", diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/addon.c index f36dbdb54446..a8eda9a52510 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/addon.c @@ -36,8 +36,8 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 5 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 3 ); STDLIB_NAPI_CREATE_INT32( env, API_SUFFIX(stdlib_strided_dfirst_index_less_than)( N, X, strideX, Y, strideY ), idx ); // TODO: Need to revisit in order to support int64_t for CBLAS_INT return idx; @@ -55,9 +55,9 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 4 ); STDLIB_NAPI_CREATE_INT32( env, API_SUFFIX(stdlib_strided_dfirst_index_less_than_ndarray)( N, X, strideX, offsetX, Y, strideY, offsetY ), idx ); // TODO: Need to revisit in order to support int64_t for CBLAS_INT return idx; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/main.c index a0232c3da79e..8d550d93c0ef 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/main.c @@ -23,12 +23,12 @@ /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array. * -* @param N number of indexed elements -* @param X first input array -* @param strideX stride length for X -* @param Y second input array -* @param strideY stride length for Y -* @return index +* @param N number of indexed elements +* @param X first input array +* @param strideX stride length for X +* @param Y second input array +* @param strideY stride length for Y +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dfirst_index_less_than)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); @@ -39,14 +39,14 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dfirst_index_less_than)( const CBLAS_INT N, /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * -* @param N number of indexed elements -* @param X first input array -* @param strideX stride length for X -* @param offsetX starting index for X -* @param Y second input array -* @param strideY stride length for Y -* @param offsetY starting index for Y -* @return index +* @param N number of indexed elements +* @param X first input array +* @param strideX stride length for X +* @param offsetX starting index for X +* @param Y second input array +* @param strideY stride length for Y +* @param offsetY starting index for Y +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dfirst_index_less_than_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { CBLAS_INT ix; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js index 2dcc565a9a20..b044b9615856 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js @@ -46,51 +46,21 @@ tape( 'the function returns the first index of an element which is less than a c x = new Float64Array( [ 6.0, 1.0, 5.0, 5.0, 5.0, 5.0 ] ); y = new Float64Array( [ 5.0, 2.0, 4.0, 4.0, 4.0, 4.0 ] ); - // Nonnegative stride... actual = dfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float64Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, y, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float64Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = dfirstIndexLessThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = dfirstIndexLessThan( 3, x, -2, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float64Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = dfirstIndexLessThan( 3, x, -1, y, -2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 0.0, 1.0, 2.0 ] ); - actual = dfirstIndexLessThan( 3, x, -2, y, -2 ); + actual = dfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -98,16 +68,11 @@ tape( 'the function returns the first index of an element which is less than a c tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = dfirstIndexLessThan( 0, x, 1, y, 1 ); + actual = dfirstIndexLessThan( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dfirstIndexLessThan( -1, x, 1, y, 1 ); + actual = dfirstIndexLessThan( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -155,8 +120,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -181,12 +146,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -198,6 +163,32 @@ tape( 'the function supports negative strides', function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = dfirstIndexLessThan( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 3.0, // 2 2.0, // 1 @@ -206,9 +197,9 @@ tape( 'the function supports negative strides', function test( t ) { 0.0 ]); - actual = dfirstIndexLessThan( 3, x, -2, y, -1 ); - + actual = dfirstIndexLessThan( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -235,8 +226,8 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -271,5 +262,6 @@ tape( 'the function supports view offsets', function test( t ) { actual = dfirstIndexLessThan( 3, x1, -2, y1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js index 688918bff026..4a3accdd7ff7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js @@ -55,51 +55,21 @@ tape( 'the function returns the first index of an element which is less than a c x = new Float64Array( [ 6.0, 1.0, 5.0, 5.0, 5.0, 5.0 ] ); y = new Float64Array( [ 5.0, 2.0, 4.0, 4.0, 4.0, 4.0 ] ); - // Nonnegative stride... actual = dfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float64Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, y, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float64Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = dfirstIndexLessThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = dfirstIndexLessThan( 3, x, -2, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float64Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = dfirstIndexLessThan( 3, x, -1, y, -2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', opts, function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 0.0, 1.0, 2.0 ] ); - actual = dfirstIndexLessThan( 3, x, -2, y, -2 ); + actual = dfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -107,16 +77,11 @@ tape( 'the function returns the first index of an element which is less than a c tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = dfirstIndexLessThan( 0, x, 1, y, 1 ); + actual = dfirstIndexLessThan( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dfirstIndexLessThan( -1, x, 1, y, 1 ); + actual = dfirstIndexLessThan( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -164,8 +129,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -190,12 +155,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -207,6 +172,32 @@ tape( 'the function supports negative strides', opts, function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = dfirstIndexLessThan( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 3.0, // 2 2.0, // 1 @@ -215,9 +206,9 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0 ]); - actual = dfirstIndexLessThan( 3, x, -2, y, -1 ); - + actual = dfirstIndexLessThan( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -244,8 +235,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexLessThan( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -280,5 +271,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { actual = dfirstIndexLessThan( 3, x1, -2, y1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js index 1c7496cdbf87..4d86c846465d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js @@ -46,51 +46,21 @@ tape( 'the function returns the first index of an element which is less than a c x = new Float64Array( [ 6.0, 1.0, 5.0, 5.0, 5.0, 5.0 ] ); y = new Float64Array( [ 5.0, 2.0, 4.0, 4.0, 4.0, 4.0 ] ); - // Nonnegative stride... actual = dfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float64Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float64Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = dfirstIndexLessThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float64Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = dfirstIndexLessThan( 3, x, -1, 2, y, -2, 4 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 0.0, 1.0, 2.0 ] ); - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -2, 4 ); + actual = dfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -98,16 +68,11 @@ tape( 'the function returns the first index of an element which is less than a c tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = dfirstIndexLessThan( 0, x, 1, 0, y, 1, 0 ); + actual = dfirstIndexLessThan( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dfirstIndexLessThan( -1, x, 1, 0, y, 1, 0 ); + actual = dfirstIndexLessThan( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -155,8 +120,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -181,12 +146,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -198,6 +163,32 @@ tape( 'the function supports negative strides', function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = dfirstIndexLessThan( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 3.0, // 2 2.0, // 1 @@ -206,9 +197,9 @@ tape( 'the function supports negative strides', function test( t ) { 0.0 ]); - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - + actual = dfirstIndexLessThan( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -231,8 +222,8 @@ tape( 'the function supports an `x` offset', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 2, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -255,8 +246,8 @@ tape( 'the function supports a `y` offset', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 0, y, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -283,7 +274,7 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js index b475a8171d87..65e6f2e9b2b2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js @@ -55,51 +55,21 @@ tape( 'the function returns the first index of an element which is less than a c x = new Float64Array( [ 6.0, 1.0, 5.0, 5.0, 5.0, 5.0 ] ); y = new Float64Array( [ 5.0, 2.0, 4.0, 4.0, 4.0, 4.0 ] ); - // Nonnegative stride... actual = dfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float64Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float64Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = dfirstIndexLessThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float64Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = dfirstIndexLessThan( 3, x, -1, 2, y, -2, 4 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', opts, function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 0.0, 1.0, 2.0 ] ); - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -2, 4 ); + actual = dfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -107,16 +77,11 @@ tape( 'the function returns the first index of an element which is less than a c tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = dfirstIndexLessThan( 0, x, 1, 0, y, 1, 0 ); + actual = dfirstIndexLessThan( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dfirstIndexLessThan( -1, x, 1, 0, y, 1, 0 ); + actual = dfirstIndexLessThan( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -164,8 +129,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -190,12 +155,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -207,6 +172,32 @@ tape( 'the function supports negative strides', opts, function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = dfirstIndexLessThan( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 3.0, // 2 2.0, // 1 @@ -215,9 +206,9 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0 ]); - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - + actual = dfirstIndexLessThan( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -240,8 +231,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 2, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -264,8 +255,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 0, y, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -292,7 +283,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexLessThan( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/README.md index faa848dfae6e..cbe31ae369a4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than/README.md @@ -55,9 +55,9 @@ var idx = gfirstIndexLessThan( x.length, x, 1, y, 1 ); The function has the following parameters: - **N**: number of indexed elements. -- **x**: first input array. +- **x**: first input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. - **strideX**: stride length for `x`. -- **y**: second input array. +- **y**: second input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. - **strideY**: stride length for `y`. If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. @@ -135,7 +135,7 @@ var idx = gfirstIndexLessThan.ndarray( 3, x, 1, x.length-3, y, 1, y.length-3 ); ## Notes -- When comparing elements, the function checks whether an element in `x` is less than a corresponding element in `y` using the less-than operator `<`. As a consequence, comparisons involving `NaN` always evaluate to `false`. +- When comparing elements, the function checks whether an element in `x` is less than a corresponding element in `y` using 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]).
@@ -192,6 +192,8 @@ console.log( idx ); @@ -145,7 +145,7 @@ var idx = sfirstIndexLessThan.ndarray( 3, x, 1, x.length-3, y, 1, y.length-3 ); ## Notes -- When comparing elements, the function checks whether an element in `x` is less than a corresponding element in `y` using the less-than operator `<`. As a consequence, comparisons involving `NaN` always evaluate to `false`. +- When comparing elements, the function checks whether an element in `x` is less than a corresponding element in `y` using the less-than operator `<`. As a consequence, comparisons involving `NaN` always evaluate to `false`, and `-0` and `+0` are considered the same. diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/repl.txt index 83d795dbc721..a8eccdcc3b42 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/repl.txt @@ -4,7 +4,7 @@ strided array which is less than a corresponding element in another single- precision floating-point strided array. - The `N` and stride parameters determine which elements in the strided array + The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/types/test.ts index f170cae22dbb..227e00f050c1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/docs/types/test.ts @@ -39,6 +39,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan( false, x, 1, y, 1 ); // $ExpectError sfirstIndexLessThan( null, x, 1, y, 1 ); // $ExpectError sfirstIndexLessThan( {}, x, 1, y, 1 ); // $ExpectError + sfirstIndexLessThan( ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float32Array... @@ -51,6 +52,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan( x.length, false, 1, y, 1 ); // $ExpectError sfirstIndexLessThan( x.length, null, 1, y, 1 ); // $ExpectError sfirstIndexLessThan( x.length, {}, 1, y, 1 ); // $ExpectError + sfirstIndexLessThan( x.length, ( x: number ): number => x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -63,6 +65,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan( x.length, x, false, y, 1 ); // $ExpectError sfirstIndexLessThan( x.length, x, null, y, 1 ); // $ExpectError sfirstIndexLessThan( x.length, x, {}, y, 1 ); // $ExpectError + sfirstIndexLessThan( x.length, x, ( x: number ): number => x, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a Float32Array... @@ -74,6 +77,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan( x.length, x, 1, false, 1 ); // $ExpectError sfirstIndexLessThan( x.length, x, 1, null, 1 ); // $ExpectError sfirstIndexLessThan( x.length, x, 1, {}, 1 ); // $ExpectError + sfirstIndexLessThan( x.length, x, 1, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... @@ -86,6 +90,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan( x.length, x, 1, y, false ); // $ExpectError sfirstIndexLessThan( x.length, x, 1, y, null ); // $ExpectError sfirstIndexLessThan( x.length, x, 1, y, {} ); // $ExpectError + sfirstIndexLessThan( x.length, x, 1, y, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -118,6 +123,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError + sfirstIndexLessThan.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float32Array... @@ -130,6 +136,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan.ndarray( x.length, false, 1, 0, y, 1, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, null, 1, 0, y, 1, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, {}, 1, 0, y, 1, 0 ); // $ExpectError + sfirstIndexLessThan.ndarray( x.length, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -142,6 +149,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError + sfirstIndexLessThan.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError } @@ -155,6 +163,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError + sfirstIndexLessThan.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float32Array... @@ -166,6 +175,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan.ndarray( x.length, x, 1, 0, false, 1, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, x, 1, 0, null, 1, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, x, 1, 0, {}, 1, 0 ); // $ExpectError + sfirstIndexLessThan.ndarray( x.length, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... @@ -178,6 +188,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError + sfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... @@ -190,6 +201,7 @@ import sfirstIndexLessThan = require( './index' ); sfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError sfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError + sfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/package.json b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/package.json index 6c616d72f653..81aa340fdc2d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/package.json @@ -59,10 +59,11 @@ "index", "search", "element", + "less", + "compare", "array", "ndarray", "strided", - "single", "float", "float32", "float32array" diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/src/addon.c index 25ee6041082d..46455771a271 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/src/addon.c @@ -55,9 +55,9 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 4 ); STDLIB_NAPI_CREATE_INT32( env, API_SUFFIX(stdlib_strided_sfirst_index_less_than_ndarray)( N, X, strideX, offsetX, Y, strideY, offsetY ), idx ); // TODO: Need to revisit in order to support int64_t for CBLAS_INT return idx; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/src/main.c index 4f77233603e3..aaba66a3d753 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/src/main.c @@ -23,12 +23,12 @@ /** * Returns the index of the first element in a single-precision floating-point strided array which is less than a corresponding element in another single-precision floating-point strided array. * -* @param N number of indexed elements -* @param X first input array -* @param strideX stride length for X -* @param Y second input array -* @param strideY stride length for Y -* @return index +* @param N number of indexed elements +* @param X first input array +* @param strideX stride length for X +* @param Y second input array +* @param strideY stride length for Y +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_sfirst_index_less_than)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); @@ -39,14 +39,14 @@ CBLAS_INT API_SUFFIX(stdlib_strided_sfirst_index_less_than)( const CBLAS_INT N, /** * Returns the index of the first element in a single-precision floating-point strided array which is less than a corresponding element in another single-precision floating-point strided array using alternative indexing semantics. * -* @param N number of indexed elements -* @param X first input array -* @param strideX stride length for X -* @param offsetX starting index for X -* @param Y second input array -* @param strideY stride length for Y -* @param offsetY starting index for Y -* @return index +* @param N number of indexed elements +* @param X first input array +* @param strideX stride length for X +* @param offsetX starting index for X +* @param Y second input array +* @param strideY stride length for Y +* @param offsetY starting index for Y +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_sfirst_index_less_than_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { CBLAS_INT ix; diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.js index 9417876679f1..d5666ab7a686 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.js @@ -46,51 +46,21 @@ tape( 'the function returns the first index of an element which is less than a c x = new Float32Array( [ 6.0, 1.0, 5.0, 5.0, 5.0, 5.0 ] ); y = new Float32Array( [ 5.0, 2.0, 4.0, 4.0, 4.0, 4.0 ] ); - // Nonnegative stride... actual = sfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float32Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float32Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float32Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - x = new Float32Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float32Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = sfirstIndexLessThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float32Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float32Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = sfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float32Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float32Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = sfirstIndexLessThan( 3, x, -1, 2, y, -2, 4 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; - x = new Float32Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float32Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float32Array( [ 0.0, 1.0, 2.0 ] ); - actual = sfirstIndexLessThan( 3, x, -2, 4, y, -2, 4 ); + actual = sfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -98,16 +68,11 @@ tape( 'the function returns the first index of an element which is less than a c tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - var y; - - x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - actual = sfirstIndexLessThan( 0, x, 1, 0, y, 1, 0 ); + actual = sfirstIndexLessThan( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = sfirstIndexLessThan( -1, x, 1, 0, y, 1, 0 ); + actual = sfirstIndexLessThan( -1, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -155,8 +120,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = sfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -181,12 +146,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = sfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -198,6 +163,32 @@ tape( 'the function supports negative strides', function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float32Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = sfirstIndexLessThan( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float32Array([ 3.0, // 2 2.0, // 1 @@ -206,9 +197,9 @@ tape( 'the function supports negative strides', function test( t ) { 0.0 ]); - actual = sfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - + actual = sfirstIndexLessThan( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -231,8 +222,8 @@ tape( 'the function supports an `x` offset', function test( t ) { ]); actual = sfirstIndexLessThan( 3, x, 1, 2, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -255,8 +246,8 @@ tape( 'the function supports a `y` offset', function test( t ) { ]); actual = sfirstIndexLessThan( 3, x, 1, 0, y, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -283,7 +274,7 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = sfirstIndexLessThan( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.native.js index 8dd8b827b407..f7e2ee7b6c3d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.ndarray.native.js @@ -55,51 +55,21 @@ tape( 'the function returns the first index of an element which is less than a c x = new Float32Array( [ 6.0, 1.0, 5.0, 5.0, 5.0, 5.0 ] ); y = new Float32Array( [ 5.0, 2.0, 4.0, 4.0, 4.0, 4.0 ] ); - // Nonnegative stride... actual = sfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float32Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float32Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float32Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - x = new Float32Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float32Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = sfirstIndexLessThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float32Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float32Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = sfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float32Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float32Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = sfirstIndexLessThan( 3, x, -1, 2, y, -2, 4 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', opts, function test( t ) { + var actual; + var x; + var y; - x = new Float32Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float32Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float32Array( [ 0.0, 1.0, 2.0 ] ); - actual = sfirstIndexLessThan( 3, x, -2, 4, y, -2, 4 ); + actual = sfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -107,16 +77,11 @@ tape( 'the function returns the first index of an element which is less than a c tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - var x; - var y; - - x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - actual = sfirstIndexLessThan( 0, x, 1, 0, y, 1, 0 ); + actual = sfirstIndexLessThan( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = sfirstIndexLessThan( -1, x, 1, 0, y, 1, 0 ); + actual = sfirstIndexLessThan( -1, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -164,8 +129,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = sfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -190,12 +155,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = sfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -207,6 +172,32 @@ tape( 'the function supports negative strides', opts, function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float32Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = sfirstIndexLessThan( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float32Array([ 3.0, // 2 2.0, // 1 @@ -215,9 +206,9 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0 ]); - actual = sfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - + actual = sfirstIndexLessThan( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -240,8 +231,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { ]); actual = sfirstIndexLessThan( 3, x, 1, 2, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -264,8 +255,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { ]); actual = sfirstIndexLessThan( 3, x, 1, 0, y, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -292,7 +283,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = sfirstIndexLessThan( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.js index 7076c8f5a93e..1f67b5a9bc47 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.js @@ -49,46 +49,18 @@ tape( 'the function returns the first index of an element which is less than a c actual = sfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float32Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float32Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float32Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 2, y, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float32Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float32Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = sfirstIndexLessThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float32Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float32Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = sfirstIndexLessThan( 3, x, -2, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float32Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float32Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = sfirstIndexLessThan( 3, x, -1, y, -2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; - x = new Float32Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float32Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float32Array( [ 0.0, 1.0, 2.0 ] ); - actual = sfirstIndexLessThan( 3, x, -2, y, -2 ); + actual = sfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -96,16 +68,11 @@ tape( 'the function returns the first index of an element which is less than a c tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - var y; - x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float32Array( [ 2.0, 3.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 0, x, 1, y, 1 ); + actual = sfirstIndexLessThan( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = sfirstIndexLessThan( -1, x, 1, y, 1 ); + actual = sfirstIndexLessThan( -1, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -114,10 +81,10 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; - actual = sfirstIndexLessThan( 1, new Float32Array( [ NaN ] ), 1, new Float32Array( [ 0.0 ] ), 1 ); // eslint-disable-line max-len + actual = sfirstIndexLessThan( 1, new Float32Array( [ NaN ] ), 1, new Float32Array( [ 0.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = sfirstIndexLessThan( 1, new Float32Array( [ 0.0 ] ), 1, new Float32Array( [ NaN ] ), 1 ); // eslint-disable-line max-len + actual = sfirstIndexLessThan( 1, new Float32Array( [ 0.0 ] ), 1, new Float32Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -126,7 +93,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', function tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; - actual = sfirstIndexLessThan( 1, new Float32Array( [ -0.0 ] ), 1, new Float32Array( [ 0.0 ] ), 1 ); // eslint-disable-line max-len + actual = sfirstIndexLessThan( 1, new Float32Array( [ -0.0 ] ), 1, new Float32Array( [ 0.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -184,7 +151,7 @@ tape( 'the function supports a `y` stride', function test( t ) { t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -196,6 +163,32 @@ tape( 'the function supports negative strides', function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float32Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = sfirstIndexLessThan( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float32Array([ 3.0, // 2 2.0, // 1 @@ -204,7 +197,7 @@ tape( 'the function supports negative strides', function test( t ) { 0.0 ]); - actual = sfirstIndexLessThan( 3, x, -2, y, -1 ); + actual = sfirstIndexLessThan( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.native.js index e88539f0813b..32f6ca59ef67 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/sfirst-index-less-than/test/test.sfirst_index_less_than.native.js @@ -55,51 +55,21 @@ tape( 'the function returns the first index of an element which is less than a c x = new Float32Array( [ 6.0, 1.0, 5.0, 5.0, 5.0, 5.0 ] ); y = new Float32Array( [ 5.0, 2.0, 4.0, 4.0, 4.0, 4.0 ] ); - // Nonnegative stride... actual = sfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float32Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float32Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float32Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float32Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = sfirstIndexLessThan( 3, x, 2, y, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - x = new Float32Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float32Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = sfirstIndexLessThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float32Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float32Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = sfirstIndexLessThan( 3, x, -2, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float32Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float32Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = sfirstIndexLessThan( 3, x, -1, y, -2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', opts, function test( t ) { + var actual; + var x; + var y; - x = new Float32Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float32Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float32Array( [ 0.0, 1.0, 2.0 ] ); - actual = sfirstIndexLessThan( 3, x, -2, y, -2 ); + actual = sfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -107,16 +77,11 @@ tape( 'the function returns the first index of an element which is less than a c tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - var x; - var y; - - x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - actual = sfirstIndexLessThan( 0, x, 1, y, 1 ); + actual = sfirstIndexLessThan( 0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = sfirstIndexLessThan( -1, x, 1, y, 1 ); + actual = sfirstIndexLessThan( -1, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -164,8 +129,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = sfirstIndexLessThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -190,12 +155,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = sfirstIndexLessThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -207,6 +172,32 @@ tape( 'the function supports negative strides', opts, function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float32Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = sfirstIndexLessThan( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float32Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float32Array([ 3.0, // 2 2.0, // 1 @@ -215,9 +206,9 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0 ]); - actual = sfirstIndexLessThan( 3, x, -2, y, -1 ); - + actual = sfirstIndexLessThan( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -244,8 +235,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = sfirstIndexLessThan( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -280,5 +271,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { actual = sfirstIndexLessThan( 3, x1, -2, y1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); From 81d1382cd46cbe38946d384a675468f7017b159d Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 11 Sep 2026 14:25:05 +0500 Subject: [PATCH 36/68] fix: apply consistency fixes to `first-index-less-than-equal` --- .../gfirst-index-less-than-equal/README.md | 8 +- .../docs/repl.txt | 6 - .../docs/types/test.ts | 4 +- .../test/test.main.js | 175 ++++++++--------- .../test/test.ndarray.js | 182 +++++++++--------- 5 files changed, 177 insertions(+), 198 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/README.md index 4c2f9e324a69..f2cc4dd32686 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-less-than-equal/README.md @@ -55,9 +55,9 @@ var idx = gfirstIndexLessThanEqual( x.length, x, 1, y, 1 ); The function has the following parameters: - **N**: number of indexed elements. -- **x**: first input array. +- **x**: first input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. - **strideX**: stride length for `x`. -- **y**: second input array. +- **y**: second input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. - **strideY**: stride length for `y`. If the function is unable to find an element in `x` which is less than or equal to a corresponding element in `y`, the function returns `-1`. @@ -117,8 +117,6 @@ The function has the following additional parameters: While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to access only the last three elements of each strided array: - - ```javascript var x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; var y = [ 9.0, 9.0, 9.0, 0.0, 5.0, 9.0 ]; @@ -194,6 +192,8 @@ console.log( idx ); @@ -222,8 +220,8 @@ console.log( idx ); Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array. ```c -double x[] = { 1.0, 2.0, 3.0, 4.0 }; -double y[] = { 2.0, 2.0, 2.0, 2.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double y[] = { 2.0, 2.0, 2.0, 2.0 }; int idx = stdlib_strided_dfirst_index_greater_than( 4, x, 1, y, 1 ); // returns 2 @@ -250,8 +248,8 @@ CBLAS_INT stdlib_strided_dfirst_index_greater_than( const CBLAS_INT N, const dou Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. ```c -double x[] = { 1.0, 2.0, 3.0, 4.0 }; -double y[] = { 2.0, 2.0, 2.0, 2.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double y[] = { 2.0, 2.0, 2.0, 2.0 }; int idx = stdlib_strided_dfirst_index_greater_than_ndarray( 4, x, 1, 0, y, 1, 0 ); // returns 2 @@ -295,8 +293,8 @@ CBLAS_INT stdlib_strided_dfirst_index_greater_than_ndarray( const CBLAS_INT N, c int main( void ) { // Create strided arrays: - double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; - double y[] = { 9.0, 9.0, 9.0, 9.0, 4.0, 9.0, 9.0, 9.0 }; + const double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; + const double y[] = { 9.0, 9.0, 9.0, 9.0, 4.0, 9.0, 9.0, 9.0 }; // Specify the number of indexed elements: const int N = 8; @@ -305,11 +303,11 @@ int main( void ) { const int strideX = 1; const int strideY = 1; - // Find the first index of an element which is greater than a corresponding element: + // Perform a search: int idx = stdlib_strided_dfirst_index_greater_than( N, x, strideX, y, strideY ); // Print the result: - printf( "first index: %d\n", idx ); + printf( "index value: %d\n", idx ); } ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/benchmark/benchmark.js index 1c9a52ad8e0f..92a99e78c165 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/benchmark/benchmark.js @@ -26,7 +26,7 @@ var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; var ones = require( '@stdlib/array/ones' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; -var dfirstIndexGreaterThan = require( './../lib' ); +var dfirstIndexGreaterThan = require( './../lib/dfirst_index_greater_than.js' ); // FUNCTIONS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt index 9238ca9dff83..4419c21435fc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt @@ -49,12 +49,12 @@ 1 // Using view offsets: - > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0 ] ); - > var y0 = new {{alias:@stdlib/array/float64}}( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*2 ); - > idx = {{alias}}( 3, x1, 2, y1, 2 ) - -1 + > var y0 = new {{alias:@stdlib/array/float64}}( [ 9.0, 9.0, 0.0, 9.0 ] ); + > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 2, x1, 1, y1, 1 ) + 1 {{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) @@ -64,8 +64,8 @@ semantics. While typed array views mandate a view offset based on the underlying - buffer, the offset parameters support indexing semantics based on - starting indices. + buffer, the offset parameters support indexing semantics based on starting + indices. Parameters ---------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/index.d.ts index 8c35974f4b62..52fbe2c9f28d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/index.d.ts @@ -42,7 +42,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * - * var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); + * var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); * // returns 2 */ ( N: number, x: Float64Array, strideX: number, y: Float64Array, strideY: number ): number; @@ -69,7 +69,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * - * var idx = dfirstIndexGreaterThan.ndarray( 4, x, 1, 0, y, 1, 0 ); + * var idx = dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ ndarray( N: number, x: Float64Array, strideX: number, offsetX: number, y: Float64Array, strideY: number, offsetY: number ): number; @@ -95,7 +95,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); * // returns 2 * * @example @@ -104,7 +104,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan.ndarray( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ declare const dfirstIndexGreaterThan: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/test.ts index 84d545dbf597..ba55d0b5cb61 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/test.ts @@ -39,6 +39,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan( false, x, 1, y, 1 ); // $ExpectError dfirstIndexGreaterThan( null, x, 1, y, 1 ); // $ExpectError dfirstIndexGreaterThan( {}, x, 1, y, 1 ); // $ExpectError + dfirstIndexGreaterThan( ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... @@ -50,6 +51,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan( 3, false, 1, y, 1 ); // $ExpectError dfirstIndexGreaterThan( 3, null, 1, y, 1 ); // $ExpectError dfirstIndexGreaterThan( 3, {}, 1, y, 1 ); // $ExpectError + dfirstIndexGreaterThan( 3, ( x: number ): number => x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -62,6 +64,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan( x.length, x, false, y, 1 ); // $ExpectError dfirstIndexGreaterThan( x.length, x, null, y, 1 ); // $ExpectError dfirstIndexGreaterThan( x.length, x, {}, y, 1 ); // $ExpectError + dfirstIndexGreaterThan( x.length, x, ( x: number ): number => x, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... @@ -73,6 +76,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan( x.length, x, 1, false, 1 ); // $ExpectError dfirstIndexGreaterThan( x.length, x, 1, null, 1 ); // $ExpectError dfirstIndexGreaterThan( x.length, x, 1, {}, 1 ); // $ExpectError + dfirstIndexGreaterThan( x.length, x, 1, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... @@ -85,6 +89,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan( x.length, x, 1, y, false ); // $ExpectError dfirstIndexGreaterThan( x.length, x, 1, y, null ); // $ExpectError dfirstIndexGreaterThan( x.length, x, 1, y, {} ); // $ExpectError + dfirstIndexGreaterThan( x.length, x, 1, y, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -118,6 +123,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -129,6 +135,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( 3, false, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( 3, null, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( 3, {}, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( 3, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -141,6 +148,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -153,6 +161,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float64Array... @@ -164,6 +173,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, false, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, null, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, {}, 1, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... @@ -176,6 +186,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... @@ -188,6 +199,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError + dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/examples/c/example.c index 81f9efc0bfcf..c993558c7799 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/examples/c/example.c @@ -31,9 +31,9 @@ int main( void ) { const int strideX = 1; const int strideY = 1; - // Find the first index of an element which is greater than a corresponding element: + // Perform a search: int idx = stdlib_strided_dfirst_index_greater_than( N, x, strideX, y, strideY ); // Print the result: - printf( "first index: %d\n", idx ); + printf( "index value: %d\n", idx ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js index 5fcc94d36e22..2a0c34d0e1eb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js @@ -46,7 +46,7 @@ var ndarray = require( './ndarray.js' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); * // returns 2 */ function dfirstIndexGreaterThan( N, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js index 25135ebfee62..a293c1de8068 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js @@ -45,7 +45,7 @@ var addon = require( './../src/addon.node' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); * // returns 2 */ function dfirstIndexGreaterThan( N, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/index.js index 6ac7f1babca2..c91443bf1b49 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/index.js @@ -30,7 +30,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); * // returns 2 * * @example @@ -40,7 +40,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan.ndarray( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js index 94ad57706123..1d258ea60424 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js @@ -42,7 +42,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ function dfirstIndexGreaterThan( N, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js index 20871b983b8d..6afab6a0ef42 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js @@ -47,7 +47,7 @@ var addon = require( './../src/addon.node' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ function dfirstIndexGreaterThan( N, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js index acc3478511be..953e7e0a259b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js @@ -46,59 +46,23 @@ tape( 'the function returns the first index of an element which is greater than x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - // Nonnegative stride... actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ] ); + t.end(); +}); - actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is greater than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 2.0, 3.0, 4.0 ] ); actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, 2, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 0.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -156,8 +120,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -182,12 +146,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -199,6 +163,32 @@ tape( 'the function supports negative strides', function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]); + + actual = dfirstIndexGreaterThan( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 9.0, // 2 0.0, // 1 @@ -207,9 +197,9 @@ tape( 'the function supports negative strides', function test( t ) { 9.0 ]); - actual = dfirstIndexGreaterThan( 3, x, -2, y, -1 ); - + actual = dfirstIndexGreaterThan( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -236,8 +226,8 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -272,5 +262,6 @@ tape( 'the function supports view offsets', function test( t ) { actual = dfirstIndexGreaterThan( 3, x1, -2, y1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js index 4ed4d49c9cdd..0c434fe87435 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js @@ -55,59 +55,23 @@ tape( 'the function returns the first index of an element which is greater than x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - // Nonnegative stride... actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ] ); + t.end(); +}); - actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is greater than a corresponding element in another array', opts, function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 2.0, 3.0, 4.0 ] ); actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, 2, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 0.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -165,8 +129,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -191,12 +155,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -208,6 +172,32 @@ tape( 'the function supports negative strides', opts, function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]); + + actual = dfirstIndexGreaterThan( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 9.0, // 2 0.0, // 1 @@ -216,9 +206,9 @@ tape( 'the function supports negative strides', opts, function test( t ) { 9.0 ]); - actual = dfirstIndexGreaterThan( 3, x, -2, y, -1 ); - + actual = dfirstIndexGreaterThan( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -245,8 +235,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexGreaterThan( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -281,5 +271,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { actual = dfirstIndexGreaterThan( 3, x1, -2, y1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js index 98710d07dbeb..c9ca07f3c275 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js @@ -46,57 +46,21 @@ tape( 'the function returns the first index of an element which is greater than x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - // Nonnegative stride... actual = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-1, x, 1, 1, y, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, -2, x.length-1, y, -2, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + t.end(); +}); - actual = dfirstIndexGreaterThan( 3, x, -2, x.length-2, y, -2, y.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is greater than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 2.0, 3.0, 4.0 ] ); - actual = dfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); + actual = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -156,8 +120,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -182,12 +146,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -199,6 +163,32 @@ tape( 'the function supports negative strides', function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]); + + actual = dfirstIndexGreaterThan( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 9.0, // 2 0.0, // 1 @@ -207,9 +197,9 @@ tape( 'the function supports negative strides', function test( t ) { 9.0 ]); - actual = dfirstIndexGreaterThan( 3, x, -2, 4, y, -1, 2 ); - + actual = dfirstIndexGreaterThan( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -240,8 +230,8 @@ tape( 'the function supports an `x` offset', function test( t ) { ]); actual = dfirstIndexGreaterThan( 4, x, 2, 1, y, 1, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -272,8 +262,8 @@ tape( 'the function supports a `y` offset', function test( t ) { ]); actual = dfirstIndexGreaterThan( 4, x, 1, 0, y, 2, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -300,7 +290,7 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js index 0577ee220042..edcc4700711b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js @@ -55,57 +55,21 @@ tape( 'the function returns the first index of an element which is greater than x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - // Nonnegative stride... actual = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-1, x, 1, 1, y, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, -2, x.length-1, y, -2, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + t.end(); +}); - actual = dfirstIndexGreaterThan( 3, x, -2, x.length-2, y, -2, y.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is greater than a corresponding element in another array', opts, function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 2.0, 3.0, 4.0 ] ); - actual = dfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); + actual = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -165,8 +129,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -191,12 +155,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -208,6 +172,32 @@ tape( 'the function supports negative strides', opts, function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]); + + actual = dfirstIndexGreaterThan( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 9.0, // 2 0.0, // 1 @@ -216,9 +206,9 @@ tape( 'the function supports negative strides', opts, function test( t ) { 9.0 ]); - actual = dfirstIndexGreaterThan( 3, x, -2, 4, y, -1, 2 ); - + actual = dfirstIndexGreaterThan( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -249,8 +239,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 4, x, 2, 1, y, 1, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -281,8 +271,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 4, x, 1, 0, y, 2, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -309,7 +299,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/README.md index 87b03420cbdf..7a2118ef1d58 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/README.md @@ -55,9 +55,9 @@ var idx = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); The function has the following parameters: - **N**: number of indexed elements. -- **x**: first input array. +- **x**: first input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. - **strideX**: stride length for `x`. -- **y**: second input array. +- **y**: second input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. - **strideY**: stride length for `y`. If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. @@ -121,8 +121,6 @@ The function has the following additional parameters: While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to access only the last three elements of each strided array: - - ```javascript var x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; var y = [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ]; @@ -141,7 +139,7 @@ var idx = gfirstIndexGreaterThan.ndarray( 3, x, 1, x.length-3, y, 1, y.length-3 ## Notes -- When comparing elements, the function checks whether an element in `x` is greater than a corresponding element in `y` using the greater-than operator `>`. As a consequence, comparisons involving `NaN` always evaluate to `false`. +- When comparing elements, the function checks whether an element in `x` is greater than a corresponding element in `y` using the greater-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]). @@ -198,6 +196,8 @@ console.log( idx );