From 295322b26ca7e1e7c974cfb3eb9a1e51a488bb87 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 23 Aug 2026 21:55:48 +0500 Subject: [PATCH] feat: add blas/ext/base/ndarray/ssome --- .../blas/ext/base/ndarray/ssome/README.md | 122 ++++++++++++ .../base/ndarray/ssome/benchmark/benchmark.js | 107 ++++++++++ .../blas/ext/base/ndarray/ssome/docs/repl.txt | 33 ++++ .../base/ndarray/ssome/docs/types/index.d.ts | 58 ++++++ .../ext/base/ndarray/ssome/docs/types/test.ts | 64 ++++++ .../ext/base/ndarray/ssome/examples/index.js | 36 ++++ .../blas/ext/base/ndarray/ssome/lib/index.js | 48 +++++ .../blas/ext/base/ndarray/ssome/lib/main.js | 70 +++++++ .../blas/ext/base/ndarray/ssome/package.json | 69 +++++++ .../blas/ext/base/ndarray/ssome/test/test.js | 186 ++++++++++++++++++ 10 files changed, 793 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/test/test.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/README.md new file mode 100644 index 000000000000..2c62d2549713 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/README.md @@ -0,0 +1,122 @@ + + +# ssome + +> Test whether a one-dimensional single-precision floating-point ndarray contains at least `k` truthy elements. + +
+ +
+ + + +
+ +## Usage + +```javascript +var ssome = require( '@stdlib/blas/ext/base/ndarray/ssome' ); +``` + +#### ssome( arrays ) + +Tests whether a one-dimensional single-precision floating-point ndarray contains at least `k` truthy elements. + +```javascript +var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +var x = new Float32Vector( [ 0.0, 0.0, 1.0, 2.0 ] ); + +var k = scalar2ndarray( 2, { + 'dtype': 'generic' +}); + +var v = ssome( [ x, k ] ); +// returns true +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray specifying the minimum number of truthy elements. + +
+ + + +
+ +## Notes + +- If provided an empty one-dimensional ndarray, the function returns `false`. +- The function explicitly treats `NaN` values as falsy. + +
+ + + +
+ +## Examples + + + +```javascript +var bernoulli = require( '@stdlib/random/bernoulli' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ssome = require( '@stdlib/blas/ext/base/ndarray/ssome' ); + +var x = bernoulli( [ 10 ], 0.3, { + 'dtype': 'float32' +}); +console.log( ndarray2array( x ) ); + +var k = scalar2ndarray( 3, { + 'dtype': 'generic' +}); + +var v = ssome( [ x, k ] ); +console.log( v ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/benchmark/benchmark.js new file mode 100644 index 000000000000..ef6db6c9acab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/benchmark/benchmark.js @@ -0,0 +1,107 @@ +/** +* @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 zeros = require( '@stdlib/ndarray/zeros' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +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 ssome = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeros( [ len ], options ); + var k = scalar2ndarray( floor( len / 2 ), { + 'dtype': 'generic' + }); + 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 = ssome( [ x, k ] ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( typeof out !== 'boolean' ) { + 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/ndarray/ssome/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/docs/repl.txt new file mode 100644 index 000000000000..b371fda00250 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/docs/repl.txt @@ -0,0 +1,33 @@ + +{{alias}}( arrays ) + Tests whether a one-dimensional single-precision floating-point ndarray + contains at least `k` truthy elements. + + If provided an empty ndarray, the function returns `false`. + + The function explicitly treats `NaN` values as falsy. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray specifying the minimum number of truthy + elements. + + Returns + ------- + bool: boolean + Boolean indicating whether the input ndarray contains at least `k` + truthy elements. + + Examples + -------- + > var x = new {{alias:@stdlib/ndarray/vector/float32}}( [ 0.0, 0.0, 1.0, 2.0 ] ); + > var k = {{alias:@stdlib/ndarray/from-scalar}}( 2, { 'dtype': 'generic' } ); + > {{alias}}( [ x, k ] ) + true + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/docs/types/index.d.ts new file mode 100644 index 000000000000..b83ec65af749 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/docs/types/index.d.ts @@ -0,0 +1,58 @@ +/* +* @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 { float32ndarray, typedndarray } from '@stdlib/types/ndarray'; + +/** +* Tests whether a one-dimensional single-precision floating-point ndarray contains at least `k` truthy elements. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a zero-dimensional ndarray specifying the minimum number of truthy elements. +* +* - The function explicitly treats `NaN` values as falsy. +* +* @param arrays - array-like object containing ndarrays +* @returns boolean indicating whether the input ndarray contains at least `k` truthy elements +* +* @example +* var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Float32Vector( [ 0.0, 0.0, 1.0, 2.0 ] ); +* +* var k = scalar2ndarray( 2, { +* 'dtype': 'generic' +* }); +* +* var v = ssome( [ x, k ] ); +* // returns true +*/ +declare function ssome( arrays: [ float32ndarray, typedndarray ] ): boolean; + + +// EXPORTS // + +export = ssome; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/docs/types/test.ts new file mode 100644 index 000000000000..843784f24180 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/docs/types/test.ts @@ -0,0 +1,64 @@ +/* +* @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. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +import ssome = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float32' + }); + const k = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + + ssome( [ x, k ] ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + ssome( '10' ); // $ExpectError + ssome( 10 ); // $ExpectError + ssome( true ); // $ExpectError + ssome( false ); // $ExpectError + ssome( null ); // $ExpectError + ssome( undefined ); // $ExpectError + ssome( [] ); // $ExpectError + ssome( {} ); // $ExpectError + ssome( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float32' + }); + const k = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + + ssome(); // $ExpectError + ssome( [ x, k ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/examples/index.js new file mode 100644 index 000000000000..d20ce660594d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/examples/index.js @@ -0,0 +1,36 @@ +/** +* @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/bernoulli' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ssome = require( './../lib' ); + +var x = bernoulli( [ 10 ], 0.3, { + 'dtype': 'float32' +}); +console.log( ndarray2array( x ) ); + +var k = scalar2ndarray( 3, { + 'dtype': 'generic' +}); + +var v = ssome( [ x, k ] ); +console.log( v ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/lib/index.js new file mode 100644 index 000000000000..4552dec479a7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/lib/index.js @@ -0,0 +1,48 @@ +/** +* @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 one-dimensional single-precision floating-point ndarray contains at least `k` truthy elements. +* +* @module @stdlib/blas/ext/base/ndarray/ssome +* +* @example +* var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var ssome = require( '@stdlib/blas/ext/base/ndarray/ssome' ); +* +* var x = new Float32Vector( [ 0.0, 0.0, 1.0, 2.0 ] ); +* +* var k = scalar2ndarray( 2, { +* 'dtype': 'generic' +* }); +* +* var v = ssome( [ x, k ] ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/lib/main.js new file mode 100644 index 000000000000..2fb6f95f7bdc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/lib/main.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 ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); +var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var strided = require( '@stdlib/blas/ext/base/ssome' ).ndarray; + + +// MAIN // + +/** +* Tests whether a one-dimensional single-precision floating-point ndarray contains at least `k` truthy elements. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a zero-dimensional ndarray specifying the minimum number of truthy elements. +* +* - The function explicitly treats `NaN` values as falsy. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {boolean} boolean indicating whether the input ndarray contains at least `k` truthy elements +* +* @example +* var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Float32Vector( [ 0.0, 0.0, 1.0, 2.0 ] ); +* +* var k = scalar2ndarray( 2, { +* 'dtype': 'generic' +* }); +* +* var v = ssome( [ x, k ] ); +* // returns true +*/ +function ssome( arrays ) { + var x = arrays[ 0 ]; + var k = ndarraylike2scalar( arrays[ 1 ] ); + return strided( numelDimension( x, 0 ), k, getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = ssome; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/package.json new file mode 100644 index 000000000000..59578cfdee96 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/ssome", + "version": "0.0.0", + "description": "Test whether a one-dimensional single-precision floating-point ndarray 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", + "mathematics", + "math", + "blas", + "extended", + "some", + "ssome", + "truthy", + "test", + "boolean", + "ndarray", + "float32", + "single-precision", + "float32array" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/test/test.js new file mode 100644 index 000000000000..d00c85cdfc93 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssome/test/test.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ssome = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Float32Array} buffer - underlying data buffer +* @param {NonNegativeInteger} length - number of indexed elements +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector( buffer, length, stride, offset ) { + return new ndarray( 'float32', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + +/** +* Returns a zero-dimensional ndarray. +* +* @private +* @param {integer} k - minimum number of truthy elements +* @returns {ndarray} zero-dimensional ndarray +*/ +function scalar( k ) { + return scalar2ndarray( k, { + 'dtype': 'generic' + }); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ssome, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( ssome.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function tests whether a one-dimensional ndarray contains at least `k` truthy elements', function test( t ) { + var x; + var v; + + x = new Float32Array( [ 0.0, 0.0, 1.0, 2.0 ] ); + v = ssome( [ vector( x, 4, 1, 0 ), scalar( 2 ) ] ); + t.strictEqual( v, true, 'returns expected value' ); + + x = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + v = ssome( [ vector( x, 4, 1, 0 ), scalar( 1 ) ] ); + t.strictEqual( v, false, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + v = ssome( [ vector( x, 4, 1, 0 ), scalar( 5 ) ] ); + t.strictEqual( v, false, 'returns expected value' ); + + x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + v = ssome( [ vector( x, 4, 1, 0 ), scalar( 4 ) ] ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function treats `NaN` values as falsy', function test( t ) { + var x; + var v; + + x = new Float32Array( [ NaN, NaN, NaN ] ); + v = ssome( [ vector( x, 3, 1, 0 ), scalar( 1 ) ] ); + t.strictEqual( v, false, 'returns expected value' ); + + x = new Float32Array( [ NaN, 1.0, 2.0 ] ); + v = ssome( [ vector( x, 3, 1, 0 ), scalar( 2 ) ] ); + t.strictEqual( v, true, 'returns expected value' ); + + x = new Float32Array( [ NaN, 1.0, 0.0 ] ); + v = ssome( [ vector( x, 3, 1, 0 ), scalar( 2 ) ] ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an empty ndarray, the function returns `false`', function test( t ) { + var x; + var v; + + x = new Float32Array( [] ); + + v = ssome( [ vector( x, 0, 1, 0 ), scalar( 1 ) ] ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { + var x; + var v; + + x = new Float32Array([ + 1.0, // 0 + 0.0, + 0.0, // 1 + 0.0, + 1.0, // 2 + 0.0, + 0.0, // 3 + 0.0 + ]); + + v = ssome( [ vector( x, 4, 2, 0 ), scalar( 2 ) ] ); + + t.strictEqual( v, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having negative strides', function test( t ) { + var x; + var v; + + x = new Float32Array([ + 1.0, + 2.0, // 2 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 0 + ]); + + v = ssome( [ vector( x, 3, -2, 5 ), scalar( 2 ) ] ); + + t.strictEqual( v, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { + var x; + var v; + + x = new Float32Array([ + 0.0, + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0 + ]); + + v = ssome( [ vector( x, 2, 1, 1 ), scalar( 2 ) ] ); + t.strictEqual( v, true, 'returns expected value' ); + + v = ssome( [ vector( x, 2, 1, 1 ), scalar( 3 ) ] ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +});