diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/README.md new file mode 100644 index 000000000000..06ca7496d2af --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/README.md @@ -0,0 +1,187 @@ + + +# gindexOfNotEqual + +> Return the first index of an element in a strided array which is not equal to a specified search element. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var gindexOfNotEqual = require( '@stdlib/blas/ext/base/gindex-of-not-equal' ); +``` + +#### gindexOfNotEqual( N, searchElement, x, strideX ) + +Returns the first index of an element in a strided array which is not equal to a specified search element. + +```javascript +var x = [ 1.0, 1.0, 0.0, 1.0 ]; + +var idx = gindexOfNotEqual( x.length, 1.0, x, 1 ); +// returns 2 +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **searchElement**: search element. +- **x**: input array. +- **strideX**: stride length. + +If all elements in the array are equal to the search element, the function returns `-1`. + +```javascript +var x = [ 1.0, 1.0, 1.0, 1.0 ]; + +var idx = gindexOfNotEqual( x.length, 1.0, x, 1 ); +// returns -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 = [ 1.0, 9.0, 0.0, 9.0, 1.0, 9.0 ]; + +var idx = gindexOfNotEqual( 3, 1.0, x, 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 array... +var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +// Create an offset view... +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Find index... +var idx = gindexOfNotEqual( 3, 2.0, x1, 2 ); +// returns 1 +``` + +#### gindexOfNotEqual.ndarray( N, searchElement, x, strideX, offsetX ) + +Returns the first index of an element in a strided array which is not equal to a specified search element using alternative indexing semantics. + +```javascript +var x = [ 1.0, 1.0, 0.0, 1.0 ]; + +var idx = gindexOfNotEqual.ndarray( x.length, 1.0, x, 1, 0 ); +// returns 2 +``` + +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: + +```javascript +var x = [ 1.0, 1.0, 0.0, 1.0 ]; + +var idx = gindexOfNotEqual.ndarray( 3, 1.0, x, 1, 1 ); +// returns 1 +``` + +
+ + + + + +
+ +## Notes + +- When searching for a search element, the function checks for inequality using the strict inequality operator `!==`. As a consequence, `NaN` values are considered distinct from all values (including other `NaN` values), 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]). + +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var gindexOfNotEqual = require( '@stdlib/blas/ext/base/gindex-of-not-equal' ); + +var x = discreteUniform( 10, 0, 3, { + 'dtype': 'generic' +}); +console.log( x ); + +var idx = gindexOfNotEqual( x.length, 0.0, x, 1 ); +console.log( idx ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/benchmark/benchmark.js new file mode 100644 index 000000000000..6c3748fcd92a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/benchmark/benchmark.js @@ -0,0 +1,97 @@ +/** +* @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 zeros = require( '@stdlib/array/zeros' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gindexOfNotEqual = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeros( 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 = gindexOfNotEqual( x.length, 0.0, x, 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/gindex-of-not-equal/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..116220a44b01 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/benchmark/benchmark.ndarray.js @@ -0,0 +1,97 @@ +/** +* @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 zeros = require( '@stdlib/array/zeros' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gindexOfNotEqual = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeros( 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 = gindexOfNotEqual( x.length, 0.0, x, 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/gindex-of-not-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/repl.txt new file mode 100644 index 000000000000..5bed55ccbb29 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/repl.txt @@ -0,0 +1,95 @@ + +{{alias}}( N, searchElement, x, strideX ) + Returns the first index of an element in a strided array which is not equal + to a specified search element. + + 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 a typed + array view. + + If `N <= 0`, the function returns `-1`. + + Parameters + ---------- + N: integer + Number of indexed elements. + + searchElement: any + Search element. + + x: Array|TypedArray + Input array. + + strideX: integer + Stride length. + + Returns + ------- + idx: integer + Index. + + Examples + -------- + // Standard usage: + > var x = [ 1.0, 1.0, 0.0, 1.0 ]; + > var idx = {{alias}}( x.length, 1.0, x, 1 ) + 2 + + // Using `N` and stride parameters: + > var x = [ 1.0, 9.0, 0.0, 9.0, 1.0, 9.0 ]; + > var idx = {{alias}}( 3, 1.0, x, 2 ) + 1 + + // 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 ) + 0 + + +{{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) + Returns the first index of an element in a strided array which is not equal + to 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 index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + searchElement: any + Search element. + + x: Array|TypedArray + Input array. + + strideX: integer + Stride length. + + offsetX: integer + Starting index. + + Returns + ------- + idx: integer + Index. + + Examples + -------- + // Standard usage: + > var x = [ 1.0, 1.0, 0.0, 1.0 ]; + > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) + 2 + + // Advanced indexing: + > 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 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/types/index.d.ts new file mode 100644 index 000000000000..2eef2727379f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/types/index.d.ts @@ -0,0 +1,108 @@ +/* +* @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 `gindexOfNotEqual`. +*/ +interface Routine { + /** + * Returns the first index of an element in a strided array which is not equal to a specified search element. + * + * ## Notes + * + * - If all elements are equal to the search element, the function returns `-1`. + * + * @param N - number of indexed elements + * @param searchElement - search element + * @param x - input array + * @param strideX - stride length + * @returns index + * + * @example + * var x = [ 1.0, 1.0, 0.0, 1.0 ]; + * + * var idx = gindexOfNotEqual( x.length, 1.0, x, 1 ); + * // returns 2 + */ + ( N: number, searchElement: unknown, x: InputArray, strideX: number ): number; + + /** + * Returns the first index of an element in a strided array which is not equal to a specified search element using alternative indexing semantics. + * + * ## Notes + * + * - If all elements are equal to the search element, the function returns `-1`. + * + * @param N - number of indexed elements + * @param searchElement - search element + * @param x - input array + * @param strideX - stride length + * @param offsetX - starting index + * @returns index + * + * @example + * var x = [ 1.0, 1.0, 0.0, 1.0 ]; + * + * var idx = gindexOfNotEqual.ndarray( x.length, 1.0, x, 1, 0 ); + * // returns 2 + */ + ndarray( N: number, searchElement: unknown, x: InputArray, strideX: number, offsetX: number ): number; +} + +/** +* Returns the first index of an element in a strided array which is not equal to a specified search element. +* +* ## Notes +* +* - If all elements are equal to the search element, the function returns `-1`. +* +* @param N - number of indexed elements +* @param searchElement - search element +* @param x - input array +* @param strideX - stride length +* @returns index +* +* @example +* var x = [ 1.0, 1.0, 0.0, 1.0 ]; +* +* var idx = gindexOfNotEqual( x.length, 1.0, x, 1 ); +* // returns 2 +* +* @example +* var x = [ 1.0, 1.0, 0.0, 1.0 ]; +* +* var idx = gindexOfNotEqual.ndarray( x.length, 1.0, x, 1, 0 ); +* // returns 2 +*/ +declare var gindexOfNotEqual: Routine; + + +// EXPORTS // + +export = gindexOfNotEqual; 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 new file mode 100644 index 000000000000..d58b9cf76888 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/docs/types/test.ts @@ -0,0 +1,129 @@ +/* +* @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 gindexOfNotEqual = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + var x = [ 1.0, 2.0, 3.0 ]; + + gindexOfNotEqual( x.length, 2.0, x, 1 ); // $ExpectType number + gindexOfNotEqual( x.length, 2.0, new AccessorArray( x ), 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 ]; + + gindexOfNotEqual( '1', 2.0, x, 1 ); // $ExpectError + gindexOfNotEqual( true, 2.0, x, 1 ); // $ExpectError + gindexOfNotEqual( false, 2.0, x, 1 ); // $ExpectError + gindexOfNotEqual( null, 2.0, x, 1 ); // $ExpectError + gindexOfNotEqual( {}, 2.0, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a collection... +{ + gindexOfNotEqual( x.length, 1.0, 1, 1 ); // $ExpectError + gindexOfNotEqual( x.length, 1.0, true, 1 ); // $ExpectError + gindexOfNotEqual( x.length, 1.0, false, 1 ); // $ExpectError + gindexOfNotEqual( x.length, 1.0, null, 1 ); // $ExpectError + gindexOfNotEqual( x.length, 1.0, {}, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + var x = [ 1.0, 2.0, 3.0 ]; + + gindexOfNotEqual( x.length, 2.0, x, '1' ); // $ExpectError + gindexOfNotEqual( x.length, 2.0, x, true ); // $ExpectError + gindexOfNotEqual( x.length, 2.0, x, false ); // $ExpectError + gindexOfNotEqual( x.length, 2.0, x, null ); // $ExpectError + gindexOfNotEqual( x.length, 2.0, x, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + gindexOfNotEqual(); // $ExpectError + gindexOfNotEqual( 3, 2.0 ); // $ExpectError + gindexOfNotEqual( 3, 2.0, [ 1.0, 2.0, 3.0 ] ); // $ExpectError + gindexOfNotEqual( 3, 2.0, [ 1.0, 2.0, 3.0 ], 1, {} ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + var x = [ 1.0, 2.0, 3.0 ]; + + gindexOfNotEqual.ndarray( x.length, 2.0, x, 1, 0 ); // $ExpectType number + gindexOfNotEqual.ndarray( x.length, 2.0, new AccessorArray( 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 = [ 1.0, 2.0, 3.0 ]; + + gindexOfNotEqual.ndarray( '1', 2.0, x, 1, 1 ); // $ExpectError + gindexOfNotEqual.ndarray( true, 2.0, x, 1, 1 ); // $ExpectError + 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 +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... +{ + gindexOfNotEqual.ndarray( x.length, 1.0, 1, 1, 1 ); // $ExpectError + gindexOfNotEqual.ndarray( x.length, 1.0, true, 1, 1 ); // $ExpectError + 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 +} + +// 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 ]; + + gindexOfNotEqual.ndarray( x.length, 2.0, x, '1', 1 ); // $ExpectError + gindexOfNotEqual.ndarray( x.length, 2.0, x, true, 1 ); // $ExpectError + 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 +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + var x = [ 1.0, 2.0, 3.0 ]; + + gindexOfNotEqual.ndarray( x.length, 2.0, x, 1, '1' ); // $ExpectError + gindexOfNotEqual.ndarray( x.length, 2.0, x, 1, true ); // $ExpectError + 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 +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + gindexOfNotEqual.ndarray(); // $ExpectError + gindexOfNotEqual.ndarray( 3, 2.0 ); // $ExpectError + gindexOfNotEqual.ndarray( 3, 2.0, [ 1.0, 2.0, 3.0 ] ); // $ExpectError + gindexOfNotEqual.ndarray( 3, 2.0, [ 1.0, 2.0, 3.0 ], 1 ); // $ExpectError + gindexOfNotEqual.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-not-equal/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/examples/index.js new file mode 100644 index 000000000000..a35dd53376d6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/examples/index.js @@ -0,0 +1,30 @@ +/** +* @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 gindexOfNotEqual = require( './../lib' ); + +var x = discreteUniform( 10, 0, 3, { + 'dtype': 'generic' +}); +console.log( x ); + +var idx = gindexOfNotEqual( x.length, 0.0, x, 1 ); +console.log( idx ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/lib/accessors.js new file mode 100644 index 000000000000..035641664dd7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/lib/accessors.js @@ -0,0 +1,70 @@ +/** +* @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 first index of an element in a strided array which is not equal to a specified search element. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {*} searchElement - search element +* @param {Object} x - input array object +* @param {Collection} x.data - input array data +* @param {Array} x.accessors - array element accessors +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @returns {integer} index +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = [ 1.0, 1.0, 0.0, 1.0 ]; +* +* var idx = gindexOfNotEqual( x.length, 1.0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* // returns 2 +*/ +function gindexOfNotEqual( N, searchElement, x, strideX, offsetX ) { + var xbuf; + var get; + var ix; + var i; + + // Cache a reference to array data: + xbuf = x.data; + + // Cache a reference to the element accessor: + get = x.accessors[ 0 ]; + + ix = offsetX; + for ( i = 0; i < N; i++ ) { + if ( get( xbuf, ix ) !== searchElement ) { + return i; + } + ix += strideX; + } + return -1; +} + + +// EXPORTS // + +module.exports = gindexOfNotEqual; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/lib/index.js new file mode 100644 index 000000000000..f02ee44c3f9b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/lib/index.js @@ -0,0 +1,57 @@ +/** +* @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 first index of an element in a strided array which is not equal to a specified search element. +* +* @module @stdlib/blas/ext/base/gindex-of-not-equal +* +* @example +* var gindexOfNotEqual = require( '@stdlib/blas/ext/base/gindex-of-not-equal' ); +* +* var x = [ 1.0, 1.0, 0.0, 1.0 ]; +* +* var idx = gindexOfNotEqual( x.length, 1.0, x, 1 ); +* // returns 2 +* +* @example +* var gindexOfNotEqual = require( '@stdlib/blas/ext/base/gindex-of-not-equal' ); +* +* var x = [ 1.0, 1.0, 0.0, 1.0 ]; +* +* var idx = gindexOfNotEqual.ndarray( x.length, 1.0, x, 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/gindex-of-not-equal/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/lib/main.js new file mode 100644 index 000000000000..c466bc62c3c5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/lib/main.js @@ -0,0 +1,51 @@ +/** +* @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 first index of an element in a strided array which is not equal to a specified search element. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {*} searchElement - search element +* @param {Collection} x - input array +* @param {integer} strideX - stride length +* @returns {integer} index +* +* @example +* var x = [ 1.0, 1.0, 0.0, 1.0 ]; +* +* var idx = gindexOfNotEqual( x.length, 1.0, x, 1 ); +* // returns 2 +*/ +function gindexOfNotEqual( N, searchElement, x, strideX ) { + return ndarray( N, searchElement, x, strideX, stride2offset( N, strideX ) ); +} + + +// EXPORTS // + +module.exports = gindexOfNotEqual; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/lib/ndarray.js new file mode 100644 index 000000000000..768a128a9e67 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/lib/ndarray.js @@ -0,0 +1,70 @@ +/** +* @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 first index of an element in a strided array which is not equal to a specified search element using alternative indexing semantics. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {*} searchElement - search element +* @param {Collection} x - input array +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @returns {integer} index +* +* @example +* var x = [ 1.0, 1.0, 0.0, 1.0 ]; +* +* var idx = gindexOfNotEqual( x.length, 1.0, x, 1, 0 ); +* // returns 2 +*/ +function gindexOfNotEqual( N, searchElement, x, strideX, offsetX ) { + var ix; + var o; + var i; + + if ( N <= 0 ) { + return -1; + } + o = arraylike2object( x ); + if ( o.accessorProtocol ) { + return accessors( N, searchElement, o, strideX, offsetX ); + } + ix = offsetX; + for ( i = 0; i < N; i++ ) { + if ( x[ ix ] !== searchElement ) { + return i; + } + ix += strideX; + } + return -1; +} + + +// EXPORTS // + +module.exports = gindexOfNotEqual; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/package.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/package.json new file mode 100644 index 000000000000..af543d7033e6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/blas/ext/base/gindex-of-not-equal", + "version": "0.0.0", + "description": "Return the first index of an element in a strided array which is not equal to a specified search element.", + "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", + "search", + "index", + "get", + "strided", + "array", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.js new file mode 100644 index 000000000000..e6b4186ea0ba --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/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 gindexOfNotEqual = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gindexOfNotEqual, '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 gindexOfNotEqual.ndarray, 'function', 'method is a function' ); + t.end(); +}); 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 new file mode 100644 index 000000000000..2601cf099fd8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.main.js @@ -0,0 +1,288 @@ +/** +* @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 gindexOfNotEqual = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gindexOfNotEqual, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( gindexOfNotEqual.length, 4, 'has expected arity' ); + t.end(); +}); + +tape( 'the function returns the index of the first element in a strided array which is not 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 = 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(); +}); + +tape( 'the function returns the index of the first element in a strided array which is not 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 = 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(); +}); + +tape( 'the function returns `-1` if every indexed element in the array is equal to the search element', function test( t ) { + var actual; + var x; + + x = [ 2.0, 2.0, 2.0 ]; + + actual = gindexOfNotEqual( x.length, 2.0, x, 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if every indexed element in the array is equal to the search element (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray( [ 2.0, 2.0, 2.0 ] ); + + actual = gindexOfNotEqual( x.length, 2.0, x, 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 ) { + var actual; + + actual = gindexOfNotEqual( 0, 2.0, [ 1.0, 2.0, 3.0 ], 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gindexOfNotEqual( -1, 2.0, [ 1.0, 2.0, 3.0 ], 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 (accessors)', function test( t ) { + var actual; + + actual = gindexOfNotEqual( 0, 2.0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gindexOfNotEqual( -1, 2.0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the index of the first element if a provided `searchElement` is `NaN`', function test( t ) { + var actual; + + actual = gindexOfNotEqual( 2, NaN, [ NaN, 1.0 ], 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the index of the first element if a provided `searchElement` is `NaN` (accessors)', function test( t ) { + var actual; + + actual = gindexOfNotEqual( 2, NaN, toAccessorArray( [ NaN, 1.0 ] ), 1 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfNotEqual( 3, 1.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 = [ + 1.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfNotEqual( 3, 1.0, toAccessorArray( x ), 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var actual; + var x; + + x = [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ]; + + actual = gindexOfNotEqual( x.length, 1.0, x, -1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides (accessors)', function test( t ) { + var actual; + var x; + + x = [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ]; + + actual = gindexOfNotEqual( x.length, 1.0, toAccessorArray( x ), -1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var actual; + var x; + + x = [ + 1.0, // 0 + 9.0, + 1.0, // 1 + 9.0, + 0.0 // 2 + ]; + + actual = gindexOfNotEqual( 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; + + x = [ + 1.0, // 0 + 9.0, + 1.0, // 1 + 9.0, + 0.0 // 2 + ]; + + actual = gindexOfNotEqual( 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 = gindexOfNotEqual( 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-not-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.ndarray.js new file mode 100644 index 000000000000..2b80a3a06bcb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-not-equal/test/test.ndarray.js @@ -0,0 +1,294 @@ +/** +* @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 gindexOfNotEqual = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gindexOfNotEqual, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( gindexOfNotEqual.length, 5, 'has expected arity' ); + t.end(); +}); + +tape( 'the function returns the index of the first element in a strided array which is not 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 = 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(); +}); + +tape( 'the function returns the index of the first element in a strided array which is not 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 = 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(); +}); + +tape( 'the function returns `-1` if every indexed element in the array is equal to the search element', function test( t ) { + var actual; + var x; + + x = [ 2.0, 2.0, 2.0 ]; + + actual = gindexOfNotEqual( x.length, 2.0, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-1` if every indexed element in the array is equal to the search element (accessors)', function test( t ) { + var actual; + var x; + + x = toAccessorArray( [ 2.0, 2.0, 2.0 ] ); + + actual = gindexOfNotEqual( x.length, 2.0, x, 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', function test( t ) { + var actual; + + actual = gindexOfNotEqual( 0, 2.0, [ 1.0, 2.0, 3.0 ], 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gindexOfNotEqual( -1, 2.0, [ 1.0, 2.0, 3.0 ], 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 (accessors)', function test( t ) { + var actual; + + actual = gindexOfNotEqual( 0, 2.0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + actual = gindexOfNotEqual( -1, 2.0, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the index of the first element if a provided `searchElement` is `NaN`', function test( t ) { + var actual; + + actual = gindexOfNotEqual( 2, NaN, [ NaN, 1.0 ], 1, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the index of the first element if a provided `searchElement` is `NaN` (accessors)', function test( t ) { + var actual; + + actual = gindexOfNotEqual( 2, NaN, toAccessorArray( [ NaN, 1.0 ] ), 1, 0 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = [ + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfNotEqual( 3, 0.0, 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 = [ + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfNotEqual( 3, 0.0, toAccessorArray( x ), 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = [ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfNotEqual( 3, 0.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset (accessors)', function test( t ) { + var actual; + var x; + + x = [ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfNotEqual( 3, 0.0, toAccessorArray( x ), 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var actual; + var x; + + x = [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ]; + + actual = gindexOfNotEqual( x.length, 0.0, x, -1, x.length-1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides (accessors)', function test( t ) { + var actual; + var x; + + x = [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ]; + + actual = gindexOfNotEqual( x.length, 0.0, toAccessorArray( x ), -1, x.length-1 ); // eslint-disable-line max-len + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var actual; + var x; + + x = [ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]; + + actual = gindexOfNotEqual( 3, 0.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +});