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 new file mode 100644 index 000000000000..87b03420cbdf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/README.md @@ -0,0 +1,207 @@ + + +# gfirstIndexGreaterThan + +> Return the index of the first element in a strided array which is greater than a corresponding element in another strided array. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var gfirstIndexGreaterThan = require( '@stdlib/blas/ext/base/gfirst-index-greater-than' ); +``` + +#### gfirstIndexGreaterThan( N, x, strideX, y, strideY ) + +Returns the index of the first element in a strided array which is greater than a corresponding element in another strided array. + +```javascript +var x = [ 1.0, 2.0, 3.0, 4.0 ]; +var y = [ 2.0, 2.0, 2.0, 2.0 ]; + +var idx = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); +// returns 2 +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **x**: first input array. +- **strideX**: stride length for `x`. +- **y**: second input 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`. + +```javascript +var x = [ 1.0, 2.0, 3.0, 4.0 ]; +var y = [ 5.0, 6.0, 7.0, 8.0 ]; + +var idx = gfirstIndexGreaterThan( 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 compare every other element: + +```javascript +var x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; +var y = [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ]; + +var idx = gfirstIndexGreaterThan( 3, x, 2, y, 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 Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var y0 = new Float64Array( [ 9.0, 9.0, 0.0, 9.0 ] ); + +// Create offset views... +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Find index... +var idx = gfirstIndexGreaterThan( 2, x1, 1, y1, 1 ); +// returns 1 +``` + + + +#### gfirstIndexGreaterThan.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) + + + +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. + +```javascript +var x = [ 1.0, 2.0, 3.0, 4.0 ]; +var y = [ 2.0, 2.0, 2.0, 2.0 ]; + +var idx = gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); +// returns 2 +``` + +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 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 ]; + +var idx = gfirstIndexGreaterThan.ndarray( 3, x, 1, x.length-3, y, 1, y.length-3 ); +// returns 0 +``` + +
+ + + + + +
+ +## 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`. +- 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]). + +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var gfirstIndexGreaterThan = require( '@stdlib/blas/ext/base/gfirst-index-greater-than' ); + +var x = discreteUniform( 10, 0, 10, { + 'dtype': 'generic' +}); +console.log( x ); + +var y = discreteUniform( 10, 0, 10, { + 'dtype': 'generic' +}); +console.log( y ); + +var idx = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); +console.log( idx ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/benchmark/benchmark.js new file mode 100644 index 000000000000..851f28a2ceff --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/benchmark/benchmark.js @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +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 gfirstIndexGreaterThan = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = ones( len, 'float64' ); + var y = ones( len, 'float64' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); + if ( out !== out ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( out ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..25bda681442c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/benchmark/benchmark.ndarray.js @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +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 gfirstIndexGreaterThan = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = ones( len, 'float64' ); + var y = ones( len, 'float64' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = gfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); + if ( out !== out ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( out ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + f = createBenchmark( len ); + bench( format( '%s:ndarray:len=%d', pkg, len ), f ); + } +} + +main(); 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 new file mode 100644 index 000000000000..e8e12501a6f3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/docs/repl.txt @@ -0,0 +1,111 @@ + +{{alias}}( N, x, strideX, y, strideY ) + Returns the index of the first element in a strided array which is greater + than a corresponding element in another 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 + array view. + + If `N <= 0`, the function returns `-1`. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Array|TypedArray + First input array. + + strideX: integer + Stride length for `x`. + + y: Array|TypedArray + Second input array. + + strideY: integer + Stride length for `y`. + + Returns + ------- + idx: integer + Index. + + Examples + -------- + // Standard usage: + > var x = [ 1.0, 2.0, 3.0, 4.0 ]; + > var y = [ 2.0, 2.0, 2.0, 2.0 ]; + > var idx = {{alias}}( x.length, x, 1, y, 1 ) + 2 + + // Using `N` and stride parameters: + > x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; + > y = [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ]; + > idx = {{alias}}( 3, x, 2, y, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var y0 = new {{alias:@stdlib/array/float64}}( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.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 + + +{{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) + 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. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on + starting indices. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Array|TypedArray + First input array. + + strideX: integer + Stride length for `x`. + + offsetX: integer + Starting index for `x`. + + y: Array|TypedArray + Second input array. + + strideY: integer + Stride length for `y`. + + offsetY: integer + Starting index for `y`. + + Returns + ------- + idx: integer + Index. + + Examples + -------- + // Standard usage: + > var x = [ 1.0, 2.0, 3.0, 4.0 ]; + > var y = [ 2.0, 2.0, 2.0, 2.0 ]; + > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) + 2 + + // Using offsets: + > x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; + > y = [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ]; + > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) + -1 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/docs/types/index.d.ts new file mode 100644 index 000000000000..60eeba2e4494 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/docs/types/index.d.ts @@ -0,0 +1,116 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; + +/** +* Input array. +*/ +type InputArray = Collection | AccessorArrayLike; + +/** +* Interface describing `gfirstIndexGreaterThan`. +*/ +interface Routine { + /** + * 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 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` + * @returns index + * + * @example + * var x = [ 1.0, 2.0, 3.0, 4.0 ]; + * var y = [ 2.0, 2.0, 2.0, 2.0 ]; + * + * var idx = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); + * // returns 2 + */ + ( N: number, x: InputArray, strideX: number, y: InputArray, strideY: number ): number; + + /** + * 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 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` + * @returns index + * + * @example + * var x = [ 1.0, 2.0, 3.0, 4.0 ]; + * var y = [ 2.0, 2.0, 2.0, 2.0 ]; + * + * var idx = gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); + * // returns 2 + */ + ndarray( N: number, x: InputArray, strideX: number, offsetX: number, y: InputArray, strideY: number, offsetY: number ): number; +} + +/** +* 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 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` +* @returns index +* +* @example +* var x = [ 1.0, 2.0, 3.0, 4.0 ]; +* var y = [ 2.0, 2.0, 2.0, 2.0 ]; +* +* var idx = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); +* // returns 2 +* +* @example +* var x = [ 1.0, 2.0, 3.0, 4.0 ]; +* var y = [ 2.0, 2.0, 2.0, 2.0 ]; +* +* var idx = gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); +* // returns 2 +*/ +declare var gfirstIndexGreaterThan: Routine; + + +// EXPORTS // + +export = gfirstIndexGreaterThan; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/docs/types/test.ts new file mode 100644 index 000000000000..fa8e84b4573d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/docs/types/test.ts @@ -0,0 +1,237 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import AccessorArray = require( '@stdlib/array/base/accessor' ); +import gfirstIndexGreaterThan = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + var x = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); // $ExpectType number + gfirstIndexGreaterThan( x.length, new AccessorArray( x ), 1, new AccessorArray( y ), 1 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + var x = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan( '1', x, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( true, x, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( false, x, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( null, x, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( undefined, x, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( [], x, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( {}, x, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( ( 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 collection... +{ + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan( 3, 10, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( 3, true, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( 3, false, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( 3, null, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( 3, undefined, 1, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( 3, {}, 1, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + var x = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan( x.length, x, '1', y, 1 ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, true, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, false, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, null, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, undefined, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, [], y, 1 ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, {}, y, 1 ); // $ExpectError + gfirstIndexGreaterThan( 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 collection... +{ + var x = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan( x.length, x, 1, 10, 1 ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, 1, true, 1 ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, 1, false, 1 ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, 1, null, 1 ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, 1, undefined, 1 ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, 1, {}, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + var x = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan( x.length, x, 1, y, '1' ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, 1, y, true ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, 1, y, false ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, 1, y, null ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, 1, y, undefined ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, 1, y, [] ); // $ExpectError + gfirstIndexGreaterThan( x.length, x, 1, y, {} ); // $ExpectError + gfirstIndexGreaterThan( 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... +{ + var x = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan(); // $ExpectError + gfirstIndexGreaterThan( 3 ); // $ExpectError + gfirstIndexGreaterThan( 3, x ); // $ExpectError + gfirstIndexGreaterThan( 3, x, 1 ); // $ExpectError + gfirstIndexGreaterThan( 3, x, 1, y ); // $ExpectError + gfirstIndexGreaterThan( 3, x, 1, y, 1, {} ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + var x = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); // $ExpectType number + gfirstIndexGreaterThan.ndarray( x.length, new AccessorArray( x ), 1, 0, new AccessorArray( y ), 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 = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan.ndarray( '1', x, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( true, x, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( undefined, x, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( [], x, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.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 collection... +{ + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan.ndarray( 3, 10, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3, true, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3, false, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3, null, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3, undefined, 1, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3, {}, 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... +{ + var x = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan.ndarray( x.length, x, '1', 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, true, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, undefined, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, [], 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.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... +{ + var x = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan.ndarray( x.length, x, 1, '1', y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, true, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, undefined, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, [], y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.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 collection... +{ + var x = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, 10, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, true, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, false, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, null, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, undefined, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, {}, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + var x = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, '1', 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, true, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, undefined, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, [], 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError + gfirstIndexGreaterThan.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... +{ + var x = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, '1' ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, true ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, undefined ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, [] ); // $ExpectError + gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError + gfirstIndexGreaterThan.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 = [ 1.0, 2.0, 3.0 ]; + var y = [ 1.0, 2.0, 3.0 ]; + + gfirstIndexGreaterThan.ndarray(); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3, x ); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3, x, 1 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3, x, 1, 0 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3, x, 1, 0, y ); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3, x, 1, 0, y, 1 ); // $ExpectError + gfirstIndexGreaterThan.ndarray( 3, x, 1, 0, y, 1, 0, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/examples/index.js new file mode 100644 index 000000000000..556a22e391ee --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/examples/index.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var gfirstIndexGreaterThan = require( './../lib' ); + +var x = discreteUniform( 10, 0, 10, { + 'dtype': 'generic' +}); +console.log( x ); + +var y = discreteUniform( 10, 0, 10, { + 'dtype': 'generic' +}); +console.log( y ); + +var idx = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); +console.log( idx ); 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 new file mode 100644 index 000000000000..869c4f71aa53 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/accessors.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Returns the index of the first element in a strided array which is greater than a corresponding element in another strided array. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {Object} x - first input array object +* @param {Collection} x.data - first input array data +* @param {Array} x.accessors - first array element accessors +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Object} y - second input array object +* @param {Collection} y.data - second input array data +* @param {Array} y.accessors - second array element accessors +* @param {integer} strideY - stride length for `y` +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @returns {integer} index +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = [ 1.0, 2.0, 3.0, 4.0 ]; +* var y = [ 2.0, 2.0, 2.0, 2.0 ]; +* +* var idx = gfirstIndexGreaterThan( x.length, arraylike2object( toAccessorArray( x ) ), 1, 0, arraylike2object( toAccessorArray( y ) ), 1, 0 ); +* // returns 2 +*/ +function gfirstIndexGreaterThan( N, x, strideX, offsetX, y, strideY, offsetY ) { + var xbuf; + var ybuf; + var xget; + var yget; + var ix; + var iy; + var i; + + // Cache reference to array data: + xbuf = x.data; + ybuf = y.data; + + // Cache a reference to the element accessors: + xget = x.accessors[ 0 ]; + yget = y.accessors[ 0 ]; + + ix = offsetX; + iy = offsetY; + for ( i = 0; i < N; i++ ) { + if ( xget( xbuf, ix ) > yget( ybuf, iy ) ) { + return i; + } + ix += strideX; + iy += strideY; + } + return -1; +} + + +// EXPORTS // + +module.exports = gfirstIndexGreaterThan; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/index.js new file mode 100644 index 000000000000..52cb30ee9d25 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/index.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Return the index of the first element in a strided array which is greater than a corresponding element in another strided array. +* +* @module @stdlib/blas/ext/base/gfirst-index-greater-than +* +* @example +* var gfirstIndexGreaterThan = require( '@stdlib/blas/ext/base/gfirst-index-greater-than' ); +* +* var x = [ 1.0, 2.0, 3.0, 4.0 ]; +* var y = [ 2.0, 2.0, 2.0, 2.0 ]; +* +* var idx = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); +* // returns 2 +* +* @example +* var gfirstIndexGreaterThan = require( '@stdlib/blas/ext/base/gfirst-index-greater-than' ); +* +* var x = [ 1.0, 2.0, 3.0, 4.0 ]; +* var y = [ 2.0, 2.0, 2.0, 2.0 ]; +* +* var idx = gfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); +* // returns 2 +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = main; 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 new file mode 100644 index 000000000000..a993d370c91b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/main.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Returns the index of the first element in a strided array which is greater than a corresponding element in another strided array. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Collection} x - first input array +* @param {integer} strideX - stride length for `x` +* @param {Collection} y - second input array +* @param {integer} strideY - stride length for `y` +* @returns {integer} index +* +* @example +* var x = [ 1.0, 2.0, 3.0, 4.0 ]; +* var y = [ 2.0, 2.0, 2.0, 2.0 ]; +* +* var idx = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); +* // returns 2 +*/ +function gfirstIndexGreaterThan( N, x, strideX, y, strideY ) { + return ndarray( N, x, strideX, stride2offset( N, strideX ), y, strideY, stride2offset( N, strideY ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = gfirstIndexGreaterThan; 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 new file mode 100644 index 000000000000..a0432966ab91 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/lib/ndarray.js @@ -0,0 +1,78 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var accessors = require( './accessors.js' ); + + +// MAIN // + +/** +* 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. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Collection} x - first input array +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Collection} y - second input array +* @param {integer} strideY - stride length for `y` +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @returns {integer} index +* +* @example +* var x = [ 1.0, 2.0, 3.0, 4.0 ]; +* var y = [ 2.0, 2.0, 2.0, 2.0 ]; +* +* var idx = gfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); +* // returns 2 +*/ +function gfirstIndexGreaterThan( N, x, strideX, offsetX, y, strideY, offsetY ) { + var ix; + var iy; + var ox; + var oy; + var i; + + if ( N <= 0 ) { + return -1; + } + ox = arraylike2object( x ); + oy = arraylike2object( y ); + if ( ox.accessorProtocol || oy.accessorProtocol ) { + return accessors( N, ox, strideX, offsetX, oy, strideY, offsetY ); + } + ix = offsetX; + iy = offsetY; + for ( i = 0; i < N; i++ ) { + if ( x[ ix ] > y[ iy ] ) { + return i; + } + ix += strideX; + iy += strideY; + } + return -1; +} + + +// EXPORTS // + +module.exports = gfirstIndexGreaterThan; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/package.json b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/package.json new file mode 100644 index 000000000000..55556bed35e3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/blas/ext/base/gfirst-index-greater-than", + "version": "0.0.0", + "description": "Return the index of the first element in a strided array which is greater than a corresponding element in another strided array.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "greater", + "index", + "compare", + "strided", + "array", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.js new file mode 100644 index 000000000000..86b2d869257e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var gfirstIndexGreaterThan = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gfirstIndexGreaterThan, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof gfirstIndexGreaterThan.ndarray, 'function', 'method is a function' ); + t.end(); +}); 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 new file mode 100644 index 000000000000..9e5aae2bc8c9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.main.js @@ -0,0 +1,452 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gfirstIndexGreaterThan = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gfirstIndexGreaterThan, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( gfirstIndexGreaterThan.length, 5, 'has expected arity' ); + t.end(); +}); + +tape( 'the function returns the first index of an element which is greater than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ]; + + // Nonnegative stride... + actual = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); + t.strictEqual( actual, 4, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; + y = [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( 3, x, 2, y, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + // Negative stride... + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( x.length, x, -1, y, -1 ); + t.strictEqual( actual, 4, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( x.length, x, -1, y, -1 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 9.0, 9.0, 9.0, 9.0, 0.0 ]; + + actual = gfirstIndexGreaterThan( x.length, x, -1, y, -1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( x.length, x, -1, y, -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 corresponding element in another array (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + // Nonnegative stride... + actual = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); + t.strictEqual( actual, 4, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( x.length, x, 1, y, 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + y = toAccessorArray( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( 3, x, 2, y, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + // Negative stride... + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( x.length, x, -1, y, -1 ); + t.strictEqual( actual, 4, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( x.length, x, -1, y, -1 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 9.0, 9.0, 9.0, 9.0, 0.0 ] ); + + actual = gfirstIndexGreaterThan( x.length, x, -1, y, -1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( x.length, x, -1, y, -1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; + + actual = gfirstIndexGreaterThan( 0, [ 1.0, 2.0, 3.0 ], 1, [ 1.0, 2.0, 3.0 ], 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gfirstIndexGreaterThan( -1, [ 1.0, 2.0, 3.0 ], 1, [ 1.0, 2.0, 3.0 ], 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if provided `N` parameter is less than or equal to zero (accessors)', function test( t ) { + var actual; + + actual = gfirstIndexGreaterThan( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gfirstIndexGreaterThan( -1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { + var actual; + + actual = gfirstIndexGreaterThan( 1, [ NaN ], 1, [ 0.0 ], 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gfirstIndexGreaterThan( 1, [ 0.0 ], 1, [ NaN ], 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors)', function test( t ) { + var actual; + + actual = gfirstIndexGreaterThan( 1, toAccessorArray( [ NaN ] ), 1, toAccessorArray( [ 0.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gfirstIndexGreaterThan( 1, toAccessorArray( [ 0.0 ] ), 1, toAccessorArray( [ NaN ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function treats -0 and +0 as equal', function test( t ) { + var actual; + + actual = gfirstIndexGreaterThan( 1, [ 0.0 ], 1, [ -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 ) { + var actual; + + actual = gfirstIndexGreaterThan( 1, toAccessorArray( [ 0.0 ] ), 1, toAccessorArray( [ -0.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; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; + y = [ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 3, x, 2, y, 1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; + y = [ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 3, toAccessorArray( x ), 2, toAccessorArray( y ), 1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]; + y = [ + 9.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 9.0 // 2 + ]; + + actual = gfirstIndexGreaterThan( 3, x, 1, y, 2 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]; + y = [ + 9.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 9.0 // 2 + ]; + + actual = gfirstIndexGreaterThan( 3, toAccessorArray( x ), 1, toAccessorArray( y ), 2 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]; + y = [ + 9.0, // 2 + 0.0, // 1 + 9.0, // 0 + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 3, x, -2, y, -1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]; + y = [ + 9.0, // 2 + 0.0, // 1 + 9.0, // 0 + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 3, toAccessorArray( x ), -2, toAccessorArray( y ), -1 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', 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, 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([ + 9.0, + 9.0, + 9.0, + 9.0, // 0 + 0.0, // 1 + 9.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 = gfirstIndexGreaterThan( 3, x1, -2, y1, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); 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 new file mode 100644 index 000000000000..451f80e53135 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfirst-index-greater-than/test/test.ndarray.js @@ -0,0 +1,539 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gfirstIndexGreaterThan = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gfirstIndexGreaterThan, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( gfirstIndexGreaterThan.length, 7, 'has expected arity' ); + t.end(); +}); + +tape( 'the function returns the first index of an element which is greater than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ]; + + // Nonnegative stride... + actual = gfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( x.length-1, x, 1, 1, y, 1, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( x.length-2, x, 1, 2, y, 1, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( x.length-2, x, 1, 2, y, 1, 2 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + x = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; + y = [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( 3, x, 2, 0, y, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + // Negative stride... + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); + t.strictEqual( actual, 4, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( 3, x, -2, x.length-1, y, -2, y.length-1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( 3, x, -2, x.length-2, y, -2, y.length-2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + x = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + y = [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ]; + + actual = gfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.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 corresponding element in another array (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + // Nonnegative stride... + actual = gfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( x.length, x, 1, 1, y, 1, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( x.length, x, 1, 2, y, 1, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( x.length-2, x, 1, 2, y, 1, 2 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + // Negative stride... + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); + t.strictEqual( actual, 4, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( 3, x, -2, x.length-1, y, -2, y.length-1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + y = toAccessorArray( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + actual = gfirstIndexGreaterThan( 3, x, -2, x.length-2, y, -2, y.length-2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = toAccessorArray( [ 5.0, 6.0, 7.0, 8.0 ] ); + + actual = gfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if provided an `N` parameter is less than or equal to zero', function test( t ) { + var actual; + + actual = gfirstIndexGreaterThan( 0, [ 1.0, 2.0, 3.0 ], 1, 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gfirstIndexGreaterThan( -1, [ 1.0, 2.0, 3.0 ], 1, 0, [ 1.0, 2.0, 3.0 ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if provided an `N` parameter is less than or equal to zero (accessors)', function test( t ) { + var actual; + + actual = gfirstIndexGreaterThan( 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gfirstIndexGreaterThan( -1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { + var actual; + + actual = gfirstIndexGreaterThan( 1, [ NaN ], 1, 0, [ 0.0 ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gfirstIndexGreaterThan( 1, [ 0.0 ], 1, 0, [ NaN ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if comparisons involve `NaN` values (accessors)', function test( t ) { + var actual; + + actual = gfirstIndexGreaterThan( 1, toAccessorArray( [ NaN ] ), 1, 0, toAccessorArray( [ 0.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gfirstIndexGreaterThan( 1, toAccessorArray( [ 0.0 ] ), 1, 0, toAccessorArray( [ NaN ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +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 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +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 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; + y = [ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 3, x, 2, 0, y, 1, 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; + var y; + + x = [ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]; + y = [ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 3, toAccessorArray( x ), 2, 0, toAccessorArray( y ), 1, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]; + y = [ + 9.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 9.0 // 2 + ]; + + actual = gfirstIndexGreaterThan( 3, x, 1, 0, y, 2, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]; + y = [ + 9.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 9.0 // 2 + ]; + + actual = gfirstIndexGreaterThan( 3, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 2, 0 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]; + y = [ + 9.0, // 2 + 0.0, // 1 + 9.0, // 0 + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 3, x, -2, 4, y, -1, 2 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides (accessors)', function test( t ) { + var actual; + var x; + var y; + + x = [ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]; + y = [ + 9.0, // 2 + 0.0, // 1 + 9.0, // 0 + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 3, toAccessorArray( x ), -2, 4, toAccessorArray( y ), -1, 2 ); + + t.strictEqual( actual, 1, 'returns expected value' ); + 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 + 0.0, // 2 + 9.0, // 3 + 9.0, + 9.0, + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 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 + 0.0, // 2 + 9.0, // 3 + 9.0, + 9.0, + 9.0, + 9.0 + ]; + + actual = gfirstIndexGreaterThan( 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, + 0.0, // 1 + 9.0, + 9.0, // 2 + 9.0, + 9.0 // 3 + ]; + + actual = gfirstIndexGreaterThan( 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, + 0.0, // 1 + 9.0, + 9.0, // 2 + 9.0, + 9.0 // 3 + ]; + + actual = gfirstIndexGreaterThan( 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; + 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, x, 2, 0, y, -1, 2 ); + + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +});