diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/README.md b/lib/node_modules/@stdlib/blas/ext/base/gsome/README.md new file mode 100644 index 000000000000..66b28ccd9436 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/README.md @@ -0,0 +1,164 @@ + + +# gsome + +> Test whether a strided array contains at least `k` truthy elements. + +
+ +
+ + + +
+ +## Usage + +```javascript +var gsome = require( '@stdlib/blas/ext/base/gsome' ); +``` + +#### gsome( N, k, x, strideX ) + +Tests whether a strided array contains at least `k` truthy elements. + +```javascript +var x = [ 0.0, 0.0, 1.0, 2.0 ]; + +var v = gsome( x.length, 2, x, 1 ); +// returns true +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **k**: minimum number of truthy elements. +- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. +- **strideX**: stride length. + +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to test every other element: + +```javascript +var x = [ 0.0, 0.0, 1.0, 2.0, 1.0, 3.0 ]; + +var v = gsome( 3, 2, x, 2 ); +// returns true +``` + +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' ); + +var x0 = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 0.0, 3.0 ] ); +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var v = gsome( 3, 2, x1, 2 ); +// returns true +``` + +#### gsome.ndarray( N, k, x, strideX, offsetX ) + +Tests whether a strided array contains at least `k` truthy elements using alternative indexing semantics. + +```javascript +var x = [ 0.0, 0.0, 1.0, 2.0 ]; + +var v = gsome.ndarray( x.length, 2, x, 1, 0 ); +// returns true +``` + +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 test every other element starting from the second element: + +```javascript +var x = [ 0.0, 0.0, 1.0, 2.0, 0.0, 3.0 ]; + +var v = gsome.ndarray( 3, 2, x, 2, 1 ); +// returns true +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, the function returns `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 bernoulli = require( '@stdlib/random/array/bernoulli' ); +var gsome = require( '@stdlib/blas/ext/base/gsome' ); + +var x = bernoulli( 10, 0.3 ); +console.log( x ); + +var v = gsome( x.length, 3, x, 1 ); +console.log( v ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gsome/benchmark/benchmark.js new file mode 100644 index 000000000000..2c9a695f2439 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/benchmark/benchmark.js @@ -0,0 +1,100 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ); +var bernoulli = require( '@stdlib/random/array/bernoulli' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gsome = require( './../lib/main.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = bernoulli( len, 0.5, { + 'dtype': 'generic' + }); + var k = floor( len / 2 ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = gsome( x.length, k, x, 1 ); + if ( typeof v !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( v ) ) { + b.fail( 'should return a boolean' ); + } + 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/gsome/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsome/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..c07756a0bdf5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/benchmark/benchmark.ndarray.js @@ -0,0 +1,100 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ); +var bernoulli = require( '@stdlib/random/array/bernoulli' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gsome = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = bernoulli( len, 0.5, { + 'dtype': 'generic' + }); + var k = floor( len / 2 ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = gsome( x.length, k, x, 1, 0 ); + if ( typeof v !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( v ) ) { + b.fail( 'should return a boolean' ); + } + 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/gsome/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gsome/docs/repl.txt new file mode 100644 index 000000000000..5e658c99d3f6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/docs/repl.txt @@ -0,0 +1,95 @@ + +{{alias}}( N, k, x, strideX ) + Tests whether a strided array contains at least `k` truthy elements. + + 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 `false`. + + Parameters + ---------- + N: integer + Number of indexed elements. + + k: integer + Minimum number of truthy elements. + + x: ArrayLikeObject + Input array. + + strideX: integer + Stride length. + + Returns + ------- + out: boolean + Boolean indicating whether the input array contains at least k truthy + elements. + + Examples + -------- + // Standard Usage: + > var x = [ 0, 0, 1, 2 ]; + > {{alias}}( x.length, 2, x, 1 ) + true + + // Using `N` and stride parameters: + > x = [ 0, 0, 1, 2, 1, 3 ]; + > {{alias}}( 3, 2, x, 2 ) + true + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0, 0, 1, 2, 0, 3 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 3, 2, x1, 2 ) + true + + +{{alias}}.ndarray( N, k, x, strideX, offsetX ) + Tests whether a strided array contains at least `k` truthy elements. + + 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. + + k: integer + Minimum number of truthy elements. + + x: ArrayLikeObject + Input array. + + strideX: integer + Stride length. + + offsetX: integer + Starting index. + + Returns + ------- + out: boolean + Boolean indicating whether the input array contains at least k truthy + elements. + + Examples + -------- + // Standard Usage: + > var x = [ 0, 0, 1, 2 ]; + > {{alias}}.ndarray( x.length, 2, x, 1, 0 ) + true + + // Using offset parameter: + > var x = [ 0, 1, 0, 2, 0, 3, 0, 4 ]; + > {{alias}}.ndarray( 4, 2, x, 2, 1 ) + true + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gsome/docs/types/index.d.ts new file mode 100644 index 000000000000..3ea736b10d8c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/docs/types/index.d.ts @@ -0,0 +1,96 @@ +/* +* @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 `gsome`. +*/ +interface Routine { + /** + * Tests whether a strided array contains at least `k` truthy elements. + * + * @param N - number of indexed elements + * @param k - minimum number of truthy elements + * @param x - input array + * @param strideX - stride length + * @returns boolean indicating whether the input array contains at least k truthy elements + * + * @example + * var x = [ 0, 0, 1, 2 ]; + * + * var v = gsome( x.length, 2, x, 1 ); + * // returns true + */ + ( N: number, k: number, x: InputArray, strideX: number ): boolean; + + /** + * Tests whether a strided array contains at least `k` truthy elements. + * + * @param N - number of indexed elements + * @param k - minimum number of truthy elements + * @param x - input array + * @param strideX - stride length + * @param offsetX - starting index + * @returns boolean indicating whether the input array contains at least k truthy elements + * + * @example + * var x = [ 0, 0, 1, 2 ]; + * + * var v = gsome.ndarray( x.length, 2, x, 1, 0 ); + * // returns true + */ + ndarray( N: number, k: number, x: InputArray, strideX: number, offsetX: number ): boolean; +} + +/** +* Tests whether a strided array contains at least `k` truthy elements. +* +* @param N - number of indexed elements +* @param k - minimum number of truthy elements +* @param x - input array +* @param strideX - stride length +* @returns boolean indicating whether the input array contains at least k truthy elements +* +* @example +* var x = [ 0, 0, 1, 2 ]; +* +* var v = gsome( x.length, 2, x, 1 ); +* // returns true +* +* @example +* var x = [ 0, 0, 1, 2 ]; +* +* var v = gsome.ndarray( x.length, 2, x, 1, 0 ); +* // returns true +*/ +declare var gsome: Routine; + + +// EXPORTS // + +export = gsome; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gsome/docs/types/test.ts new file mode 100644 index 000000000000..3d595b3b47da --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/docs/types/test.ts @@ -0,0 +1,186 @@ +/* +* @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 gsome = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + const x = new Float64Array( 10 ); + + gsome( x.length, 5, x, 1 ); // $ExpectType boolean + gsome( x.length, 5, new AccessorArray( x ), 1 ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gsome( '10', 5, x, 1 ); // $ExpectError + gsome( true, 5, x, 1 ); // $ExpectError + gsome( false, 5, x, 1 ); // $ExpectError + gsome( null, 5, x, 1 ); // $ExpectError + gsome( undefined, 5, x, 1 ); // $ExpectError + gsome( [], 5, x, 1 ); // $ExpectError + gsome( {}, 5, x, 1 ); // $ExpectError + gsome( ( x: number ): number => x, 5, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gsome( x.length, '5', x, 1 ); // $ExpectError + gsome( x.length, true, x, 1 ); // $ExpectError + gsome( x.length, false, x, 1 ); // $ExpectError + gsome( x.length, null, x, 1 ); // $ExpectError + gsome( x.length, undefined, x, 1 ); // $ExpectError + gsome( x.length, [], x, 1 ); // $ExpectError + gsome( x.length, {}, x, 1 ); // $ExpectError + gsome( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not an array-like object... +{ + const x = new Float64Array( 10 ); + + gsome( x.length, 5, 10, 1 ); // $ExpectError + gsome( x.length, 5, true, 1 ); // $ExpectError + gsome( x.length, 5, false, 1 ); // $ExpectError + gsome( x.length, 5, null, 1 ); // $ExpectError + gsome( x.length, 5, undefined, 1 ); // $ExpectError + gsome( x.length, 5, {}, 1 ); // $ExpectError + gsome( x.length, 5, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gsome( x.length, 5, x, '10' ); // $ExpectError + gsome( x.length, 5, x, true ); // $ExpectError + gsome( x.length, 5, x, false ); // $ExpectError + gsome( x.length, 5, x, null ); // $ExpectError + gsome( x.length, 5, x, undefined ); // $ExpectError + gsome( x.length, 5, x, [] ); // $ExpectError + gsome( x.length, 5, x, {} ); // $ExpectError + gsome( x.length, 5, x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + + gsome(); // $ExpectError + gsome( x.length ); // $ExpectError + gsome( x.length, 5 ); // $ExpectError + gsome( x.length, 5, x ); // $ExpectError + gsome( x.length, 5, x, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a boolean... +{ + const x = new Float64Array( 10 ); + + gsome.ndarray( x.length, 5, x, 1, 0 ); // $ExpectType boolean + gsome.ndarray( x.length, 5, new AccessorArray( x ), 1, 0 ); // $ExpectType boolean +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gsome.ndarray( '10', 5, x, 1, 0 ); // $ExpectError + gsome.ndarray( true, 5, x, 1, 0 ); // $ExpectError + gsome.ndarray( false, 5, x, 1, 0 ); // $ExpectError + gsome.ndarray( null, 5, x, 1, 0 ); // $ExpectError + gsome.ndarray( undefined, 5, x, 1, 0 ); // $ExpectError + gsome.ndarray( [], 5, x, 1, 0 ); // $ExpectError + gsome.ndarray( {}, 5, x, 1, 0 ); // $ExpectError + gsome.ndarray( ( x: number ): number => x, 5, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gsome.ndarray( x.length, '5', x, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, true, x, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, false, x, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, null, x, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, undefined, x, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, [], x, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, {}, x, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, ( x: number ): number => x, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not an array-like object... +{ + const x = new Float64Array( 10 ); + + gsome.ndarray( x.length, 5, 10, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, 5, true, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, 5, false, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, 5, null, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, 5, undefined, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, 5, {}, 1, 0 ); // $ExpectError + gsome.ndarray( x.length, 5, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gsome.ndarray( x.length, 5, x, '10', 0 ); // $ExpectError + gsome.ndarray( x.length, 5, x, true, 0 ); // $ExpectError + gsome.ndarray( x.length, 5, x, false, 0 ); // $ExpectError + gsome.ndarray( x.length, 5, x, null, 0 ); // $ExpectError + gsome.ndarray( x.length, 5, x, undefined, 0 ); // $ExpectError + gsome.ndarray( x.length, 5, x, [], 0 ); // $ExpectError + gsome.ndarray( x.length, 5, x, {}, 0 ); // $ExpectError + gsome.ndarray( x.length, 5, x, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const x = new Float64Array( 10 ); + + gsome.ndarray( x.length, 5, x, 1, '0' ); // $ExpectError + gsome.ndarray( x.length, 5, x, 1, true ); // $ExpectError + gsome.ndarray( x.length, 5, x, 1, false ); // $ExpectError + gsome.ndarray( x.length, 5, x, 1, null ); // $ExpectError + gsome.ndarray( x.length, 5, x, 1, undefined ); // $ExpectError + gsome.ndarray( x.length, 5, x, 1, [] ); // $ExpectError + gsome.ndarray( x.length, 5, x, 1, {} ); // $ExpectError + gsome.ndarray( x.length, 5, x, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + + gsome.ndarray(); // $ExpectError + gsome.ndarray( x.length ); // $ExpectError + gsome.ndarray( x.length, 5 ); // $ExpectError + gsome.ndarray( x.length, 5, x ); // $ExpectError + gsome.ndarray( x.length, 5, x, 1 ); // $ExpectError + gsome.ndarray( x.length, 5, x, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gsome/examples/index.js new file mode 100644 index 000000000000..a1d356a241b0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/examples/index.js @@ -0,0 +1,28 @@ +/** +* @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 bernoulli = require( '@stdlib/random/array/bernoulli' ); +var gsome = require( './../lib' ); + +var x = bernoulli( 10, 0.3 ); +console.log( x ); + +var v = gsome( x.length, 3, x, 1 ); +console.log( v ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gsome/lib/accessors.js new file mode 100644 index 000000000000..d34df2dd80e9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/lib/accessors.js @@ -0,0 +1,74 @@ +/** +* @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 // + +/** +* Tests whether a strided array contains at least `k` truthy elements using accessor functions. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {PositiveInteger} k - minimum number of truthy elements +* @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 {boolean} boolean indicating whether the input array contains at least k truthy elements +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = toAccessorArray( [ 0, 0, 1, 1 ] ); +* +* var v = gsome( 4, 2, arraylike2object( x ), 1, 0 ); +* // returns true +*/ +function gsome( N, k, x, strideX, offsetX ) { + var count; + var xbuf; + var get; + var ix; + var i; + + xbuf = x.data; + get = x.accessors[ 0 ]; + if ( strideX === 0 ) { + return ( get( xbuf, offsetX ) ) ? k <= N : k <= 0; + } + ix = offsetX; + count = 0; + for ( i = 0; i < N; i++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= k ) { + return true; + } + } + ix += strideX; + } + return false; +} + + +// EXPORTS // + +module.exports = gsome; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gsome/lib/index.js new file mode 100644 index 000000000000..79d1f6cea987 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/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'; + +/** +* Test whether a strided array contains at least `k` truthy elements. +* +* @module @stdlib/blas/ext/base/gsome +* +* @example +* var gsome = require( '@stdlib/blas/ext/base/gsome' ); +* +* var x = [ 0.0, 0.0, 1.0, 2.0 ]; +* +* var out = gsome( x.length, 2, x, 1 ); +* // returns true +* +* @example +* var gsome = require( '@stdlib/blas/ext/base/gsome' ); +* +* var x = [ 0.0, 0.0, 0.0, 0.0 ]; +* +* var out = gsome.ndarray( x.length, 2, x, 1, 0 ); +* // returns false +*/ + +// 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/gsome/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gsome/lib/main.js new file mode 100644 index 000000000000..0256a7a2610a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/lib/main.js @@ -0,0 +1,52 @@ +/** +* @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 // + +/** +* Tests whether a strided array contains at least `k` truthy elements. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {PositiveInteger} k - minimum number of truthy elements +* @param {Collection} x - input array +* @param {integer} strideX - stride length +* @returns {boolean} boolean indicating whether the input array contains at least k truthy elements +* +* @example +* var x = [ 0.0, 0.0, 1.0, 2.0 ]; +* +* var v = gsome( x.length, 2, x, 1 ); +* // returns true +*/ +function gsome( N, k, x, strideX ) { + var ox = stride2offset( N, strideX ); + return ndarray( N, k, x, strideX, ox ); +} + + +// EXPORTS // + +module.exports = gsome; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsome/lib/ndarray.js new file mode 100644 index 000000000000..8136e26002ba --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/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 // + +/** +* Tests whether a strided array contains at least `k` truthy elements. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {PositiveInteger} k - minimum number of truthy elements +* @param {Collection} x - input array +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @returns {boolean} boolean indicating whether the input array contains at least k truthy elements +* +* @example +* var x = [ 0.0, 0.0, 1.0, 2.0 ]; +* +* var v = gsome( 4, 2, x, 1, 0 ); +* // returns true +*/ +function gsome( N, k, x, strideX, offsetX ) { + var count; + var ix; + var o; + var i; + + if ( N <= 0 ) { + return false; + } + o = arraylike2object( x ); + if ( o.accessorProtocol ) { + return accessors( N, k, o, strideX, offsetX ); + } + if ( strideX === 0 ) { + return ( x[ offsetX ] ) ? k <= N : k <= 0; + } + ix = offsetX; + count = 0; + for ( i = 0; i < N; i++ ) { + if ( x[ ix ] ) { + count += 1; + if ( count >= k ) { + return true; + } + } + ix += strideX; + } + return false; +} + + +// EXPORTS // + +module.exports = gsome; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/package.json b/lib/node_modules/@stdlib/blas/ext/base/gsome/package.json new file mode 100644 index 000000000000..0f1f42438f5a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/blas/ext/base/gsome", + "version": "0.0.0", + "description": "Test whether a strided array contains at least `k` truthy elements.", + "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", + "statistics", + "stats", + "mathematics", + "math", + "blas", + "extended", + "some", + "gsome", + "truthy", + "boolean", + "strided", + "strided array", + "array" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gsome/test/test.js new file mode 100644 index 000000000000..1e0c96301f07 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/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 gsome = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gsome, '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 gsome.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gsome/test/test.main.js new file mode 100644 index 000000000000..130f0206dea2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/test/test.main.js @@ -0,0 +1,223 @@ +/** +* @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 gsome = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gsome, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( gsome.length, 4, 'has expected arity' ); + t.end(); +}); + +tape( 'the function tests whether a strided array contains at least k truthy elements', function test( t ) { + var x; + var v; + + x = [ 0, 0, 1, 2 ]; + v = gsome( x.length, 2, x, 1 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 0, 0, 0, 0 ]; + v = gsome( x.length, 1, x, 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + v = gsome( x.length, 5, x, 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + v = gsome( x.length, 4, x, 1 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a strided array contains at least k truthy elements (accessors)', function test( t ) { + var x; + var v; + + x = [ 0, 0, 1, 2 ]; + v = gsome( x.length, 2, toAccessorArray( x ), 1 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 0, 0, 0, 0 ]; + v = gsome( x.length, 1, toAccessorArray( x ), 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + v = gsome( x.length, 5, toAccessorArray( x ), 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + v = gsome( x.length, 4, toAccessorArray( x ), 1 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `false`', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4 ]; + + v = gsome( 0, 1, x, 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + v = gsome( -1, 1, x, 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `false` (accessors)', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4 ]; + + v = gsome( 0, 1, toAccessorArray( x ), 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + v = gsome( -1, 1, toAccessorArray( x ), 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a `stride` parameter', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4, 5, 6 ]; + + v = gsome( 3, 2, x, 2 ); + t.strictEqual( v, true, 'returns expected value' ); + + v = gsome( 3, 1, x, 2 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a `stride` parameter (accessors)', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4, 5, 6 ]; + + v = gsome( 3, 2, toAccessorArray( x ), 2 ); + t.strictEqual( v, true, 'returns expected value' ); + + v = gsome( 3, 1, toAccessorArray( x ), 2 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a stride of `0`', function test( t ) { + var x; + var v; + + x = [ 0, 0, 0, 0 ]; + v = gsome( 2, 1, x, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 2, 1, x, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 3, 2, x, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 0, 0, 0, 0 ]; + v = gsome( 3, 2, x, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 2, 3, x, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a stride of `0` (accessors)', function test( t ) { + var x; + var v; + + x = [ 0, 0, 0, 0 ]; + v = gsome( 2, 1, toAccessorArray( x ), 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 2, 1, toAccessorArray( x ), 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 3, 2, toAccessorArray( x ), 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 0, 0, 0, 0 ]; + v = gsome( 3, 2, toAccessorArray( x ), 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 2, 3, toAccessorArray( x ), 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4, 5, 6 ]; + + v = gsome( 3, 2, x, -2 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides (accessors)', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4, 5, 6 ]; + + v = gsome( 3, 2, toAccessorArray( x ), -2 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsome/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsome/test/test.ndarray.js new file mode 100644 index 000000000000..150daee6c18b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gsome/test/test.ndarray.js @@ -0,0 +1,253 @@ +/** +* @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 gsome = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gsome, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( gsome.length, 5, 'has expected arity' ); + t.end(); +}); + +tape( 'the function tests whether a strided array contains at least k truthy elements', function test( t ) { + var x; + var v; + + x = [ 0, 0, 1, 2 ]; + v = gsome( x.length, 2, x, 1, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 0, 0, 0, 0 ]; + v = gsome( x.length, 1, x, 1, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + v = gsome( x.length, 5, x, 1, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + v = gsome( x.length, 4, x, 1, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a strided array contains at least k truthy elements (accessors)', function test( t ) { + var x; + var v; + + x = [ 0, 0, 1, 2 ]; + v = gsome( x.length, 2, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 0, 0, 0, 0 ]; + v = gsome( x.length, 1, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + v = gsome( x.length, 5, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 2, 3, 4 ]; + v = gsome( x.length, 4, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `false`', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4 ]; + + v = gsome( 0, 1, x, 1, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + v = gsome( -1, 1, x, 1, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `false` (accessors)', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4 ]; + + v = gsome( 0, 1, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + v = gsome( -1, 1, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a `stride` parameter', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4, 5, 6 ]; + + v = gsome( 3, 2, x, 2, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + v = gsome( 3, 1, x, 2, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a `stride` parameter (accessors)', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4, 5, 6 ]; + + v = gsome( 3, 2, toAccessorArray( x ), 2, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + v = gsome( 3, 1, toAccessorArray( x ), 2, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `offset` parameter', function test( t ) { + var x; + var v; + + x = [ 0, 1, 2, 3, 4 ]; + + v = gsome( 2, 2, x, 1, 1 ); + t.strictEqual( v, true, 'returns expected value' ); + + v = gsome( 2, 3, x, 1, 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `offset` parameter (accessors)', function test( t ) { + var x; + var v; + + x = [ 0, 1, 2, 3, 4 ]; + + v = gsome( 2, 2, toAccessorArray( x ), 1, 1 ); + t.strictEqual( v, true, 'returns expected value' ); + + v = gsome( 2, 3, toAccessorArray( x ), 1, 1 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a stride of `0`', function test( t ) { + var x; + var v; + + x = [ 0, 0, 0, 0 ]; + v = gsome( 2, 1, x, 0, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 2, 1, x, 0, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 3, 2, x, 0, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 0, 0, 0, 0 ]; + v = gsome( 3, 2, x, 0, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 2, 3, x, 0, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a stride of `0` (accessors)', function test( t ) { + var x; + var v; + + x = [ 0, 0, 0, 0 ]; + v = gsome( 2, 1, toAccessorArray( x ), 0, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 2, 1, toAccessorArray( x ), 0, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 3, 2, toAccessorArray( x ), 0, 0 ); + t.strictEqual( v, true, 'returns expected value' ); + + x = [ 0, 0, 0, 0 ]; + v = gsome( 3, 2, toAccessorArray( x ), 0, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + x = [ 1, 1, 1, 1 ]; + v = gsome( 2, 3, toAccessorArray( x ), 0, 0 ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4, 5, 6 ]; + + v = gsome( 3, 2, x, -2, 5 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides (accessors)', function test( t ) { + var x; + var v; + + x = [ 1, 2, 3, 4, 5, 6 ]; + + v = gsome( 3, 2, toAccessorArray( x ), -2, 5 ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +});