diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/README.md new file mode 100644 index 000000000000..d6eb1d6aa4ad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/README.md @@ -0,0 +1,109 @@ + + +# dnone + +> Test whether every element in a one-dimensional double-precision floating-point ndarray is falsy. + +
+ +
+ + + +
+ +## Usage + +```javascript +var dnone = require( '@stdlib/blas/ext/base/ndarray/dnone' ); +``` + +#### dnone( arrays ) + +Tests whether every element in a one-dimensional double-precision floating-point ndarray is falsy. + +```javascript +var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); + +var x = new Float64Vector( [ 0.0, 0.0, 1.0, 1.0 ] ); + +var v = dnone( [ x ] ); +// returns false +``` + +The function has the following parameters: + +- **arrays**: array-like object containing a one-dimensional input ndarray. + +
+ + + +
+ +## Notes + +- If provided an empty one-dimensional ndarray, the function returns `true`. +- The function explicitly treats `NaN` values as falsy. + +
+ + + +
+ +## Examples + + + +```javascript +var bernoulli = require( '@stdlib/random/bernoulli' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var dnone = require( '@stdlib/blas/ext/base/ndarray/dnone' ); + +var x = bernoulli( [ 10 ], 0.2, { + 'dtype': 'float64' +}); +console.log( ndarray2array( x ) ); + +var v = dnone( [ x ] ); +console.log( v ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/benchmark/benchmark.js new file mode 100644 index 000000000000..6b33e7948063 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/benchmark/benchmark.js @@ -0,0 +1,102 @@ +/** +* @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 pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dnone = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeros( [ len ], options ); + 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 = dnone( [ x ] ); + 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/dnone/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/docs/repl.txt new file mode 100644 index 000000000000..664157ebdcf8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/docs/repl.txt @@ -0,0 +1,28 @@ + +{{alias}}( arrays ) + Tests whether every element in a one-dimensional double-precision floating- + point ndarray is falsy. + + If provided an empty ndarray, the function returns `true`. + + The function explicitly treats `NaN` values as falsy. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing a one-dimensional input ndarray. + + Returns + ------- + bool: boolean + Boolean indicating whether all elements are falsy. + + Examples + -------- + > var x = new {{alias:@stdlib/ndarray/vector/float64}}( [ 0.0, 0.0, 1.0 ] ); + > {{alias}}( [ x ] ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/docs/types/index.d.ts new file mode 100644 index 000000000000..2f3b59fdc674 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/docs/types/index.d.ts @@ -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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { float64ndarray } from '@stdlib/types/ndarray'; + +/** +* Tests whether every element in a one-dimensional double-precision floating-point ndarray is falsy. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* +* - The function explicitly treats `NaN` values as falsy. +* +* @param arrays - array-like object containing ndarrays +* @returns boolean indicating whether all elements are falsy +* +* @example +* var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* +* var x = new Float64Vector( [ 0.0, 0.0, 1.0, 1.0 ] ); +* +* var v = dnone( [ x ] ); +* // returns false +*/ +declare function dnone( arrays: [ float64ndarray ] ): boolean; + + +// EXPORTS // + +export = dnone; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/docs/types/test.ts new file mode 100644 index 000000000000..77223f7fc4d7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/docs/types/test.ts @@ -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. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import dnone = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float64' + }); + + dnone( [ x ] ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + dnone( '10' ); // $ExpectError + dnone( 10 ); // $ExpectError + dnone( true ); // $ExpectError + dnone( false ); // $ExpectError + dnone( null ); // $ExpectError + dnone( undefined ); // $ExpectError + dnone( [] ); // $ExpectError + dnone( {} ); // $ExpectError + dnone( ( 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': 'float64' + }); + + dnone(); // $ExpectError + dnone( [ x ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/examples/index.js new file mode 100644 index 000000000000..a22f240a7b69 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/examples/index.js @@ -0,0 +1,31 @@ +/** +* @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 ndarray2array = require( '@stdlib/ndarray/to-array' ); +var dnone = require( './../lib' ); + +var x = bernoulli( [ 10 ], 0.2, { + 'dtype': 'float64' +}); +console.log( ndarray2array( x ) ); + +var v = dnone( [ x ] ); +console.log( v ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/lib/index.js new file mode 100644 index 000000000000..7f1508c12263 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/lib/index.js @@ -0,0 +1,43 @@ +/** +* @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 every element in a one-dimensional double-precision floating-point ndarray is falsy. +* +* @module @stdlib/blas/ext/base/ndarray/dnone +* +* @example +* var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var dnone = require( '@stdlib/blas/ext/base/ndarray/dnone' ); +* +* var x = new Float64Vector( [ 0.0, 0.0, 1.0, 1.0 ] ); +* +* var v = dnone( [ x ] ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/lib/main.js new file mode 100644 index 000000000000..bb7df3f74474 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/lib/main.js @@ -0,0 +1,62 @@ +/** +* @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 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/dnone' ).ndarray; + + +// MAIN // + +/** +* Tests whether every element in a one-dimensional double-precision floating-point ndarray is falsy. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* +* - The function explicitly treats `NaN` values as falsy. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {boolean} boolean indicating whether all elements are falsy +* +* @example +* var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* +* var x = new Float64Vector( [ 0.0, 0.0, 1.0, 1.0 ] ); +* +* var v = dnone( [ x ] ); +* // returns false +*/ +function dnone( arrays ) { + var x = arrays[ 0 ]; + return strided( numelDimension( x, 0 ), getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dnone; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/package.json new file mode 100644 index 000000000000..f47c17ed8f88 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/dnone", + "version": "0.0.0", + "description": "Test whether every element in a one-dimensional double-precision floating-point ndarray is falsy.", + "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", + "none", + "dnone", + "falsy", + "test", + "boolean", + "ndarray", + "float64", + "double-precision", + "float64array" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/test/test.js new file mode 100644 index 000000000000..dbd8e8360f80 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnone/test/test.js @@ -0,0 +1,178 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var dnone = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Float64Array} 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( 'float64', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dnone, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( dnone.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function tests whether every element in a one-dimensional ndarray is falsy', function test( t ) { + var x; + var v; + + x = new Float64Array( [ 0.0, 0.0, 1.0, 1.0 ] ); + v = dnone( [ vector( x, 4, 1, 0 ) ] ); + t.strictEqual( v, false, 'returns expected value' ); + + x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + v = dnone( [ vector( x, 5, 1, 0 ) ] ); + t.strictEqual( v, true, 'returns expected value' ); + + x = new Float64Array( [ 1.0, 0.0, 0.0 ] ); + v = dnone( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( v, false, 'returns expected value' ); + + x = new Float64Array( [ -0.0, 0.0, -0.0 ] ); + v = dnone( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( v, true, 'returns expected value' ); + + x = new Float64Array( [ -1.0, 0.0, 0.0 ] ); + v = dnone( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function treats `NaN` values as falsy', function test( t ) { + var x; + var v; + + x = new Float64Array( [ NaN, 0.0, 0.0 ] ); + v = dnone( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( v, true, 'returns expected value' ); + + x = new Float64Array( [ NaN, NaN, NaN ] ); + v = dnone( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( v, true, 'returns expected value' ); + + x = new Float64Array( [ NaN, 0.0, 1.0 ] ); + v = dnone( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( v, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an empty ndarray, the function returns `true`', function test( t ) { + var x; + var v; + + x = new Float64Array( [] ); + + v = dnone( [ vector( x, 0, 1, 0 ) ] ); + t.strictEqual( v, true, '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 Float64Array([ + 0.0, // 0 + 1.0, + 0.0, // 1 + 1.0, + 0.0, // 2 + 1.0, + 0.0, // 3 + 1.0 + ]); + + v = dnone( [ vector( x, 4, 2, 0 ) ] ); + + 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 Float64Array([ + 1.0, // 3 + 0.0, + 0.0, // 2 + 0.0, + 0.0, // 1 + 0.0, + 0.0, // 0 + 0.0 + ]); + + v = dnone( [ vector( x, 4, -2, 6 ) ] ); + + t.strictEqual( v, false, '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 Float64Array([ + 1.0, + 0.0, // 0 + 1.0, + 0.0, // 1 + 1.0, + 0.0, // 2 + 1.0, + 0.0 // 3 + ]); + + v = dnone( [ vector( x, 4, 2, 1 ) ] ); + t.strictEqual( v, true, 'returns expected value' ); + + t.end(); +});