diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/README.md b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/README.md new file mode 100644 index 000000000000..557fa9e24450 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/README.md @@ -0,0 +1,127 @@ + + +# smskmin + +> Calculate the minimum value of a one-dimensional single-precision floating-point ndarray according to a mask. + +
+ +
+ + + +
+ +## Usage + +```javascript +var smskmin = require( '@stdlib/stats/base/ndarray/smskmin' ); +``` + +#### smskmin( arrays ) + +Computes the minimum value of a one-dimensional single-precision floating-point ndarray according to a mask. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); + +var xbuf = new Float32Array( [ 1.0, -2.0, 4.0, 2.0 ] ); +var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); + +var maskbuf = new Uint8Array( [ 0, 0, 1, 0 ] ); +var mask = new ndarray( 'uint8', maskbuf, [ 4 ], [ 1 ], 0, 'row-major' ); + +var v = smskmin( [ x, mask ] ); +// returns -2.0 +``` + +The function has the following parameters: + +- **arrays**: array-like object containing an input ndarray and a mask ndarray. + +If a `mask` array element is `0`, the corresponding element in the input ndarray is considered valid and **included** in computation. If a `mask` array element is `1`, the corresponding element in the input ndarray is considered invalid/missing and **excluded** from computation. + +
+ + + +
+ +## Notes + +- If provided an empty ndarray or a mask with all elements set to `1`, the function returns `NaN`. + +
+ + + +
+ +## Examples + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var bernoulli = require( '@stdlib/random/array/bernoulli' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var smskmin = require( '@stdlib/stats/base/ndarray/smskmin' ); + +var xbuf = uniform( 10, -50.0, 50.0, { + 'dtype': 'float32' +}); +var x = new ndarray( 'float32', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var maskbuf = bernoulli( xbuf.length, 0.2, { + 'dtype': 'uint8' +}); +var mask = new ndarray( 'uint8', maskbuf, [ maskbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( mask ) ); + +var v = smskmin( [ x, mask ] ); +console.log( v ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/benchmark/benchmark.js new file mode 100644 index 000000000000..8a6f86d8561f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/benchmark/benchmark.js @@ -0,0 +1,112 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 uniform = require( '@stdlib/random/array/uniform' ); +var bernoulli = require( '@stdlib/random/array/bernoulli' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var pkg = require( './../package.json' ).name; +var smskmin = require( './../lib' ); + + +// VARIABLES // + +var xoptions = { + 'dtype': 'float32' +}; +var moptions = { + 'dtype': 'uint8' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var mask; + var mbuf; + var xbuf; + var x; + + xbuf = uniform( len, -100.0, 100.0, xoptions ); + x = new ndarray( xoptions.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' ); + + mbuf = bernoulli( len, 0.2, moptions ); + mask = new ndarray( moptions.dtype, mbuf, [ len ], [ 1 ], 0, 'row-major' ); + + return benchmark; + + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + xbuf[ i%len ] = i; + v = smskmin( [ x, mask ] ); + if ( isnanf( v ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( v ) ) { + b.fail( 'should not return NaN' ); + } + 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( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/docs/repl.txt new file mode 100644 index 000000000000..c73148d904fa --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/docs/repl.txt @@ -0,0 +1,35 @@ + +{{alias}}( arrays ) + Computes the minimum value of a one-dimensional single-precision floating- + point ndarray according to a mask. + + If provided an empty ndarray or a mask with all elements set to `1`, the + function returns `NaN`. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing an input ndarray and a mask ndarray. + + Returns + ------- + out: number + Minimum value. + + Examples + -------- + > var xbuf = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 4.0, 2.0 ] ); + > var dt = 'float32'; + > var sh = [ xbuf.length ]; + > var sx = [ 1 ]; + > var ox = 0; + > var ord = 'row-major'; + > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); + > var mbuf = new {{alias:@stdlib/array/uint8}}( [ 0, 0, 1, 0 ] ); + > var mdt = 'uint8'; + > var mask = new {{alias:@stdlib/ndarray/ctor}}( mdt, mbuf, sh, sx, ox, ord ); + > {{alias}}( [ x, mask ] ) + -2.0 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/docs/types/index.d.ts new file mode 100644 index 000000000000..cd50efe47589 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/docs/types/index.d.ts @@ -0,0 +1,50 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 { ndarray } from '@stdlib/types/ndarray'; + +/** +* Computes the minimum value of a one-dimensional single-precision floating-point ndarray according to a mask. +* +* @param arrays - array-like object containing an input ndarray and a mask ndarray +* @returns minimum value +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* +* var xbuf = new Float32Array( [ 1.0, -2.0, 4.0, 2.0 ] ); +* var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var maskbuf = new Uint8Array( [ 0, 0, 1, 0 ] ); +* var mask = new ndarray( 'uint8', maskbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var v = smskmin( [ x, mask ] ); +* // returns -2.0 +*/ +declare function smskmin( arrays: [ T, T ] ): number; + + +// EXPORTS // + +export = smskmin; diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/docs/types/test.ts new file mode 100644 index 000000000000..364f31a67422 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/docs/types/test.ts @@ -0,0 +1,63 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 smskmin = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float32' + }); + const mask = zeros( [ 10 ], { + 'dtype': 'uint8' + }); + + smskmin( [ x, mask ] ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + smskmin( '10' ); // $ExpectError + smskmin( 10 ); // $ExpectError + smskmin( true ); // $ExpectError + smskmin( false ); // $ExpectError + smskmin( null ); // $ExpectError + smskmin( undefined ); // $ExpectError + smskmin( [] ); // $ExpectError + smskmin( {} ); // $ExpectError + smskmin( ( 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 mask = zeros( [ 10 ], { + 'dtype': 'uint8' + }); + + smskmin(); // $ExpectError + smskmin( [ x, mask ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/examples/index.js b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/examples/index.js new file mode 100644 index 000000000000..25b500f6bf07 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 uniform = require( '@stdlib/random/array/uniform' ); +var bernoulli = require( '@stdlib/random/array/bernoulli' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var smskmin = require( './../lib' ); + +var xbuf = uniform( 10, -50.0, 50.0, { + 'dtype': 'float32' +}); +var x = new ndarray( 'float32', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var maskbuf = bernoulli( xbuf.length, 0.2, { + 'dtype': 'uint8' +}); +var mask = new ndarray( 'uint8', maskbuf, [ maskbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( mask ) ); + +var v = smskmin( [ x, mask ] ); +console.log( v ); diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/lib/index.js b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/lib/index.js new file mode 100644 index 000000000000..0879fc5f737e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/lib/index.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Calculate the minimum value of a one-dimensional single-precision floating-point ndarray according to a mask. +* +* @module @stdlib/stats/base/ndarray/smskmin +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var smskmin = require( '@stdlib/stats/base/ndarray/smskmin' ); +* +* var xbuf = new Float32Array( [ 1.0, -2.0, 4.0, 2.0 ] ); +* var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var maskbuf = new Uint8Array( [ 0, 0, 1, 0 ] ); +* var mask = new ndarray( 'uint8', maskbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var v = smskmin( [ x, mask ] ); +* // returns -2.0 +*/ + +// MODULES // + +var smskmin = require( './main.js' ); + + +// EXPORTS // + +module.exports = smskmin; diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/lib/main.js b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/lib/main.js new file mode 100644 index 000000000000..3cc90f3b10c8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/lib/main.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 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/stats/strided/smskmin' ).ndarray; + + +// MAIN // + +/** +* Computes the minimum value of a one-dimensional single-precision floating-point ndarray according to a mask. +* +* @param {ArrayLikeObject} arrays - array-like object containing an input ndarray and a mask ndarray +* @returns {number} minimum value +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var Uint8Array = require( '@stdlib/array/uint8' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* +* var xbuf = new Float32Array( [ 1.0, -2.0, 4.0, 2.0 ] ); +* var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var maskbuf = new Uint8Array( [ 0, 0, 1, 0 ] ); +* var mask = new ndarray( 'uint8', maskbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var v = smskmin( [ x, mask ] ); +* // returns -2.0 +*/ +function smskmin( arrays ) { + var mask = arrays[ 1 ]; + var x = arrays[ 0 ]; + return strided( numelDimension( x, 0 ), getData( x ), getStride( x, 0 ), getOffset( x ), getData( mask ), getStride( mask, 0 ), getOffset( mask ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = smskmin; diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/package.json b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/package.json new file mode 100644 index 000000000000..b5a31a67c58a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/stats/base/ndarray/smskmin", + "version": "0.0.0", + "description": "Calculate the minimum value of a one-dimensional single-precision floating-point ndarray according to a mask.", + "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", + "minimum", + "min", + "masked", + "mask", + "float32", + "single-precision", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/test/test.js b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/test/test.js new file mode 100644 index 000000000000..58e0ea796b5c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/smskmin/test/test.js @@ -0,0 +1,253 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Uint8Array = require( '@stdlib/array/uint8' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var smskmin = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {string} dtype - data type +* @param {Collection} 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( dtype, buffer, length, stride, offset ) { + return new ndarray( dtype, buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof smskmin, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( smskmin.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function calculates the minimum value of a one-dimensional ndarray according to a mask', function test( t ) { + var mask; + var x; + var v; + + x = new Float32Array( [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, 3.0 ] ); + mask = new Uint8Array( [ 0, 0, 0, 1, 0, 0, 0 ] ); + v = smskmin( [ vector( 'float32', x, x.length, 1, 0 ), vector( 'uint8', mask, mask.length, 1, 0 ) ] ); + t.strictEqual( v, -4.0, 'returns expected value' ); + + x = new Float32Array( [ -4.0, NaN, -5.0 ] ); + mask = new Uint8Array( [ 0, 1, 0 ] ); + v = smskmin( [ vector( 'float32', x, x.length, 1, 0 ), vector( 'uint8', mask, mask.length, 1, 0 ) ] ); + t.strictEqual( v, -5.0, 'returns expected value' ); + + x = new Float32Array( [ -0.0, 0.0, NaN, -0.0 ] ); + mask = new Uint8Array( [ 0, 0, 1, 0 ] ); + v = smskmin( [ vector( 'float32', x, x.length, 1, 0 ), vector( 'uint8', mask, mask.length, 1, 0 ) ] ); + t.strictEqual( isNegativeZerof( v ), true, 'returns expected value' ); + + x = new Float32Array( [ -4.0, 0.0, NaN, 5.0 ] ); + mask = new Uint8Array( [ 0, 0, 0, 0 ] ); + v = smskmin( [ vector( 'float32', x, x.length, 1, 0 ), vector( 'uint8', mask, mask.length, 1, 0 ) ] ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + + x = new Float32Array( [ NaN ] ); + mask = new Uint8Array( [ 0 ] ); + v = smskmin( [ vector( 'float32', x, x.length, 1, 0 ), vector( 'uint8', mask, mask.length, 1, 0 ) ] ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + + x = new Float32Array( [ NaN ] ); + mask = new Uint8Array( [ 1 ] ); + v = smskmin( [ vector( 'float32', x, x.length, 1, 0 ), vector( 'uint8', mask, mask.length, 1, 0 ) ] ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + + x = new Float32Array( [ NaN, NaN ] ); + mask = new Uint8Array( [ 1, 1 ] ); + v = smskmin( [ vector( 'float32', x, x.length, 1, 0 ), vector( 'uint8', mask, mask.length, 1, 0 ) ] ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + + x = new Float32Array( [ NaN, NaN ] ); + mask = new Uint8Array( [ 1, 0 ] ); + v = smskmin( [ vector( 'float32', x, x.length, 1, 0 ), vector( 'uint8', mask, mask.length, 1, 0 ) ] ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + + x = new Float32Array( [ NaN, NaN ] ); + mask = new Uint8Array( [ 0, 1 ] ); + v = smskmin( [ vector( 'float32', x, x.length, 1, 0 ), vector( 'uint8', mask, mask.length, 1, 0 ) ] ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + + x = new Float32Array( [ NaN, NaN ] ); + mask = new Uint8Array( [ 0, 0 ] ); + v = smskmin( [ vector( 'float32', x, x.length, 1, 0 ), vector( 'uint8', mask, mask.length, 1, 0 ) ] ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an empty ndarray, the function returns `NaN`', function test( t ) { + var mask; + var x; + var v; + + x = new Float32Array( [] ); + mask = new Uint8Array( [] ); + + v = smskmin( [ vector( 'float32', x, 0, 1, 0 ), vector( 'uint8', mask, 0, 1, 0 ) ] ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an ndarray containing a single element, the function returns the first element', function test( t ) { + var mask; + var x; + var v; + + x = new Float32Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); + mask = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); + + v = smskmin( [ vector( 'float32', x, 1, 1, 0 ), vector( 'uint8', mask, 1, 1, 0 ) ] ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { + var mask; + var x; + var v; + + x = new Float32Array([ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0, + 5.0, // 4 + 6.0 + ]); + mask = new Uint8Array([ + 0, // 0 + 0, + 0, // 1 + 0, + 0, // 2 + 0, + 0, // 3 + 0, + 1, // 4 + 1 + ]); + + v = smskmin( [ vector( 'float32', x, 5, 2, 0 ), vector( 'uint8', mask, 5, 2, 0 ) ] ); + t.strictEqual( v, -2.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having negative strides', function test( t ) { + var mask; + var x; + var v; + + x = new Float32Array([ + 5.0, // 4 + 6.0, + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]); + mask = new Uint8Array([ + 1, // 4 + 1, + 0, // 3 + 0, + 0, // 2 + 0, + 0, // 1 + 0, + 0, // 0 + 0 + ]); + + v = smskmin( [ vector( 'float32', x, 5, -2, 8 ), vector( 'uint8', mask, 5, -2, 8 ) ] ); + t.strictEqual( v, -2.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { + var mask; + var x; + var v; + + x = new Float32Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0, // 3 + 5.0, + 6.0 // 4 + ]); + mask = new Uint8Array([ + 0, + 0, // 0 + 0, + 0, // 1 + 0, + 0, // 2 + 0, + 0, // 3 + 1, + 1 // 4 + ]); + + v = smskmin( [ vector( 'float32', x, 5, 2, 1 ), vector( 'uint8', mask, 5, 2, 1 ) ] ); + t.strictEqual( v, -2.0, 'returns expected value' ); + + t.end(); +});