diff --git a/lib/node_modules/@stdlib/_tools/eslint/rules/no-dynamic-require/examples/index.js b/lib/node_modules/@stdlib/_tools/eslint/rules/no-dynamic-require/examples/index.js index d347dd85b233..7d8ae3655bde 100644 --- a/lib/node_modules/@stdlib/_tools/eslint/rules/no-dynamic-require/examples/index.js +++ b/lib/node_modules/@stdlib/_tools/eslint/rules/no-dynamic-require/examples/index.js @@ -39,17 +39,17 @@ result = linter.verify( code, { }); console.log( result ); /* => - [ - { - 'ruleId': 'no-dynamic-require', - 'severity': 2, - 'message': 'require() calls should only use string literals', - 'line': 2, - 'column': 15, - 'nodeType': 'CallExpression', - 'source': 'var betainc = require( pkg );', - 'endLine': 2, - 'endColumn': 29 - } - ] + [ + { + 'ruleId': 'no-dynamic-require', + 'severity': 2, + 'message': 'require() calls should only use string literals', + 'line': 2, + 'column': 15, + 'nodeType': 'CallExpression', + 'source': 'var betainc = require( pkg );', + 'endLine': 2, + 'endColumn': 29 + } + ] */ diff --git a/lib/node_modules/@stdlib/_tools/eslint/rules/tsdoc-declarations-doctest/lib/add_package_to_scope.js b/lib/node_modules/@stdlib/_tools/eslint/rules/tsdoc-declarations-doctest/lib/add_package_to_scope.js index 5fa060ceb18b..1a2170792807 100644 --- a/lib/node_modules/@stdlib/_tools/eslint/rules/tsdoc-declarations-doctest/lib/add_package_to_scope.js +++ b/lib/node_modules/@stdlib/_tools/eslint/rules/tsdoc-declarations-doctest/lib/add_package_to_scope.js @@ -33,7 +33,7 @@ var RE_DECLARE_CLASS = /declare\s+class\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s/; var RE_DECLARE_CONST = /declare\s+const\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:/; // Regular expression to match variable declarations with interface types such as "declare var ctor: Int32Vector;" (captures variable name and interface name): -var RE_DECLARE_VAR_INTERFACE = /declare\s+var\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:\s*([A-Z][a-zA-Z0-9_$]*)/; +var RE_DECLARE_VAR_INTERFACE = /declare\s+(?:var|const)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:\s*([A-Z][a-zA-Z0-9_$]*)/; // MAIN // diff --git a/lib/node_modules/@stdlib/blas/base/isamax/test/test.isamax.js b/lib/node_modules/@stdlib/blas/base/isamax/test/test.isamax.js index 19ad51ceae1b..b60e99fc38e6 100644 --- a/lib/node_modules/@stdlib/blas/base/isamax/test/test.isamax.js +++ b/lib/node_modules/@stdlib/blas/base/isamax/test/test.isamax.js @@ -57,13 +57,13 @@ tape( 'the function finds the index of the element with the maximum absolute val idx = isamax( 4, x, 1 ); t.strictEqual( idx, expected, 'returns expected value' ); - x = new Float32Array( [ + x = new Float32Array([ 0.2, // 1 -0.6, // 2 0.3, // 3 5.0, 5.0 - ] ); + ]); expected = 1; idx = isamax( 3, x, 1 ); @@ -77,11 +77,11 @@ tape( 'if provided an `N` parameter less than `1`, the function returns `-1`', f var idx; var x; - x = new Float32Array( [ + x = new Float32Array([ 1.0, 2.0, 3.0 - ] ); + ]); expected = -1; idx = isamax( 0, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/sorthp/lib/index.js b/lib/node_modules/@stdlib/blas/ext/sorthp/lib/index.js index 8123cc15d6a5..09412ed7dd01 100644 --- a/lib/node_modules/@stdlib/blas/ext/sorthp/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/sorthp/lib/index.js @@ -60,5 +60,3 @@ var main = require( './main.js' ); // EXPORTS // module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/node_modules/@stdlib/blas/ext/sorthp/test/test.js b/lib/node_modules/@stdlib/blas/ext/sorthp/test/test.js index 88532b7c87f4..1b09e9c43aab 100644 --- a/lib/node_modules/@stdlib/blas/ext/sorthp/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/sorthp/test/test.js @@ -336,7 +336,7 @@ tape( 'the function throws an error if provided a first argument which is not an } }); -tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a support string', function test( t ) { +tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a supported string', function test( t ) { var values; var x; var i; @@ -366,7 +366,7 @@ tape( 'the function throws an error if provided a `sortOrder` argument which is } }); -tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a support string (options)', function test( t ) { +tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a supported string (options)', function test( t ) { var values; var x; var i; diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/README.md b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/README.md new file mode 100644 index 000000000000..d34b9f3033af --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/README.md @@ -0,0 +1,245 @@ + + +# toSortedhp + +> Return a new [ndarray][@stdlib/ndarray/ctor] containing the elements of an input [ndarray][@stdlib/ndarray/ctor] sorted along one or more [ndarray][@stdlib/ndarray/ctor] dimensions using heapsort. + +
+ +## Usage + +```javascript +var toSortedhp = require( '@stdlib/blas/ext/to-sortedhp' ); +``` + +#### toSortedhp( x\[, sortOrder]\[, options] ) + +Returns a new [ndarray][@stdlib/ndarray/ctor] containing the elements of an input [ndarray][@stdlib/ndarray/ctor] sorted along one or more [ndarray][@stdlib/ndarray/ctor] dimensions using heapsort. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ -1.0, 2.0, -3.0 ] ); + +var y = toSortedhp( x ); +// returns + +var arr = ndarray2array( y ); +// returns [ -3.0, -1.0, 2.0 ] +``` + +The function has the following parameters: + +- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. +- **sortOrder**: sort order (_optional_). May be either a scalar value, string, or an [ndarray][@stdlib/ndarray/ctor] having a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. For example, given the input shape `[2, 3, 4]` and `options.dims=[0]`, an [ndarray][@stdlib/ndarray/ctor] sort order must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. Similarly, when performing the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor], an [ndarray][@stdlib/ndarray/ctor] sort order must be a zero-dimensional [ndarray][@stdlib/ndarray/ctor]. By default, the sort order is `1` (i.e., increasing order). +- **options**: function options (_optional_). + +The function accepts the following options: + +- **dims**: list of dimensions over which to perform operation. If not provided, the function performs the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor]. +- **dtype**: output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes]. + +By default, the function sorts elements in increasing order. To sort in a different order, provide a `sortOrder` argument. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ -1.0, 2.0, -3.0 ] ); + +var y = toSortedhp( x, -1.0 ); +// returns + +var arr = ndarray2array( y ); +// returns [ 2.0, -1.0, -3.0 ] +``` + +In addition to numeric values, one can specify the sort order via one of the following string literals: `'ascending'`, `'asc'`, `'descending'`, or `'desc'`. The first two literals indicate to sort in ascending (i.e., increasing) order. The last two literals indicate to sort in descending (i.e., decreasing) order. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ -1.0, 2.0, -3.0 ] ); + +// Sort in ascending order: +var y = toSortedhp( x, 'asc' ); +// returns + +var arr = ndarray2array( y ); +// returns [ -3.0, -1.0, 2.0 ] + +// Sort in descending order: +y = toSortedhp( x, 'descending' ); +// returns + +arr = ndarray2array( y ); +// returns [ 2.0, -1.0, -3.0 ] +``` + +By default, the function performs the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor]. To perform the operation over specific dimensions, provide a `dims` option. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ -1.0, 2.0, -3.0, 4.0 ], { + 'shape': [ 2, 2 ], + 'order': 'row-major' +}); + +var v = ndarray2array( x ); +// returns [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ] + +var y = toSortedhp( x, { + 'dims': [ 0 ] +}); +// returns + +v = ndarray2array( y ); +// returns [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ] +``` + +To specify the output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes], provide a `dtype` option. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ -1.0, 2.0, -3.0 ] ); + +var y = toSortedhp( x, { + 'dtype': 'float32' +}); +// returns + +var arr = ndarray2array( y ); +// returns [ -3.0, -1.0, 2.0 ] +``` + +#### toSortedhp.assign( x, out\[, sortOrder]\[, options] ) + +Sorts the elements of an input [ndarray][@stdlib/ndarray/ctor] along one or more [ndarray][@stdlib/ndarray/ctor] dimensions using heapsort and assigns the results to an output [ndarray][@stdlib/ndarray/ctor]. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ -1.0, 2.0, -3.0 ] ); +var y = zeros( [ 3 ] ); + +var out = toSortedhp.assign( x, y ); +// returns + +var arr = ndarray2array( out ); +// returns [ -3.0, -1.0, 2.0 ] + +var bool = ( y === out ); +// returns true +``` + +The function has the following parameters: + +- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. +- **out**: output [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. +- **sortOrder**: sort order (_optional_). May be either a scalar value, string, or an [ndarray][@stdlib/ndarray/ctor] having a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. For example, given the input shape `[2, 3, 4]` and `options.dims=[0]`, an [ndarray][@stdlib/ndarray/ctor] sort order must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. Similarly, when performing the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor], an [ndarray][@stdlib/ndarray/ctor] sort order must be a zero-dimensional [ndarray][@stdlib/ndarray/ctor]. By default, the sort order is `1` (i.e., increasing order). +- **options**: function options (_optional_). + +The function accepts the following options: + +- **dims**: list of dimensions over which to perform operation. If not provided, the function performs the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor]. + +
+ + + +
+ +## Notes + +- If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input [ndarray][@stdlib/ndarray/ctor] is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input [ndarray][@stdlib/ndarray/ctor] is sorted in **increasing** order. If `sortOrder == 0.0`, the input [ndarray][@stdlib/ndarray/ctor] is left unchanged. +- The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`. +- The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first. +- The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`. +- The algorithm is **unstable**, meaning that the algorithm may change the order of [ndarray][@stdlib/ndarray/ctor] elements which are equal or equivalent (e.g., `NaN` values). +- The function iterates over [ndarray][@stdlib/ndarray/ctor] elements according to the memory layout of the input [ndarray][@stdlib/ndarray/ctor]. Accordingly, performance degradation is possible when operating over multiple dimensions of a large non-contiguous multi-dimensional input [ndarray][@stdlib/ndarray/ctor]. In such scenarios, one may want to copy an input [ndarray][@stdlib/ndarray/ctor] to contiguous memory before sorting. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var toSortedhp = require( '@stdlib/blas/ext/to-sortedhp' ); + +// Generate an array of random numbers: +var xbuf = discreteUniform( 25, -20, 20, { + 'dtype': 'generic' +}); + +// Wrap in an ndarray: +var x = new ndarray( 'generic', xbuf, [ 5, 5 ], [ 5, 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +// Perform operation: +var out = toSortedhp( x, { + 'dims': [ 0 ] +}); + +// Print the results: +console.log( ndarray2array( out ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/benchmark/benchmark.assign.js new file mode 100644 index 000000000000..82053922c517 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/benchmark/benchmark.assign.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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var pkg = require( './../package.json' ).name; +var assign = require( './../lib/assign.js' ); + + +// 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; + var y; + + x = uniform( len, -50.0, 50.0, options ); + x = new ndarray( options.dtype, x, [ len ], [ 1 ], 0, 'row-major' ); + y = zeros( [ len ], { + 'dtype': options.dtype + }); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var o; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + o = assign( x, y, ( i%2 ) ? 1 : -1 ); + if ( typeof o !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( y.get( i%len ) ) ) { + 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+':assign:dtype='+options.dtype+',len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/benchmark/benchmark.js new file mode 100644 index 000000000000..cf5d13649599 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/benchmark/benchmark.js @@ -0,0 +1,105 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var pkg = require( './../package.json' ).name; +var toSortedhp = 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 = uniform( len, -50.0, 50.0, options ); + x = new ndarray( options.dtype, x, [ len ], [ 1 ], 0, 'row-major' ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var o; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + o = toSortedhp( x, ( i%2 ) ? 1 : -1 ); + if ( typeof o !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( o.get( i%len ) ) ) { + 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+':dtype='+options.dtype+',len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/repl.txt new file mode 100644 index 000000000000..005be213a8c4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/repl.txt @@ -0,0 +1,122 @@ + +{{alias}}( x[, sortOrder][, options] ) + Returns a new ndarray containing the elements of an input ndarray sorted + along one or more ndarray dimensions using heapsort. + + The algorithm distinguishes between `-0` and `+0`. When sorted in increasing + order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is + sorted after `+0`. + + The algorithm sorts `NaN` values to the end. When sorted in increasing + order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` + values are sorted first. + + The algorithm has space complexity O(1) and time complexity O(N log2 N). + + The algorithm is *unstable*, meaning that the algorithm may change the order + of ndarray elements which are equal or equivalent (e.g., `NaN` values). + + Parameters + ---------- + x: ndarray + Input array. Must have a real-valued or "generic" data type. + + sortOrder: ndarray|number|string (optional) + Sort order. May be either a scalar value, string, or an ndarray having a + real-valued or "generic" data type. If provided an ndarray, the value + must have a shape which is broadcast compatible with the complement of + the shape defined by `options.dims`. For example, given the input shape + `[2, 3, 4]` and `options.dims=[0]`, an ndarray sort order must have a + shape which is broadcast compatible with the shape `[3, 4]`. Similarly, + when performing the operation over all elements in a provided input + ndarray, an ndarray sort order must be a zero-dimensional ndarray. + + If specified as a string, must be one of the following values: + + - ascending: sort in increasing order. + - asc: sort in increasing order. + - descending: sort in decreasing order. + - desc: sort in decreasing order. + + By default, the sort order is `1` (i.e., increasing order). + + options: Object (optional) + Function options. + + options.dims: Array (optional) + List of dimensions over which to perform operation. If not provided, the + function performs the operation over all elements in a provided input + ndarray. + + options.dtype: string|DataType (optional) + Output array data type. + + Returns + ------- + out: ndarray + Output array. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/array}}( [ -1.0, 2.0, -3.0, -4.0 ] ); + > var out = {{alias}}( x ); + > {{alias:@stdlib/ndarray/to-array}}( out ) + [ -4.0, -3.0, -1.0, 2.0 ] + + +{{alias}}.assign( x, out[, sortOrder][, options] ) + Sorts elements of an input ndarray along one or more ndarray dimensions + using heapsort and assigns the results to an output ndarray. + + Parameters + ---------- + x: ndarray + Input array. Must have a real-valued or "generic" data type. + + out: ndarray + Output array. Must have a real-valued or "generic" data type. + + sortOrder: ndarray|number|string (optional) + Sort order. May be either a scalar value, string, or an ndarray having a + real-valued or "generic" data type. If provided an ndarray, the value + must have a shape which is broadcast compatible with the complement of + the shape defined by `options.dims`. For example, given the input shape + `[2, 3, 4]` and `options.dims=[0]`, an ndarray sort order must have a + shape which is broadcast compatible with the shape `[3, 4]`. Similarly, + when performing the operation over all elements in a provided input + ndarray, an ndarray sort order must be a zero-dimensional ndarray. + + If specified as a string, must be one of the following values: + + - ascending: sort in increasing order. + - asc: sort in increasing order. + - descending: sort in decreasing order. + - desc: sort in decreasing order. + + By default, the sort order is `1` (i.e., increasing order). + + options: Object (optional) + Function options. + + options.dims: Array (optional) + List of dimensions over which to perform operation. If not provided, the + function performs the operation over all elements in a provided input + ndarray. + + Returns + ------- + out: ndarray + Output array. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/array}}( [ -1.0, 2.0, -3.0, -4.0 ] ); + > var y = {{alias:@stdlib/ndarray/zeros}}( [ 4 ] ); + > var out = {{alias}}.assign( x, y ); + > {{alias:@stdlib/ndarray/to-array}}( out ) + [ -4.0, -3.0, -1.0, 2.0 ] + > var bool = ( out === y ) + true + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/types/index.d.ts new file mode 100644 index 000000000000..3b346cf42826 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/types/index.d.ts @@ -0,0 +1,308 @@ +/* +* @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 { ArrayLike } from '@stdlib/types/array'; +import { NumericAndGenericDataType as DataType, typedndarray, realndarray, genericndarray } from '@stdlib/types/ndarray'; + +/** +* Input array. +*/ +type InputArray = realndarray | genericndarray; + +/** +* Output array. +*/ +type OutputArray = realndarray | genericndarray; + +/** +* Sort order. +*/ +type SortOrder = typedndarray | genericndarray | number | 'descending' | 'desc' | 'ascending' | 'asc'; + +/** +* Interface defining "base" options. +*/ +interface BaseOptions { + /** + * List of dimensions over which to perform operation. + */ + dims?: ArrayLike; +} + +/** +* Interface defining options. +*/ +interface Options extends BaseOptions { + /** + * Output ndarray data type. + */ + dtype: DataType; +} + +/** +* Interface for performing an operation on an ndarray. +*/ +interface ToSortedhp { + /** + * Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort. + * + * ## Notes + * + * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged. + * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`. + * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first. + * - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`. + * - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values). + * + * @param x - input ndarray + * @param options - function options + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( [ -1.0, 2.0, -3.0 ] ); + * + * var y = toSortedhp( x ); + * // returns + * + * var arr = ndarray2array( y ); + * // returns [ -3.0, -1.0, 2.0 ] + */ + ( x: T, options?: BaseOptions ): T; + + /** + * Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort. + * + * ## Notes + * + * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged. + * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`. + * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first. + * - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`. + * - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values). + * + * @param x - input ndarray + * @param options - function options + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( [ -1.0, 2.0, -3.0 ] ); + * + * var y = toSortedhp( x ); + * // returns + * + * var arr = ndarray2array( y ); + * // returns [ -3.0, -1.0, 2.0 ] + */ + ( x: T, options?: Options ): U; // NOTE: we lose type specificity here. We can likely address this with type maps + + /** + * Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort. + * + * ## Notes + * + * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged. + * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`. + * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first. + * - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`. + * - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values). + * + * @param x - input ndarray + * @param sortOrder - sort order + * @param options - function options + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( [ -1.0, 2.0, -3.0 ] ); + * + * var y = toSortedhp( x, 1.0 ); + * // returns + * + * var arr = ndarray2array( y ); + * // returns [ -3.0, -1.0, 2.0 ] + */ + ( x: T, sortOrder: SortOrder, options?: BaseOptions ): T; + + /** + * Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort. + * + * ## Notes + * + * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged. + * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`. + * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first. + * - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`. + * - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values). + * + * @param x - input ndarray + * @param sortOrder - sort order + * @param options - function options + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( [ -1.0, 2.0, -3.0 ] ); + * + * var y = toSortedhp( x, 1.0 ); + * // returns + * + * var arr = ndarray2array( y ); + * // returns [ -3.0, -1.0, 2.0 ] + */ + ( x: T, sortOrder: SortOrder, options?: Options ): U; // NOTE: we lose type specificity here. We can likely address this with type maps + + /** + * Sorts the elements in an input ndarray along along one or more ndarray dimensions using heapsort and assigns the results to an output ndarray. + * + * ## Notes + * + * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged. + * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`. + * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first. + * - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`. + * - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values). + * + * @param x - input ndarray + * @param out - output ndarray + * @param options - function options + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var zeros = require( '@stdlib/ndarray/zeros' ); + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( [ -1.0, 2.0, -3.0 ] ); + * + * var y = zeros( [ 3 ] ); + * + * var out = toSortedhp.assign( x, y ); + * // returns + * + * var arr = ndarray2array( out ); + * // returns [ -3.0, -1.0, 2.0 ] + * + * var bool = ( out === y ); + * // returns true + */ + assign( x: T, out: U, options?: BaseOptions ): U; + + /** + * Sorts the elements in an input ndarray along along one or more ndarray dimensions using heapsort and assigns the results to an output ndarray. + * + * ## Notes + * + * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged. + * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`. + * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first. + * - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`. + * - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values). + * + * @param x - input ndarray + * @param out - output ndarray + * @param sortOrder - sort order + * @param options - function options + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var zeros = require( '@stdlib/ndarray/zeros' ); + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( [ -1.0, 2.0, -3.0 ] ); + * + * var y = zeros( [ 3 ] ); + * + * var out = toSortedhp.assign( x, y, 1); + * // returns + * + * var arr = ndarray2array( out ); + * // returns [ -3.0, -1.0, 2.0 ] + * + * var bool = ( out === y ); + * // returns true + */ + assign( x: T, out: U, sortOrder: SortOrder, options?: BaseOptions ): U; +} + +/** +* Returns a new ndarray with the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort. +* +* ## Notes +* +* - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged. +* - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`. +* - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first. +* - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`. +* - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values). +* +* @param x - input ndarray +* @param sortOrder - sort order +* @param options - function options +* @returns output ndarray +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( [ -1.0, 2.0, -3.0 ] ); +* +* var y = toSortedhp( x, 1.0 ); +* // returns +* +* var arr = ndarray2array( y ); +* // returns [ -3.0, -1.0, 2.0 ] +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( [ -1.0, 2.0, -3.0 ] ); +* +* var y = zeros( [ 3 ] ); +* +* var out = toSortedhp.assign( x, y ); +* // returns +* +* var arr = ndarray2array( out ); +* // returns [ -3.0, -1.0, 2.0 ] +* +* var bool = ( out === y ); +* // returns true +*/ +declare const toSortedhp: ToSortedhp; + + +// EXPORTS // + +export = toSortedhp; diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/types/test.ts new file mode 100644 index 000000000000..c7df2a032736 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/types/test.ts @@ -0,0 +1,363 @@ +/* +* @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 toSortedhp = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp( x ); // $ExpectType float64ndarray + toSortedhp( x, 1.0 ); // $ExpectType float64ndarray + toSortedhp( x, {} ); // $ExpectType float64ndarray + toSortedhp( x, 1.0, {} ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an ndarray... +{ + toSortedhp( '5' ); // $ExpectError + toSortedhp( 5 ); // $ExpectError + toSortedhp( true ); // $ExpectError + toSortedhp( false ); // $ExpectError + toSortedhp( null ); // $ExpectError + toSortedhp( void 0 ); // $ExpectError + toSortedhp( {} ); // $ExpectError + toSortedhp( ( x: number ): number => x ); // $ExpectError + + toSortedhp( '5', 1.0 ); // $ExpectError + toSortedhp( 5, 1.0 ); // $ExpectError + toSortedhp( true, 1.0 ); // $ExpectError + toSortedhp( false, 1.0 ); // $ExpectError + toSortedhp( null, 1.0 ); // $ExpectError + toSortedhp( void 0, 1.0 ); // $ExpectError + toSortedhp( {}, 1.0 ); // $ExpectError + toSortedhp( ( x: number ): number => x, 1.0 ); // $ExpectError + + toSortedhp( '5', {} ); // $ExpectError + toSortedhp( 5, {} ); // $ExpectError + toSortedhp( true, {} ); // $ExpectError + toSortedhp( false, {} ); // $ExpectError + toSortedhp( null, {} ); // $ExpectError + toSortedhp( void 0, {} ); // $ExpectError + toSortedhp( {}, {} ); // $ExpectError + toSortedhp( ( x: number ): number => x, {} ); // $ExpectError + + toSortedhp( '5', 1.0, {} ); // $ExpectError + toSortedhp( 5, 1.0, {} ); // $ExpectError + toSortedhp( true, 1.0, {} ); // $ExpectError + toSortedhp( false, 1.0, {} ); // $ExpectError + toSortedhp( null, 1.0, {} ); // $ExpectError + toSortedhp( void 0, 1.0, {} ); // $ExpectError + toSortedhp( {}, 1.0, {} ); // $ExpectError + toSortedhp( ( x: number ): number => x, 1.0, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sort order argument which is not an ndarray, supported string literal, or scalar value... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp( x, true ); // $ExpectError + toSortedhp( x, false ); // $ExpectError + toSortedhp( x, [] ); // $ExpectError + toSortedhp( x, ( x: number ): number => x ); // $ExpectError + + toSortedhp( x, 'foo', {} ); // $ExpectError + toSortedhp( x, true, {} ); // $ExpectError + toSortedhp( x, false, {} ); // $ExpectError + toSortedhp( x, null, {} ); // $ExpectError + toSortedhp( x, void 0, {} ); // $ExpectError + toSortedhp( x, [], {} ); // $ExpectError + toSortedhp( x, {}, {} ); // $ExpectError + toSortedhp( x, ( x: number ): number => x, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided a options argument which is not an object... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp( x, true ); // $ExpectError + toSortedhp( x, false ); // $ExpectError + toSortedhp( x, [] ); // $ExpectError + toSortedhp( x, ( x: number ): number => x ); // $ExpectError + + toSortedhp( x, 1.0, '5' ); // $ExpectError + toSortedhp( x, 1.0, true ); // $ExpectError + toSortedhp( x, 1.0, false ); // $ExpectError + toSortedhp( x, 1.0, null ); // $ExpectError + toSortedhp( x, 1.0, [] ); // $ExpectError + toSortedhp( x, 1.0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid `dtype` option... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp( x, { 'dtype': '5' } ); // $ExpectError + toSortedhp( x, { 'dtype': 5 } ); // $ExpectError + toSortedhp( x, { 'dtype': true } ); // $ExpectError + toSortedhp( x, { 'dtype': false } ); // $ExpectError + toSortedhp( x, { 'dtype': null } ); // $ExpectError + toSortedhp( x, { 'dtype': [] } ); // $ExpectError + toSortedhp( x, { 'dtype': {} } ); // $ExpectError + toSortedhp( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError + + toSortedhp( x, 1.0, { 'dtype': '5' } ); // $ExpectError + toSortedhp( x, 1.0, { 'dtype': 5 } ); // $ExpectError + toSortedhp( x, 1.0, { 'dtype': true } ); // $ExpectError + toSortedhp( x, 1.0, { 'dtype': false } ); // $ExpectError + toSortedhp( x, 1.0, { 'dtype': null } ); // $ExpectError + toSortedhp( x, 1.0, { 'dtype': [] } ); // $ExpectError + toSortedhp( x, 1.0, { 'dtype': {} } ); // $ExpectError + toSortedhp( x, 1.0, { 'dtype': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid `dims` option... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp( x, { 'dims': '5' } ); // $ExpectError + toSortedhp( x, { 'dims': 5 } ); // $ExpectError + toSortedhp( x, { 'dims': true } ); // $ExpectError + toSortedhp( x, { 'dims': false } ); // $ExpectError + toSortedhp( x, { 'dims': null } ); // $ExpectError + toSortedhp( x, { 'dims': {} } ); // $ExpectError + toSortedhp( x, { 'dims': ( x: number ): number => x } ); // $ExpectError + + toSortedhp( x, 1.0, { 'dims': '5' } ); // $ExpectError + toSortedhp( x, 1.0, { 'dims': 5 } ); // $ExpectError + toSortedhp( x, 1.0, { 'dims': true } ); // $ExpectError + toSortedhp( x, 1.0, { 'dims': false } ); // $ExpectError + toSortedhp( x, 1.0, { 'dims': null } ); // $ExpectError + toSortedhp( x, 1.0, { 'dims': {} } ); // $ExpectError + toSortedhp( x, 1.0, { 'dims': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp(); // $ExpectError + toSortedhp( x, 10.0, {}, {} ); // $ExpectError +} + +// Attached to the function is an `assign` method which returns an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + const y = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp.assign( x, y ); // $ExpectType float64ndarray + toSortedhp.assign( x, y, 1.0 ); // $ExpectType float64ndarray + toSortedhp.assign( x, y, {} ); // $ExpectType float64ndarray + toSortedhp.assign( x, y, 1.0, {} ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... +{ + const y = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp.assign( '5', y ); // $ExpectError + toSortedhp.assign( 5, y ); // $ExpectError + toSortedhp.assign( true, y ); // $ExpectError + toSortedhp.assign( false, y ); // $ExpectError + toSortedhp.assign( null, y ); // $ExpectError + toSortedhp.assign( void 0, y ); // $ExpectError + toSortedhp.assign( {}, y ); // $ExpectError + toSortedhp.assign( ( x: number ): number => x, y ); // $ExpectError + + toSortedhp.assign( '5', y, 1.0 ); // $ExpectError + toSortedhp.assign( 5, y, 1.0 ); // $ExpectError + toSortedhp.assign( true, y, 1.0 ); // $ExpectError + toSortedhp.assign( false, y, 1.0 ); // $ExpectError + toSortedhp.assign( null, y, 1.0 ); // $ExpectError + toSortedhp.assign( void 0, y, 1.0 ); // $ExpectError + toSortedhp.assign( {}, y, 1.0 ); // $ExpectError + toSortedhp.assign( ( x: number ): number => x, y, 1.0 ); // $ExpectError + + toSortedhp.assign( '5', y, {} ); // $ExpectError + toSortedhp.assign( 5, y, {} ); // $ExpectError + toSortedhp.assign( true, y, {} ); // $ExpectError + toSortedhp.assign( false, y, {} ); // $ExpectError + toSortedhp.assign( null, y, {} ); // $ExpectError + toSortedhp.assign( void 0, y, {} ); // $ExpectError + toSortedhp.assign( {}, y, {} ); // $ExpectError + toSortedhp.assign( ( x: number ): number => x, y, {} ); // $ExpectError + + toSortedhp.assign( '5', y, 1.0, {} ); // $ExpectError + toSortedhp.assign( 5, y, 1.0, {} ); // $ExpectError + toSortedhp.assign( true, y, 1.0, {} ); // $ExpectError + toSortedhp.assign( false, y, 1.0, {} ); // $ExpectError + toSortedhp.assign( null, y, 1.0, {} ); // $ExpectError + toSortedhp.assign( void 0, y, 1.0, {} ); // $ExpectError + toSortedhp.assign( {}, y, 1.0, {} ); // $ExpectError + toSortedhp.assign( ( x: number ): number => x, y, 1.0, {} ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a second argument which is not an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp.assign( x, '5' ); // $ExpectError + toSortedhp.assign( x, 5 ); // $ExpectError + toSortedhp.assign( x, true ); // $ExpectError + toSortedhp.assign( x, false ); // $ExpectError + toSortedhp.assign( x, null ); // $ExpectError + toSortedhp.assign( x, void 0 ); // $ExpectError + toSortedhp.assign( x, {} ); // $ExpectError + toSortedhp.assign( x, ( x: number ): number => x ); // $ExpectError + + toSortedhp.assign( x, '5', 1.0 ); // $ExpectError + toSortedhp.assign( x, 5, 1.0 ); // $ExpectError + toSortedhp.assign( x, true, 1.0 ); // $ExpectError + toSortedhp.assign( x, false, 1.0 ); // $ExpectError + toSortedhp.assign( x, null, 1.0 ); // $ExpectError + toSortedhp.assign( x, void 0, 1.0 ); // $ExpectError + toSortedhp.assign( x, {}, 1.0 ); // $ExpectError + toSortedhp.assign( x, ( x: number ): number => x, 1.0 ); // $ExpectError + + toSortedhp.assign( x, '5', {} ); // $ExpectError + toSortedhp.assign( x, 5, {} ); // $ExpectError + toSortedhp.assign( x, true, {} ); // $ExpectError + toSortedhp.assign( x, false, {} ); // $ExpectError + toSortedhp.assign( x, null, {} ); // $ExpectError + toSortedhp.assign( x, void 0, {} ); // $ExpectError + toSortedhp.assign( x, {}, {} ); // $ExpectError + toSortedhp.assign( x, ( x: number ): number => x, {} ); // $ExpectError + + toSortedhp.assign( x, '5', 1.0, {} ); // $ExpectError + toSortedhp.assign( x, 5, 1.0, {} ); // $ExpectError + toSortedhp.assign( x, true, 1.0, {} ); // $ExpectError + toSortedhp.assign( x, false, 1.0, {} ); // $ExpectError + toSortedhp.assign( x, null, 1.0, {} ); // $ExpectError + toSortedhp.assign( x, void 0, 1.0, {} ); // $ExpectError + toSortedhp.assign( x, {}, 1.0, {} ); // $ExpectError + toSortedhp.assign( x, ( x: number ): number => x, 1.0, {} ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a sort order argument which is not an ndarray, supported string literal, or scalar value... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + const y = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp.assign( x, y, true ); // $ExpectError + toSortedhp.assign( x, y, false ); // $ExpectError + toSortedhp.assign( x, y, [] ); // $ExpectError + toSortedhp.assign( x, y, ( x: number ): number => x ); // $ExpectError + + toSortedhp.assign( x, y, 'foo', {} ); // $ExpectError + toSortedhp.assign( x, y, true, {} ); // $ExpectError + toSortedhp.assign( x, y, false, {} ); // $ExpectError + toSortedhp.assign( x, y, null, {} ); // $ExpectError + toSortedhp.assign( x, y, void 0, {} ); // $ExpectError + toSortedhp.assign( x, y, [], {} ); // $ExpectError + toSortedhp.assign( x, y, {}, {} ); // $ExpectError + toSortedhp.assign( x, y, ( x: number ): number => x, {} ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a options argument which is not an object... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + const y = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp.assign( x, y, true ); // $ExpectError + toSortedhp.assign( x, y, false ); // $ExpectError + toSortedhp.assign( x, y, [] ); // $ExpectError + toSortedhp.assign( x, y, ( x: number ): number => x ); // $ExpectError + + toSortedhp.assign( x, y, 1.0, '5' ); // $ExpectError + toSortedhp.assign( x, y, 1.0, true ); // $ExpectError + toSortedhp.assign( x, y, 1.0, false ); // $ExpectError + toSortedhp.assign( x, y, 1.0, null ); // $ExpectError + toSortedhp.assign( x, y, 1.0, [] ); // $ExpectError + toSortedhp.assign( x, y, 1.0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an invalid `dims` option... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + const y = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp.assign( x, y, { 'dims': '5' } ); // $ExpectError + toSortedhp.assign( x, y, { 'dims': 5 } ); // $ExpectError + toSortedhp.assign( x, y, { 'dims': true } ); // $ExpectError + toSortedhp.assign( x, y, { 'dims': false } ); // $ExpectError + toSortedhp.assign( x, y, { 'dims': null } ); // $ExpectError + toSortedhp.assign( x, y, { 'dims': {} } ); // $ExpectError + toSortedhp.assign( x, y, { 'dims': ( x: number ): number => x } ); // $ExpectError + + toSortedhp.assign( x, y, 1.0, { 'dims': '5' } ); // $ExpectError + toSortedhp.assign( x, y, 1.0, { 'dims': 5 } ); // $ExpectError + toSortedhp.assign( x, y, 1.0, { 'dims': true } ); // $ExpectError + toSortedhp.assign( x, y, 1.0, { 'dims': false } ); // $ExpectError + toSortedhp.assign( x, y, 1.0, { 'dims': null } ); // $ExpectError + toSortedhp.assign( x, y, 1.0, { 'dims': {} } ); // $ExpectError + toSortedhp.assign( x, y, 1.0, { 'dims': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + const y = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + toSortedhp.assign(); // $ExpectError + toSortedhp.assign( x ); // $ExpectError + toSortedhp.assign( x, y, 10.0, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/examples/index.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/examples/index.js new file mode 100644 index 000000000000..f43a4b7e26ca --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/examples/index.js @@ -0,0 +1,41 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var toSortedhp = require( './../lib' ); + +// Generate an array of random numbers: +var xbuf = discreteUniform( 25, -20, 20, { + 'dtype': 'generic' +}); + +// Wrap in an ndarray: +var x = new ndarray( 'generic', xbuf, [ 5, 5 ], [ 5, 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +// Perform operation: +var out = toSortedhp( x, { + 'dims': [ 0 ] +}); + +// Print the results: +console.log( ndarray2array( out ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/assign.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/assign.js new file mode 100644 index 000000000000..4c95fe280200 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/assign.js @@ -0,0 +1,116 @@ +/** +* @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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var isMostlySafeCast = require( '@stdlib/ndarray/base/assert/is-mostly-safe-data-type-cast' ); +var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' ); +var copy = require( '@stdlib/ndarray/base/assign' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var sorthp = require( '@stdlib/blas/ext/sorthp' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sorts the elements of an input ndarray along one or more ndarray dimensions using heapsort and assigns the results to an output ndarray. +* +* @param {ndarrayLike} x - input ndarray +* @param {ndarrayLike} y - output ndarray +* @param {(ndarrayLike|number|string)} [sortOrder=1.0] - sort order +* @param {Options} [options] - function options +* @param {IntegerArray} [options.dims] - list of dimensions over which to perform operation +* @throws {TypeError} first argument must be an ndarray-like object +* @throws {TypeError} second argument must be an ndarray-like object +* @throws {TypeError} sort order argument must be either an ndarray-like object, a numeric value, or a supported string +* @throws {TypeError} options argument must be an object +* @throws {RangeError} dimension indices must not exceed input ndarray bounds +* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions +* @throws {TypeError} first argument cannot be safely cast to the data type of the second argument +* @throws {Error} must provide valid options +* @returns {ndarray} output ndarray +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, -3.0, 4.0, -5.0, 6.0 ] ); +* +* // Define the shape of the input array: +* var sh = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray: +* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); +* +* // Create an output ndarray; +* var y = zeros( sh ); +* +* // Perform operation: +* var out = assign( x, y ); +* // returns +* +* var arr = ndarray2array( out ); +* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ] +* +* var bool = ( y === out ); +* // returns true +*/ +function assign( x, y ) { + var nargs; + var xdt; + var ydt; + if ( !isndarrayLike( x ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + } + if ( !isndarrayLike( y ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an ndarray-like object. Value: `%s`.', y ) ); + } + xdt = getDType( x ); + ydt = getDType( y ); + if ( !isMostlySafeCast( xdt, ydt ) ) { + throw new TypeError( format( 'invalid argument. First argument cannot be safely cast to the output data type. Data types: [%s, %s].', resolveStr( xdt ), resolveStr( ydt ) ) ); + } + nargs = arguments.length; + copy( [ x, y ] ); + if ( nargs <= 2 ) { + return sorthp( y ); + } + if ( nargs === 3 ) { + return sorthp( y, arguments[ 2 ] ); + } + // nargs > 3 + return sorthp( y, arguments[ 2 ], arguments[ 3 ] ); +} + + +// EXPORTS // + +module.exports = assign; diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/index.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/index.js new file mode 100644 index 000000000000..2662601a5a6d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/index.js @@ -0,0 +1,106 @@ +/** +* @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'; + +/** +* Return a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort. +* +* @module @stdlib/blas/ext/to-sortedhp +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var toSortedhp = require( '@stdlib/blas/ext/to-sortedhp' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, -3.0, 4.0, -5.0, 6.0 ] ); +* +* // Define the shape of the input array: +* var sh = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray: +* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); +* +* // Perform operation: +* var out = toSortedhp( x ); +* // returns +* +* var arr = ndarray2array( out ); +* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var toSortedhp = require( '@stdlib/blas/ext/to-sortedhp' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, -3.0, 4.0, -5.0, 6.0 ] ); +* +* // Define the shape of the input array: +* var sh = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray: +* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); +* +* // Create an output ndarray; +* var y = zeros( sh ); +* +* // Perform operation: +* var out = toSortedhp.assign( x, y ); +* // returns +* +* var arr = ndarray2array( out ); +* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ] +* +* var bool = ( y === out ); +* // returns true +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var assign = require( './assign.js' ); + + +// MAIN // + +setReadOnly( main, 'assign', assign ); + + +// EXPORTS // + +module.exports = main; + +// exports: { "assign": "main.assign" } diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/main.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/main.js new file mode 100644 index 000000000000..2a202baa42cd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/main.js @@ -0,0 +1,150 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var isMostlySafeCast = require( '@stdlib/ndarray/base/assert/is-mostly-safe-data-type-cast' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getOrder = require( '@stdlib/ndarray/order' ); +var empty = require( '@stdlib/ndarray/empty' ); +var assign = require( '@stdlib/ndarray/base/assign' ); +var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' ); +var sorthp = require( '@stdlib/blas/ext/sorthp' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort. +* +* @param {ndarrayLike} x - input ndarray +* @param {(ndarrayLike|number|string)} [sortOrder=1.0] - sort order +* @param {Options} [options] - function options +* @param {IntegerArray} [options.dims] - list of dimensions over which to perform operation +* @param {*} [options.dtype] - output ndarray data type +* @throws {TypeError} first argument must be an ndarray-like object +* @throws {TypeError} sort order argument must be either an ndarray-like object, a numeric value, or a supported string +* @throws {TypeError} options argument must be an object +* @throws {RangeError} dimension indices must not exceed input ndarray bounds +* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions +* @throws {Error} must provide valid options +* @returns {ndarray} output ndarray +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, -3.0, 4.0, -5.0, 6.0 ] ); +* +* // Define the shape of the input array: +* var sh = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray: +* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); +* +* // Perform operation: +* var out = toSortedhp( x ); +* // returns +* +* var arr = ndarray2array( out ); +* // returns [ [ [ -5, -3 ] ], [ [ 1, 2 ] ], [ [ 4, 6 ] ] ] +*/ +function toSortedhp( x ) { + var sortOrder; + var options; + var nargs; + var xdt; + var ydt; + var y; + var o; + + if ( !isndarrayLike( x ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + } + nargs = arguments.length; + o = arguments[ 1 ]; + + // Case: toSortedhp( x ) + if ( nargs < 2 ) { + sortOrder = 1; + } + // Case: toSortedhp( x, ??? ) + else if ( nargs === 2 ) { + // Case: toSortedhp( x, sortOrder_string || sortOrder_scalar || sortOrder_ndarray ) ) + if ( isString( o ) || isNumber( o ) || isndarrayLike( o ) ) { + sortOrder = o; + } + // Case: toSortedhp( x, options ) + else { + sortOrder = 1; + options = o; + if ( !isPlainObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + } + } + // Case: toSortedhp( x, sortOrder, options ) + else if ( nargs >= 3 ) { + sortOrder = o; + options = arguments[ 2 ]; + if ( !isPlainObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + } + xdt = getDType( x ); + if ( hasOwnProp( options, 'dtype' ) ) { + ydt = options.dtype; + if ( !isMostlySafeCast( xdt, ydt ) ) { + throw new TypeError( format( 'invalid argument. First argument cannot be safely cast to the output data type. Data types: [%s, %s].', resolveStr( xdt ), resolveStr( ydt ) ) ); + } + } else { + ydt = xdt; + } + // Create an output ndarray: + y = empty( getShape( x ), { + 'dtype': ydt, + 'order': getOrder( x ) + }); + + // Copy elements from the input ndarray to the output ndarray: + assign( [ x, y ] ); + + return sorthp( y, sortOrder, options || {} ); +} + + +// EXPORTS // + +module.exports = toSortedhp; diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/package.json b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/package.json new file mode 100644 index 000000000000..18b27dc6b1cf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/blas/ext/to-sortedhp", + "version": "0.0.0", + "description": "Return a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort.", + "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", + "arrange", + "sort", + "sorted", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.assign.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.assign.js new file mode 100644 index 000000000000..3e8c5d23e391 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.assign.js @@ -0,0 +1,1974 @@ +/** +* @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 ndarray = require( '@stdlib/ndarray/ctor' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var assign = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof assign, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ) ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=scalar)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ), 1.0 ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=ndarray)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ), scalar2ndarray( 1.0 ) ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ), {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=scalar, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ), 1.0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=ndarray, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ), scalar2ndarray( 1.0 ), {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which does not have a supported data type', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ) ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which does not have a supported data type (options)', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ), {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which does not have a supported data type (sortOrder=scalar)', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ), 1.0 ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which does not have a supported data type (sortOrder=ndarray)', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ), scalar2ndarray( 1.0 ) ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which does not have a supported data type (sortOrder=scalar, options)', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ), 1.0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which does not have a supported data type (sortOrder=ndarray, options)', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, zeros( [ 2, 2 ] ), scalar2ndarray( 1.0 ), {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray-like object', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray-like object (sortOrder=scalar)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value, 1.0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray-like object (sortOrder=ndarray)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value, scalar2ndarray( 1.0 ) ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray-like object (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray-like object (sortOrder=scalar, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value, 1.0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray-like object (sortOrder=ndarray, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value, scalar2ndarray( 1.0 ), {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which does not have a supported data type', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which does not have a supported data type (options)', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which does not have a supported data type (sortOrder=scalar)', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value, 1.0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which does not have a supported data type (sortOrder=ndarray)', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value, scalar2ndarray( 1.0 ) ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which does not have a supported data type (sortOrder=scalar, options)', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value, 1.0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which does not have a supported data type (sortOrder=ndarray, options)', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value, scalar2ndarray( 1.0 ), {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument having dimensions greater than or less than the dimensions of input ndarray', function test( t ) { + var values; + var i; + + values = [ + zeros( [ 2 ] ), + zeros( [ 2, 1 ] ), + zeros( [ 3, 3 ] ), + zeros( [ 2, 2, 2 ] ), + zeros( [ 2, 2, 2, 2 ] ), + zeros( [ 2, 2, 2, 2, 2 ] ) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( zeros( [ 2, 2 ] ), value ); + }; + } +}); + +tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a support string', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + 'invalid', + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, value ); + }; + } +}); + +tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a support string (options)', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + 'invalid', + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a `sortOrder` argument which is not broadcast-compatible', function test( t ) { + var values; + var opts; + var x; + var y; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + y = zeros( [ 2, 2 ], opts ); + + values = [ + zeros( [ 4 ], opts ), + zeros( [ 2, 2, 2 ], opts ), + zeros( [ 0 ], opts ) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, value ); + }; + } +}); + +tape( 'the function throws an error if provided a `sortOrder` argument which is not broadcast-compatible (options)', function test( t ) { + var values; + var opts; + var x; + var y; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + y = zeros( [ 2, 2 ], opts ); + + values = [ + zeros( [ 4 ], opts ), + zeros( [ 2, 2, 2 ], opts ), + zeros( [ 0 ], opts ) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (sortOrder=scalar)', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, 1.0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (sortOrder=ndarray)', function test( t ) { + var values; + var opts; + var x; + var y; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + y = zeros( [ 2, 2 ], opts ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, scalar2ndarray( 1.0, opts ), value ); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers (sortOrder=scalar)', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, 1.0, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers (sortOrder=ndarray)', function test( t ) { + var values; + var opts; + var x; + var y; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + y = zeros( [ 2, 2 ], opts ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, scalar2ndarray( 1.0, opts ), { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ -10 ], + [ 0, 20 ], + [ 20 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices (sortOrder=scalar)', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ -10 ], + [ 0, 20 ], + [ 20 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, 1.0, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices (sortOrder=ndarray)', function test( t ) { + var values; + var opts; + var x; + var y; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + y = zeros( [ 2, 2 ], opts ); + + values = [ + [ -10 ], + [ 0, 20 ], + [ 20 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, scalar2ndarray( 1.0, opts ), { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains too many indices', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ 0, 1, 2 ], + [ 0, 1, 2, 3 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains too many indices (sortOrder=scalar)', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ 0, 1, 2 ], + [ 0, 1, 2, 3 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, 1.0, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains too many indices (sortOrder=ndarray)', function test( t ) { + var values; + var opts; + var x; + var y; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + y = zeros( [ 2, 2 ], opts ); + + values = [ + [ 0, 1, 2 ], + [ 0, 1, 2, 3 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, scalar2ndarray( 1.0, opts ), { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains duplicate indices', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ 0, 0 ], + [ 1, 1 ], + [ 0, 1, 0 ], + [ 1, 0, 1 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains duplicate indices (sortOrder=scalar)', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ 0, 0 ], + [ 1, 1 ], + [ 0, 1, 0 ], + [ 1, 0, 1 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, 1.0, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains duplicate indices (sortOrder=ndarray)', function test( t ) { + var values; + var opts; + var x; + var y; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + y = zeros( [ 2, 2 ], opts ); + + values = [ + [ 0, 0 ], + [ 1, 1 ], + [ 0, 1, 0 ], + [ 1, 0, 1 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, y, scalar2ndarray( 1.0, opts ), { + 'dims': value + }); + }; + } +}); + +tape( 'the function sorts the input ndarray and assigns results to an output ndarray (default, row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + actual = assign( x, y ); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function sorts the input ndarray and assigns results to an output ndarray (default, column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y ); + expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function sorts the input ndarray and assigns results to an output ndarray (all dimensions, row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + actual = assign( x, y, { + 'dims': [ 0, 1 ] + }); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function sorts the input ndarray and assigns results to an output ndarray (all dimensions, column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, { + 'dims': [ 0, 1 ] + }); + expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function sorts the input ndarray and assigns results to an output ndarray (no dimensions, row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + actual = assign( x, y, { + 'dims': [] + }); + expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function sorts the input ndarray and assigns results to an output ndarray (no dimensions, column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, { + 'dims': [] + }); + expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying operation dimensions (row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + actual = assign( x, y, { + 'dims': [ 0 ] + }); + expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = assign( x, y, { + 'dims': [ 1 ] + }); + expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying operation dimensions (column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, { + 'dims': [ 0 ] + }); + expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = assign( x, y, { + 'dims': [ 1 ] + }); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (scalar)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'row-major' + }); + + actual = assign( x, y, 1.0 ); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, -1.0 ); + expected = [ [ 4.0, -1.0 ], [ 2.0, -3.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (scalar, options)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'row-major' + }); + + actual = assign( x, y, 1.0, {} ); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, -1.0, {} ); + expected = [ [ 4.0, -1.0 ], [ 2.0, -3.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'row-major' + }); + + actual = assign( x, y, 0.0, {} ); + expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (0d ndarray)', function test( t ) { + var expected; + var actual; + var xbuf; + var opts; + var x; + var y; + + opts = { + 'dtype': 'generic' + }; + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'row-major' + }); + + actual = assign( x, y, scalar2ndarray( 1.0, opts ) ); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, scalar2ndarray( -1.0, opts ) ); + expected = [ [ 4.0, -1.0 ], [ 2.0, -3.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, scalar2ndarray( 0.0, opts ) ); + expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (0d ndarray, options)', function test( t ) { + var expected; + var actual; + var xbuf; + var opts; + var x; + var y; + + opts = { + 'dtype': 'generic' + }; + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'row-major' + }); + + actual = assign( x, y, scalar2ndarray( 1.0, opts ), {} ); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, scalar2ndarray( -1.0, opts ), {} ); + expected = [ [ 4.0, -1.0 ], [ 2.0, -3.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, scalar2ndarray( 0.0, opts ), {} ); + expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (scalar, broadcasted)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'row-major' + }); + + actual = assign( x, y, 1.0, { + 'dims': [ 0 ] + }); + expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, -1.0, { + 'dims': [ 0 ] + }); + expected = [ [ 2.0, 4.0 ], [ -1.0, -3.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, 0.0, { + 'dims': [ 0 ] + }); + expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (0d ndarray, broadcasted)', function test( t ) { + var expected; + var actual; + var xbuf; + var opts; + var x; + var y; + + opts = { + 'dtype': 'generic' + }; + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'row-major' + }); + + actual = assign( x, y, scalar2ndarray( 1.0, opts ), { + 'dims': [ 0 ] + }); + expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, scalar2ndarray( -1.0, opts ), { + 'dims': [ 0 ] + }); + expected = [ [ 2.0, 4.0 ], [ -1.0, -3.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + actual = assign( x, y, scalar2ndarray( 0.0, opts ), { + 'dims': [ 0 ] + }); + expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (string literals)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + actual = assign( x, y, 'asc' ); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = assign( x, y, 'ascending' ); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = assign( x, y, 'desc' ); + expected = [ [ 4.0, 2.0 ], [ -1.0, -3.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = assign( x, y, 'descending' ); + expected = [ [ 4.0, 2.0 ], [ -1.0, -3.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (string literals, options)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + var y; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + actual = assign( x, y, 'asc', {} ); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = assign( x, y, 'descending', { + 'dims': [ 0 ] + }); + expected = [ [ -1.0, 4.0 ], [ -3.0, 2.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (ndarray)', function test( t ) { + var sortOrder; + var expected; + var actual; + var xbuf; + var obuf; + var opts; + var x; + var y; + + opts = { + 'dtype': 'generic' + }; + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2], { + 'dtype': 'generic' + }); + + obuf = [ 1.0, -1.0 ]; + sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' ); + actual = assign( x, y, sortOrder, { + 'dims': [ 0 ] + }); + expected = [ [ -3.0, 4.0 ], [ -1.0, 2.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + y = zeros( [ 2, 2], { + 'dtype': 'generic', + 'order': 'column-major' + }); + + obuf = [ 1.0, -1.0 ]; + sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' ); + actual = assign( x, y, sortOrder, { + 'dims': [ 0 ] + }); + expected = [ [ -1.0, 4.0 ], [ 2.0, -3.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ 1.0, -2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + y = zeros( [ 2, 2], { + 'dtype': 'generic', + 'order': 'row-major' + }); + + obuf = [ 0.0, -1.0 ]; + sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' ); + actual = assign( x, y, sortOrder, { + 'dims': [ 1 ] + }); + expected = [ [ 1.0, -2.0 ], [ 4.0, -3.0 ] ]; + + t.strictEqual( actual, y, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.js new file mode 100644 index 000000000000..9246480f371a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.js @@ -0,0 +1,39 @@ +/** +* @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 isMethod = require( '@stdlib/assert/is-method' ); +var toSortedhp = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof toSortedhp, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( isMethod( toSortedhp, 'assign' ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.main.js new file mode 100644 index 000000000000..6218c9d2b171 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.main.js @@ -0,0 +1,1774 @@ +/** +* @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 isEqualDataType = require( '@stdlib/ndarray/base/assert/is-equal-data-type' ); +var isSameArray = require( '@stdlib/assert/is-same-array' ); +var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var empty = require( '@stdlib/ndarray/empty' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getOrder = require( '@stdlib/ndarray/order' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var toSortedhp = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof toSortedhp, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=scalar)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value, 1.0 ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=ndarray)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value, scalar2ndarray( 1.0 ) ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=scalar, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value, 1.0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=ndarray, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value, scalar2ndarray( 1.0 ), {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type', function test( t ) { + var values; + var i; + + values = [ + empty( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (sortOrder=scalar)', function test( t ) { + var values; + var i; + + values = [ + empty( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value, 1.0 ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (sortOrder=ndarray)', function test( t ) { + var values; + var i; + + values = [ + empty( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value, scalar2ndarray( 1.0 ) ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (options)', function test( t ) { + var values; + var i; + + values = [ + empty( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (sortOrder=scalar, options)', function test( t ) { + var values; + var i; + + values = [ + empty( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value, 1.0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (sortOrder=ndarray, options)', function test( t ) { + var values; + var i; + + values = [ + empty( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( value, scalar2ndarray( 1.0 ), {} ); + }; + } +}); + +tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a supported string', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + 'invalid', + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, value ); + }; + } +}); + +tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a supported string (options)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + 'invalid', + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a `sortOrder` argument which is not broadcast-compatible', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + zeros( [ 4 ], opts ), + zeros( [ 2, 2, 2 ], opts ), + zeros( [ 0 ], opts ) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, value ); + }; + } +}); + +tape( 'the function throws an error if provided a `sortOrder` argument which is not broadcast-compatible (options)', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + zeros( [ 4 ], opts ), + zeros( [ 2, 2, 2 ], opts ), + zeros( [ 0 ], opts ) + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (sortOrder=scalar)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, 1.0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (sortOrder=ndarray)', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, scalar2ndarray( 1.0, opts ), value ); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers (sortOrder=scalar)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, 1.0, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers (sortOrder=ndarray)', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, scalar2ndarray( 1.0, opts ), { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ -10 ], + [ 0, 20 ], + [ 20 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices (sortOrder=scalar)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ -10 ], + [ 0, 20 ], + [ 20 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, 1.0, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices (sortOrder=ndarray)', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + [ -10 ], + [ 0, 20 ], + [ 20 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, scalar2ndarray( 1.0, opts ), { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains too many indices', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ 0, 1, 2 ], + [ 0, 1, 2, 3 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains too many indices (sortOrder=scalar)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ 0, 1, 2 ], + [ 0, 1, 2, 3 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, 1.0, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains too many indices (sortOrder=ndarray)', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + [ 0, 1, 2 ], + [ 0, 1, 2, 3 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, scalar2ndarray( 1.0, opts ), { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains duplicate indices', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ 0, 0 ], + [ 1, 1 ], + [ 0, 1, 0 ], + [ 1, 0, 1 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains duplicate indices (sortOrder=scalar)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ 0, 0 ], + [ 1, 1 ], + [ 0, 1, 0 ], + [ 1, 0, 1 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, 1.0, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains duplicate indices (sortOrder=ndarray)', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + [ 0, 0 ], + [ 1, 1 ], + [ 0, 1, 0 ], + [ 1, 0, 1 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, scalar2ndarray( 1.0, opts ), { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided an invalid `dtype` option', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 'foo', + 5, + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, { + 'dtype': value + }); + }; + } +}); + +tape( 'the function throws an error if provided an invalid `dtype` option (sortOrder=scalar)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 'foo', + 5, + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, 1.0, { + 'dtype': value + }); + }; + } +}); + +tape( 'the function throws an error if provided an invalid `dtype` option (sortOrder=string)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 'foo', + 5, + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, 'asc', { + 'dtype': value + }); + }; + } +}); + +tape( 'the function throws an error if provided an invalid `dtype` option (sortOrder=ndarray)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 'foo', + 5, + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + toSortedhp( x, scalar2ndarray( 1.0 ), { + 'dtype': value + }); + }; + } +}); + +tape( 'the function returns a sorted ndarray (default, row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x ); + expected = [ -3.0, -1.0, 2.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a sorted ndarray (default, column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = toSortedhp( x ); + expected = [ -3.0, -1.0, 2.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a sorted ndarray (all dimensions, row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, { + 'dims': [ 0, 1 ] + }); + expected = [ -3.0, -1.0, 2.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a sorted ndarray (all dimensions, column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = toSortedhp( x, { + 'dims': [ 0, 1 ] + }); + expected = [ -3.0, -1.0, 2.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a sorted ndarray (no dimensions, row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, { + 'dims': [] + }); + expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a sorted ndarray (no dimensions, column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = toSortedhp( x, { + 'dims': [] + }); + expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying operation dimensions (row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, { + 'dims': [ 0 ] + }); + expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, { + 'dims': [ 1 ] + }); + expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying operation dimensions (column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = toSortedhp( x, { + 'dims': [ 0 ] + }); + expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = toSortedhp( x, { + 'dims': [ 1 ] + }); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (scalar)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 1.0 ); + expected = [ -3.0, -1.0, 2.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); + + actual = toSortedhp( x, -1.0 ); + expected = [ 4.0, 2.0, -1.0, -3.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (scalar, options)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 1.0, {} ); + expected = [ -3.0, -1.0, 2.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); + + actual = toSortedhp( x, -1.0, {} ); + expected = [ 4.0, 2.0, -1.0, -3.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 0.0, {} ); + expected = [ -1.0, 2.0, -3.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (0d ndarray)', function test( t ) { + var expected; + var actual; + var xbuf; + var opts; + var x; + + opts = { + 'dtype': 'generic' + }; + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, scalar2ndarray( 1.0, opts ) ); + expected = [-3.0, -1.0, 2.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); + + actual = toSortedhp( x, scalar2ndarray( -1.0, opts ) ); + expected = [ 4.0, 2.0, -1.0, -3.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = toSortedhp( x, scalar2ndarray( 0.0, opts ) ); + expected = [ -1.0, 2.0, -3.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (0d ndarray, options)', function test( t ) { + var expected; + var actual; + var xbuf; + var opts; + var x; + + opts = { + 'dtype': 'generic' + }; + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, scalar2ndarray( 1.0, opts ), {} ); + expected = [ -3.0, -1.0, 2.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); + + actual = toSortedhp( x, scalar2ndarray( -1.0, opts ), {} ); + expected = [ 4.0, 2.0, -1.0, -3.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = toSortedhp( x, scalar2ndarray( 0.0, opts ), {} ); + expected = [ -1.0, 2.0, -3.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (scalar, broadcasted)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 1.0, { + 'dims': [ 0 ] + }); + expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = toSortedhp( x, -1.0, { + 'dims': [ 0 ] + }); + expected = [ [ 2.0, 4.0 ], [ -1.0, -3.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = toSortedhp( x, 0.0, { + 'dims': [ 0 ] + }); + expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (0d ndarray, broadcasted)', function test( t ) { + var expected; + var actual; + var xbuf; + var opts; + var x; + + opts = { + 'dtype': 'generic' + }; + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, scalar2ndarray( 1.0, opts ), { + 'dims': [ 0 ] + }); + expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = toSortedhp( x, scalar2ndarray( -1.0, opts ), { + 'dims': [ 0 ] + }); + expected = [ [ 2.0, 4.0 ], [ -1.0, -3.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = toSortedhp( x, scalar2ndarray( 0.0, opts ), { + 'dims': [ 0 ] + }); + expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (string literals)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 'asc' ); + expected = [ -3.0, -1.0, 2.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 'ascending' ); + expected = [ -3.0, -1.0, 2.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 'desc' ); + expected = [ 4.0, 2.0, -1.0, -3.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 'descending' ); + expected = [ 4.0, 2.0, -1.0, -3.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (string literals, options)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 'asc', {} ); + expected = [ -3.0, -1.0, 2.0, 4.0 ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 'descending', { + 'dims': [ 0 ] + }); + expected = [ [ -1.0, 4.0 ], [ -3.0, 2.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a `sortOrder` argument (ndarray)', function test( t ) { + var sortOrder; + var expected; + var actual; + var xbuf; + var obuf; + var opts; + var x; + + opts = { + 'dtype': 'generic' + }; + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + obuf = [ 1.0, -1.0 ]; + sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' ); + actual = toSortedhp( x, sortOrder, { + 'dims': [ 0 ] + }); + expected = [ [ -3.0, 4.0 ], [ -1.0, 2.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + obuf = [ 1.0, -1.0 ]; + sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' ); + actual = toSortedhp( x, sortOrder, { + 'dims': [ 0 ] + }); + expected = [ [ -1.0, 4.0 ], [ 2.0, -3.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = [ 1.0, -2.0, -3.0, 4.0 ]; + x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + obuf = [ 0.0, -1.0 ]; + sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' ); + actual = toSortedhp( x, sortOrder, { + 'dims': [ 1 ] + }); + expected = [ [ 1.0, -2.0 ], [ 4.0, -3.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( getDType( actual ), opts.dtype, 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an output data type', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'float32', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, { + 'dtype': 'float64' + }); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( resolveStr( getDType( actual ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an output data type (sortOrder=scalar)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1.0, 2.0, -3.0, 4.0 ]; + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 1.0, { + 'dtype': 'float32' + }); + expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( resolveStr( getDType( actual ) ), 'float32', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an output data type (sortOrder=string)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = [ -1, 2, -3, 4 ]; + x = new ndarray( 'int8', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = toSortedhp( x, 'desc', { + 'dtype': 'int32' + }); + expected = [ [ 4, 2 ], [ -1, -3 ] ]; + + t.notEqual( actual, x, 'returns expected value' ); + t.strictEqual( resolveStr( getDType( actual ) ), 'int32', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/cceilf/package.json b/lib/node_modules/@stdlib/math/base/special/cceilf/package.json index 9727be736b09..4c3642aebc21 100644 --- a/lib/node_modules/@stdlib/math/base/special/cceilf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/cceilf/package.json @@ -66,5 +66,142 @@ "complex", "cmplx", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "ceil", + "alias": "cceilf", + "pkg_desc": "round each component of a complex number toward positive infinity", + "desc": "rounds each component of a complex number toward positive infinity", + "short_desc": "", + "parameters": [ + { + "name": "z", + "desc": "input value", + "type": { + "javascript": "Complex64", + "jsdoc": "Complex64", + "c": "stdlib_complex64_t", + "dtype": "complex64" + }, + "domain": null, + "rand": { + "prng": "random/base/uniform", + "parameters": [ + [ + -10, + 10 + ], + [ + -10, + 10 + ] + ] + }, + "example_values": [ + { + "re": -3.14, + "im": -1.5 + }, + { + "re": 0, + "im": 0 + }, + { + "re": -1.5, + "im": 2.5 + }, + { + "re": 2.5, + "im": -1.5 + }, + { + "re": 0, + "im": -3.7 + }, + { + "re": 4.2, + "im": 0 + }, + { + "re": 21.2, + "im": 3 + }, + { + "re": 11, + "im": -5 + }, + { + "re": 33, + "im": -14.67 + }, + { + "re": -42, + "im": 9.3 + }, + { + "re": -3, + "im": 3 + }, + { + "re": 73, + "im": 31 + }, + { + "re": -2.45, + "im": 1.23 + }, + { + "re": 2.45, + "im": -1.23 + }, + { + "re": 1.77, + "im": -3.14 + }, + { + "re": -7.5, + "im": 8.2 + }, + { + "re": 5.5, + "im": -12.3 + }, + { + "re": -15.8, + "im": 0.4 + }, + { + "re": 0.99, + "im": -0.99 + } + ] + } + ], + "returns": { + "desc": "result", + "type": { + "javascript": "Complex64", + "jsdoc": "Complex64", + "c": "stdlib_complex64_t", + "dtype": "complex64" + } + }, + "keywords": [ + "ceil", + "cceil", + "round", + "integer", + "nearest", + "value", + "complex", + "cmplx", + "number" + ], + "extra_keywords": [ + "math.ceil" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/factoriallnf/package.json b/lib/node_modules/@stdlib/math/base/special/factoriallnf/package.json index 77092991e9c2..150142987bcf 100644 --- a/lib/node_modules/@stdlib/math/base/special/factoriallnf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/factoriallnf/package.json @@ -64,9 +64,87 @@ "logarithm", "fact", "lfact", - "factoriallnf", + "factorialln", "combinatorics", "gamma", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "factorialln", + "alias": "factoriallnf", + "pkg_desc": "compute the natural logarithm of the factorial function", + "desc": "computes the natural logarithm of the factorial function", + "short_desc": "natural logarithm of the factorial function", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + }, + "domain": [ + { + "min": 0, + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/discrete-uniform", + "parameters": [ + 0, + 100 + ] + }, + "example_values": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 93, + 95, + 96, + 97, + 98, + 99 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "result", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + } + }, + "keywords": [ + "factorial", + "log-scale", + "logarithm", + "fact", + "lfact", + "factorialln", + "combinatorics", + "gamma" + ], + "extra_keywords": [] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/floor/package.json b/lib/node_modules/@stdlib/math/base/special/floor/package.json index daa4df3c537d..3fddea60f4bd 100644 --- a/lib/node_modules/@stdlib/math/base/special/floor/package.json +++ b/lib/node_modules/@stdlib/math/base/special/floor/package.json @@ -66,5 +66,80 @@ "double", "double-precision", "dbl" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "floor", + "alias": "floor", + "pkg_desc": "round a double-precision floating-point number toward negative infinity", + "desc": "rounds a double-precision floating-point number toward negative infinity", + "short_desc": "", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + -3.7, + 3.5, + -1.2, + -0.1, + 0.1, + 1.1, + 2.9, + 5.5, + 10.2, + 5.9, + 2.25, + -3.14, + 5, + 4.33, + 10.2, + -9.99, + 9.99, + 2.12, + -0.5, + 0.5 + ] + } + ], + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "floor", + "round", + "integer", + "nearest" + ], + "extra_keywords": [ + "math.floor" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/fresnels/test/fixtures/c/cephes/runner.c b/lib/node_modules/@stdlib/math/base/special/fresnels/test/fixtures/c/cephes/runner.c index c2c7054fffe3..1a334b642b49 100644 --- a/lib/node_modules/@stdlib/math/base/special/fresnels/test/fixtures/c/cephes/runner.c +++ b/lib/node_modules/@stdlib/math/base/special/fresnels/test/fixtures/c/cephes/runner.c @@ -117,7 +117,7 @@ void write_data_as_json( FILE *f, const double *x, const double *S, const unsign * @param len number of values in the domain * @param name output filename */ -void generate( double *x, const unsigned int len, const char *name ) { +void generate( const double *x, const unsigned int len, const char *name ) { unsigned int i; double *S; double C; diff --git a/lib/node_modules/@stdlib/math/base/special/hacoversin/package.json b/lib/node_modules/@stdlib/math/base/special/hacoversin/package.json index e07dbdfcb3d3..a62ac82619ef 100644 --- a/lib/node_modules/@stdlib/math/base/special/hacoversin/package.json +++ b/lib/node_modules/@stdlib/math/base/special/hacoversin/package.json @@ -74,5 +74,95 @@ "trigonometry", "radians", "angle" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "hacoversin", + "alias": "hacoversin", + "pkg_desc": "compute the half-value coversed sine", + "desc": "computes the half-value coversed sine", + "short_desc": "half-value coversed sine", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "half-value coversed sine", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "hacoversin", + "hacoversine", + "versed sine", + "half-value", + "coversed", + "sinus versus", + "hacoversinus", + "hcv", + "hacov", + "semicoversin", + "cohaversine", + "versed", + "sine", + "sin", + "trig", + "trigonometry", + "radians", + "angle" + ], + "extra_keywords": [ + "math.sin" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/haversin/package.json b/lib/node_modules/@stdlib/math/base/special/haversin/package.json index 94a30f5b9898..82311e39085f 100644 --- a/lib/node_modules/@stdlib/math/base/special/haversin/package.json +++ b/lib/node_modules/@stdlib/math/base/special/haversin/package.json @@ -76,5 +76,97 @@ "trigonometry", "radians", "angle" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "haversin", + "alias": "haversin", + "pkg_desc": "compute the half-value versed sine", + "desc": "computes the half-value versed sine", + "short_desc": "half-value versed sine", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "half-value versed sine", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "haversin", + "haversine", + "versed sine", + "haversed sine", + "haversed", + "hv", + "hvs", + "sem", + "havers", + "semiversinus", + "semiversin", + "semiversus", + "cosine", + "sine", + "cos", + "sin", + "trig", + "trigonometry", + "radians", + "angle" + ], + "extra_keywords": [ + "math.sin" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/round/package.json b/lib/node_modules/@stdlib/math/base/special/round/package.json index 60d9cd66b904..d315d56773bd 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/package.json +++ b/lib/node_modules/@stdlib/math/base/special/round/package.json @@ -61,5 +61,80 @@ "integer", "nearest", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "round", + "alias": "round", + "pkg_desc": "round a numeric value to the nearest integer", + "desc": "rounds a numeric value to the nearest integer", + "short_desc": "", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 64, + 27.2, + 0, + 0.1, + -9, + 8.1, + -1, + 125, + 15.7, + -16.5, + 17.9, + -188.7, + 19.11, + -200.1, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "round", + "integer", + "nearest" + ], + "extra_keywords": [ + "math.round" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/round2/package.json b/lib/node_modules/@stdlib/math/base/special/round2/package.json index ebf4f2e2c2fe..8ffea4c90d7d 100644 --- a/lib/node_modules/@stdlib/math/base/special/round2/package.json +++ b/lib/node_modules/@stdlib/math/base/special/round2/package.json @@ -63,5 +63,82 @@ "prevpow2", "nearest", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "round2", + "alias": "round2", + "pkg_desc": "round a numeric value to the nearest power of two on a linear scale", + "desc": "rounds a numeric value to the nearest power of two on a linear scale", + "short_desc": "", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "round", + "round2", + "nextpow2", + "prevpow2", + "nearest" + ], + "extra_keywords": [ + "math.round" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/secd/package.json b/lib/node_modules/@stdlib/math/base/special/secd/package.json index 95626afded3c..f100faf4dbf2 100644 --- a/lib/node_modules/@stdlib/math/base/special/secd/package.json +++ b/lib/node_modules/@stdlib/math/base/special/secd/package.json @@ -63,5 +63,81 @@ "trigonometry", "angle", "degree" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "secd", + "alias": "secd", + "pkg_desc": "compute the secant of an angle measured in degrees", + "desc": "computes the secant of an angle measured in degrees", + "short_desc": "secant", + "parameters": [ + { + "name": "x", + "desc": "input value (in degrees)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -180, + 180 + ] + }, + "example_values": [ + 0, + 30, + 45, + 60, + 90, + 120, + 135, + 150, + 180, + -30, + -45, + -60, + -90, + -120, + -135, + -150, + -180 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "secant", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "secant", + "sine", + "inverse", + "trig", + "trigonometry", + "angle", + "degree" + ], + "extra_keywords": [ + "math.sec" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/secdf/package.json b/lib/node_modules/@stdlib/math/base/special/secdf/package.json index 6fbf4c6c3a6d..1861e63d1505 100644 --- a/lib/node_modules/@stdlib/math/base/special/secdf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/secdf/package.json @@ -62,5 +62,80 @@ "trig", "trigonometry", "angle" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "secd", + "alias": "secdf", + "pkg_desc": "compute the secant of a single-precision floating-point number (in degrees)", + "desc": "computes the secant of a single-precision floating-point number (in degrees)", + "short_desc": "secant", + "parameters": [ + { + "name": "x", + "desc": "input value (in degrees)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -180, + 180 + ] + }, + "example_values": [ + 0, + 30, + 45, + 60, + 90, + 120, + 135, + 150, + 180, + -30, + -45, + -60, + -90, + -120, + -135, + -150, + -180 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "secant", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + } + }, + "keywords": [ + "secant", + "cosine", + "inverse", + "trig", + "trigonometry", + "angle" + ], + "extra_keywords": [ + "math.sec" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/secf/package.json b/lib/node_modules/@stdlib/math/base/special/secf/package.json index 5e8a39dc015d..9a766a232396 100644 --- a/lib/node_modules/@stdlib/math/base/special/secf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/secf/package.json @@ -61,10 +61,90 @@ "cosine", "sec", "secant", - "secf", "trig", "trigonometry", "radians", "angle" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "sec", + "alias": "secf", + "pkg_desc": "compute the secant of a single-precision floating-point number (in radians)", + "desc": "computes the secant of a single-precision floating-point number (in radians)", + "short_desc": "secant", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 0, + 0.5236, + 0.7854, + 1.5708, + 1.0472, + 2.3562, + 3.1416, + 4.7124, + 6.2832, + -0.5236, + -0.7854, + -1.0472, + -1.5708, + -2.3562, + -3.1416, + 7.854, + -7.854, + 0.1, + -0.1, + 3.5 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "secant", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + } + }, + "keywords": [ + "cos", + "cosine", + "sec", + "secant", + "trig", + "trigonometry", + "radians", + "angle" + ], + "extra_keywords": [ + "math.sec", + "math.cos" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/sech/package.json b/lib/node_modules/@stdlib/math/base/special/sech/package.json index e540cc57d1e5..c682c2bfee91 100644 --- a/lib/node_modules/@stdlib/math/base/special/sech/package.json +++ b/lib/node_modules/@stdlib/math/base/special/sech/package.json @@ -67,5 +67,87 @@ "trigonometry", "radians", "angle" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "sech", + "alias": "sech", + "pkg_desc": "compute the hyperbolic secant of a double-precision floating-point number", + "desc": "computes the hyperbolic secant of a double-precision floating-point number", + "short_desc": "hyperbolic secant", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 0, + 0.5236, + 0.7854, + 1.5708, + 1.0472, + 2.3562, + 3.1416, + 4.7124, + 6.2832, + -0.5236, + -0.7854, + -1.0472, + -1.5708, + -2.3562, + -3.1416, + 7.854, + -7.854, + 0.1, + -0.1, + 3.5 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "hyperbolic secant", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "sec", + "sech", + "secant", + "cos", + "cosine", + "hyperbolic", + "trig", + "trigonometry", + "radians", + "angle" + ], + "extra_keywords": [ + "math.sech" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/signum/package.json b/lib/node_modules/@stdlib/math/base/special/signum/package.json index e7de55604693..a57a50acbde4 100644 --- a/lib/node_modules/@stdlib/math/base/special/signum/package.json +++ b/lib/node_modules/@stdlib/math/base/special/signum/package.json @@ -64,5 +64,79 @@ "special function", "special", "function" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "signum", + "alias": "signum", + "pkg_desc": "evaluate the signum function for a double-precision floating-point number", + "desc": "evaluates the signum function for a double-precision floating-point number", + "short_desc": "signum", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -100, + 100 + ] + }, + "example_values": [ + -100, + 0.1, + 0.5, + -50, + -10, + 10, + 25, + -5, + -3.5, + -1, + -0.5, + -0.1, + 0, + 1, + 3.5, + 5, + 50, + 75, + 100, + -75 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "signum", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "signum", + "sign" + ], + "extra_keywords": [ + "math.sign" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/signumf/package.json b/lib/node_modules/@stdlib/math/base/special/signumf/package.json index fc5519cd62e8..b1d23bd2d5fc 100644 --- a/lib/node_modules/@stdlib/math/base/special/signumf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/signumf/package.json @@ -69,5 +69,79 @@ "single-precision", "f32", "flt" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "signum", + "alias": "signumf", + "pkg_desc": "evaluate the signum function for a single-precision floating-point number", + "desc": "evaluates the signum function for a single-precision floating-point number", + "short_desc": "signum", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -100, + 100 + ] + }, + "example_values": [ + -100, + 0.1, + 0.5, + 1, + -50, + -10, + 10, + 25, + -5, + -3.5, + -1, + -0.5, + -0.1, + 0, + 3.5, + 5, + 50, + 75, + 100, + -75 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "signum", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + } + }, + "keywords": [ + "signum", + "sign" + ], + "extra_keywords": [ + "math.sign" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/versin/package.json b/lib/node_modules/@stdlib/math/base/special/versin/package.json index 8e53f9a896f1..0d18b52ebee5 100644 --- a/lib/node_modules/@stdlib/math/base/special/versin/package.json +++ b/lib/node_modules/@stdlib/math/base/special/versin/package.json @@ -65,5 +65,86 @@ "trigonometry", "radians", "angle" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "versin", + "alias": "versin", + "pkg_desc": "compute the versed sine", + "desc": "computes the versed sine", + "short_desc": "versed sine", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "versed sine", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "versin", + "versine", + "versed sine", + "cosine", + "cos", + "trig", + "trigonometry", + "radians", + "angle" + ], + "extra_keywords": [ + "math.sin" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/special/data/unary.json b/lib/node_modules/@stdlib/math/special/data/unary.json index ae3d67a27aa8..be74f78f20ae 100644 --- a/lib/node_modules/@stdlib/math/special/data/unary.json +++ b/lib/node_modules/@stdlib/math/special/data/unary.json @@ -5034,7 +5034,141 @@ "math.ceil" ] }, - "@stdlib/math/base/special/cceilf": {}, + "@stdlib/math/base/special/cceilf": { + "$schema": "math/base@v1.0", + "base_alias": "ceil", + "alias": "cceilf", + "pkg_desc": "round each component of a complex number toward positive infinity", + "desc": "rounds each component of a complex number toward positive infinity", + "short_desc": "", + "parameters": [ + { + "name": "z", + "desc": "input value", + "type": { + "javascript": "Complex64", + "jsdoc": "Complex64", + "c": "stdlib_complex64_t", + "dtype": "complex64" + }, + "domain": null, + "rand": { + "prng": "random/base/uniform", + "parameters": [ + [ + -10, + 10 + ], + [ + -10, + 10 + ] + ] + }, + "example_values": [ + { + "re": -3.14, + "im": -1.5 + }, + { + "re": 0, + "im": 0 + }, + { + "re": -1.5, + "im": 2.5 + }, + { + "re": 2.5, + "im": -1.5 + }, + { + "re": 0, + "im": -3.7 + }, + { + "re": 4.2, + "im": 0 + }, + { + "re": 21.2, + "im": 3 + }, + { + "re": 11, + "im": -5 + }, + { + "re": 33, + "im": -14.67 + }, + { + "re": -42, + "im": 9.3 + }, + { + "re": -3, + "im": 3 + }, + { + "re": 73, + "im": 31 + }, + { + "re": -2.45, + "im": 1.23 + }, + { + "re": 2.45, + "im": -1.23 + }, + { + "re": 1.77, + "im": -3.14 + }, + { + "re": -7.5, + "im": 8.2 + }, + { + "re": 5.5, + "im": -12.3 + }, + { + "re": -15.8, + "im": 0.4 + }, + { + "re": 0.99, + "im": -0.99 + } + ] + } + ], + "returns": { + "desc": "result", + "type": { + "javascript": "Complex64", + "jsdoc": "Complex64", + "c": "stdlib_complex64_t", + "dtype": "complex64" + } + }, + "keywords": [ + "ceil", + "cceil", + "round", + "integer", + "nearest", + "value", + "complex", + "cmplx", + "number" + ], + "extra_keywords": [ + "math.ceil" + ] + }, "@stdlib/math/base/special/cceil": { "$schema": "math/base@v1.0", "base_alias": "ceil", @@ -8449,7 +8583,82 @@ ], "extra_keywords": [] }, - "@stdlib/math/base/special/factoriallnf": {}, + "@stdlib/math/base/special/factoriallnf": { + "$schema": "math/base@v1.0", + "base_alias": "factorialln", + "alias": "factoriallnf", + "pkg_desc": "compute the natural logarithm of the factorial function", + "desc": "computes the natural logarithm of the factorial function", + "short_desc": "natural logarithm of the factorial function", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + }, + "domain": [ + { + "min": 0, + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/discrete-uniform", + "parameters": [ + 0, + 100 + ] + }, + "example_values": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 93, + 95, + 96, + 97, + 98, + 99 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "result", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + } + }, + "keywords": [ + "factorial", + "log-scale", + "logarithm", + "fact", + "lfact", + "factorialln", + "combinatorics", + "gamma" + ], + "extra_keywords": [] + }, "@stdlib/math/base/special/factorialln": { "$schema": "math/base@v1.0", "base_alias": "factorialln", @@ -8599,37 +8808,22 @@ "@stdlib/math/base/special/fibonacci-indexf": {}, "@stdlib/math/base/special/fibonacci-index": {}, "@stdlib/math/base/special/floorf": {}, - "@stdlib/math/base/special/floor": {}, - "@stdlib/math/base/special/cfloorf": {}, - "@stdlib/math/base/special/cfloor": {}, - "@stdlib/math/base/special/floor10": {}, - "@stdlib/math/base/special/floor2": {}, - "@stdlib/math/base/special/fresnel": {}, - "@stdlib/math/base/special/fresnelc": {}, - "@stdlib/math/base/special/fresnels": {}, - "@stdlib/math/base/special/gamma": {}, - "@stdlib/math/base/special/gamma-lanczos-sum": {}, - "@stdlib/math/base/special/gamma-lanczos-sum-expg-scaledf": {}, - "@stdlib/math/base/special/gamma-lanczos-sum-expg-scaled": {}, - "@stdlib/math/base/special/gamma1pm1": {}, - "@stdlib/math/base/special/gammasgnf": {}, - "@stdlib/math/base/special/gammasgn": {}, - "@stdlib/math/base/special/hacovercosf": { + "@stdlib/math/base/special/floor": { "$schema": "math/base@v1.0", - "base_alias": "hacovercos", - "alias": "hacovercosf", - "pkg_desc": "compute the half-value coversed cosine", - "desc": "computes the half-value coversed cosine", - "short_desc": "half-value coversed cosine", + "base_alias": "floor", + "alias": "floor", + "pkg_desc": "round a double-precision floating-point number toward negative infinity", + "desc": "rounds a double-precision floating-point number toward negative infinity", + "short_desc": "", "parameters": [ { "name": "x", - "desc": "input value (in radians)", + "desc": "input value", "type": { "javascript": "number", "jsdoc": "number", - "c": "float", - "dtype": "float32" + "c": "double", + "dtype": "float64" }, "domain": [ { @@ -8645,26 +8839,113 @@ ] }, "example_values": [ - 64, - 27, - 0, - 0.1, - -9, - 8, - -1, - 125, - -10.2, - 11.3, - -12.4, + -3.7, 3.5, - -1.6, - 15.7, - -16, - 17.9, - -188, - 19.11, - -200, - 21.15 + -1.2, + -0.1, + 0.1, + 1.1, + 2.9, + 5.5, + 10.2, + 5.9, + 2.25, + -3.14, + 5, + 4.33, + 10.2, + -9.99, + 9.99, + 2.12, + -0.5, + 0.5 + ] + } + ], + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "floor", + "round", + "integer", + "nearest" + ], + "extra_keywords": [ + "math.floor" + ] + }, + "@stdlib/math/base/special/cfloorf": {}, + "@stdlib/math/base/special/cfloor": {}, + "@stdlib/math/base/special/floor10": {}, + "@stdlib/math/base/special/floor2": {}, + "@stdlib/math/base/special/fresnel": {}, + "@stdlib/math/base/special/fresnelc": {}, + "@stdlib/math/base/special/fresnels": {}, + "@stdlib/math/base/special/gamma": {}, + "@stdlib/math/base/special/gamma-lanczos-sum": {}, + "@stdlib/math/base/special/gamma-lanczos-sum-expg-scaledf": {}, + "@stdlib/math/base/special/gamma-lanczos-sum-expg-scaled": {}, + "@stdlib/math/base/special/gamma1pm1": {}, + "@stdlib/math/base/special/gammasgnf": {}, + "@stdlib/math/base/special/gammasgn": {}, + "@stdlib/math/base/special/hacovercosf": { + "$schema": "math/base@v1.0", + "base_alias": "hacovercos", + "alias": "hacovercosf", + "pkg_desc": "compute the half-value coversed cosine", + "desc": "computes the half-value coversed cosine", + "short_desc": "half-value coversed cosine", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 ] } ], @@ -8789,7 +9070,94 @@ ], "extra_keywords": [] }, - "@stdlib/math/base/special/hacoversin": {}, + "@stdlib/math/base/special/hacoversin": { + "$schema": "math/base@v1.0", + "base_alias": "hacoversin", + "alias": "hacoversin", + "pkg_desc": "compute the half-value coversed sine", + "desc": "computes the half-value coversed sine", + "short_desc": "half-value coversed sine", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "half-value coversed sine", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "hacoversin", + "hacoversine", + "versed sine", + "half-value", + "coversed", + "sinus versus", + "hacoversinus", + "hcv", + "hacov", + "semicoversin", + "cohaversine", + "versed", + "sine", + "sin", + "trig", + "trigonometry", + "radians", + "angle" + ], + "extra_keywords": [ + "math.sin" + ] + }, "@stdlib/math/base/special/havercosf": { "$schema": "math/base@v1.0", "base_alias": "havercos", @@ -9039,29 +9407,17 @@ ], "extra_keywords": [] }, - "@stdlib/math/base/special/haversin": {}, - "@stdlib/math/base/special/invf": {}, - "@stdlib/math/base/special/inv": {}, - "@stdlib/math/base/special/cinvf": {}, - "@stdlib/math/base/special/cinv": {}, - "@stdlib/math/base/special/lnf": {}, - "@stdlib/math/base/special/ln": {}, - "@stdlib/math/base/special/log10": {}, - "@stdlib/math/base/special/log1mexp": {}, - "@stdlib/math/base/special/log1p": {}, - "@stdlib/math/base/special/log1pexp": {}, - "@stdlib/math/base/special/log1pmx": {}, - "@stdlib/math/base/special/log2": { + "@stdlib/math/base/special/haversin": { "$schema": "math/base@v1.0", - "base_alias": "log2", - "alias": "log2", - "pkg_desc": "compute the binary logarithm", - "desc": "computes the binary logarithm", - "short_desc": "binary logarithm", + "base_alias": "haversin", + "alias": "haversin", + "pkg_desc": "compute the half-value versed sine", + "desc": "computes the half-value versed sine", + "short_desc": "half-value versed sine", "parameters": [ { "name": "x", - "desc": "input value", + "desc": "input value (in radians)", "type": { "javascript": "number", "jsdoc": "number", @@ -9070,44 +9426,697 @@ }, "domain": [ { - "min": 0, + "min": "-infinity", "max": "infinity" } ], "rand": { "prng": "random/base/uniform", "parameters": [ - 0, - 100 + -10, + 10 ] }, "example_values": [ - 0, - 0.01, - 0.25, - 0.5, - 1, - 2, - 3, - 4, - 9, - 16, - 25, - 36, - 49, 64, - 81, - 100, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "half-value versed sine", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "haversin", + "haversine", + "versed sine", + "haversed sine", + "haversed", + "hv", + "hvs", + "sem", + "havers", + "semiversinus", + "semiversin", + "semiversus", + "cosine", + "sine", + "cos", + "sin", + "trig", + "trigonometry", + "radians", + "angle" + ], + "extra_keywords": [ + "math.sin" + ] + }, + "@stdlib/math/base/special/invf": {}, + "@stdlib/math/base/special/inv": {}, + "@stdlib/math/base/special/cinvf": {}, + "@stdlib/math/base/special/cinv": {}, + "@stdlib/math/base/special/lnf": {}, + "@stdlib/math/base/special/ln": {}, + "@stdlib/math/base/special/log10": {}, + "@stdlib/math/base/special/log1mexp": {}, + "@stdlib/math/base/special/log1p": {}, + "@stdlib/math/base/special/log1pexp": {}, + "@stdlib/math/base/special/log1pmx": {}, + "@stdlib/math/base/special/log2": { + "$schema": "math/base@v1.0", + "base_alias": "log2", + "alias": "log2", + "pkg_desc": "compute the binary logarithm", + "desc": "computes the binary logarithm", + "short_desc": "binary logarithm", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": 0, + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + 0, + 100 + ] + }, + "example_values": [ + 0, + 0.01, + 0.25, + 0.5, + 1, + 2, + 3, + 4, + 9, + 16, + 25, + 36, + 49, + 64, + 81, + 100, + 0.1, + 10, + 50, + 99.99 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "binary logarithm", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "logarithm", + "log2", + "binary", + "base 2", + "log" + ], + "extra_keywords": [ + "math.log2" + ] + }, + "@stdlib/math/base/special/logitf": {}, + "@stdlib/math/base/special/logit": {}, + "@stdlib/math/base/special/lucasf": {}, + "@stdlib/math/base/special/lucas": {}, + "@stdlib/math/base/special/negafibonaccif": {}, + "@stdlib/math/base/special/negafibonacci": {}, + "@stdlib/math/base/special/negalucasf": {}, + "@stdlib/math/base/special/negalucas": {}, + "@stdlib/math/base/special/nonfibonaccif": {}, + "@stdlib/math/base/special/nonfibonacci": {}, + "@stdlib/math/base/special/rad2degf": {}, + "@stdlib/math/base/special/rad2deg": {}, + "@stdlib/math/base/special/rampf": {}, + "@stdlib/math/base/special/ramp": {}, + "@stdlib/math/base/special/rcbrtf": {}, + "@stdlib/math/base/special/rcbrt": {}, + "@stdlib/math/base/special/riemann-zeta": {}, + "@stdlib/math/base/special/roundf": {}, + "@stdlib/math/base/special/round": { + "$schema": "math/base@v1.0", + "base_alias": "round", + "alias": "round", + "pkg_desc": "round a numeric value to the nearest integer", + "desc": "rounds a numeric value to the nearest integer", + "short_desc": "", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 64, + 27.2, + 0, + 0.1, + -9, + 8.1, + -1, + 125, + 15.7, + -16.5, + 17.9, + -188.7, + 19.11, + -200.1, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "round", + "integer", + "nearest" + ], + "extra_keywords": [ + "math.round" + ] + }, + "@stdlib/math/base/special/croundf": {}, + "@stdlib/math/base/special/cround": {}, + "@stdlib/math/base/special/round-nearest-even": { + "$schema": "math/base@v1.0", + "base_alias": "roundNearestEven", + "alias": "roundNearestEven", + "pkg_desc": "round to the nearest integer with ties rounding to the nearest even integer", + "desc": "rounds to the nearest integer with ties rounding to the nearest even integer", + "short_desc": "rounds to nearest integer", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "round", + "round-nearest-even", + "round-nearest", + "integer", + "nearest", + "number" + ], + "extra_keywords": [ + "math.round" + ] + }, + "@stdlib/math/base/special/round10": {}, + "@stdlib/math/base/special/round2": { + "$schema": "math/base@v1.0", + "base_alias": "round2", + "alias": "round2", + "pkg_desc": "round a numeric value to the nearest power of two on a linear scale", + "desc": "rounds a numeric value to the nearest power of two on a linear scale", + "short_desc": "", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "round", + "round2", + "nextpow2", + "prevpow2", + "nearest" + ], + "extra_keywords": [ + "math.round" + ] + }, + "@stdlib/math/base/special/rsqrtf": {}, + "@stdlib/math/base/special/rsqrt": {}, + "@stdlib/math/base/special/secf": { + "$schema": "math/base@v1.0", + "base_alias": "sec", + "alias": "secf", + "pkg_desc": "compute the secant of a single-precision floating-point number (in radians)", + "desc": "computes the secant of a single-precision floating-point number (in radians)", + "short_desc": "secant", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 0, + 0.5236, + 0.7854, + 1.5708, + 1.0472, + 2.3562, + 3.1416, + 4.7124, + 6.2832, + -0.5236, + -0.7854, + -1.0472, + -1.5708, + -2.3562, + -3.1416, + 7.854, + -7.854, + 0.1, + -0.1, + 3.5 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "secant", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + } + }, + "keywords": [ + "cos", + "cosine", + "sec", + "secant", + "trig", + "trigonometry", + "radians", + "angle" + ], + "extra_keywords": [ + "math.sec", + "math.cos" + ] + }, + "@stdlib/math/base/special/sec": { + "$schema": "math/base@v1.0", + "base_alias": "sec", + "alias": "sec", + "pkg_desc": "compute the secant", + "desc": "computes the secant", + "short_desc": "secant", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 0, + 0.5236, + 0.7854, + 1.5708, + 1.0472, + 2.3562, + 3.1416, + 4.7124, + 6.2832, + -0.5236, + -0.7854, + -1.0472, + -1.5708, + -2.3562, + -3.1416, + 7.854, + -7.854, + 0.1, + -0.1, + 3.5 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "secant", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "sec", + "secant", + "trig", + "trigonometry", + "cos", + "cosine" + ], + "extra_keywords": [ + "math.sec", + "math.cos" + ] + }, + "@stdlib/math/base/special/secd": { + "$schema": "math/base@v1.0", + "base_alias": "secd", + "alias": "secd", + "pkg_desc": "compute the secant of an angle measured in degrees", + "desc": "computes the secant of an angle measured in degrees", + "short_desc": "secant", + "parameters": [ + { + "name": "x", + "desc": "input value (in degrees)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -180, + 180 + ] + }, + "example_values": [ + 0, + 30, + 45, + 60, + 90, + 120, + 135, + 150, + 180, + -30, + -45, + -60, + -90, + -120, + -135, + -150, + -180 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "secant", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "secant", + "sine", + "inverse", + "trig", + "trigonometry", + "angle", + "degree" + ], + "extra_keywords": [ + "math.sec" + ] + }, + "@stdlib/math/base/special/sech": { + "$schema": "math/base@v1.0", + "base_alias": "sech", + "alias": "sech", + "pkg_desc": "compute the hyperbolic secant of a double-precision floating-point number", + "desc": "computes the hyperbolic secant of a double-precision floating-point number", + "short_desc": "hyperbolic secant", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 0, + 0.5236, + 0.7854, + 1.5708, + 1.0472, + 2.3562, + 3.1416, + 4.7124, + 6.2832, + -0.5236, + -0.7854, + -1.0472, + -1.5708, + -2.3562, + -3.1416, + 7.854, + -7.854, 0.1, - 10, - 50, - 99.99 + -0.1, + 3.5 ] } ], "output_policy": "real_floating_point_and_generic", "returns": { - "desc": "binary logarithm", + "desc": "hyperbolic secant", "type": { "javascript": "number", "jsdoc": "number", @@ -9116,44 +10125,28 @@ } }, "keywords": [ - "logarithm", - "log2", - "binary", - "base 2", - "log" + "sec", + "sech", + "secant", + "cos", + "cosine", + "hyperbolic", + "trig", + "trigonometry", + "radians", + "angle" ], "extra_keywords": [ - "math.log2" + "math.sech" ] }, - "@stdlib/math/base/special/logitf": {}, - "@stdlib/math/base/special/logit": {}, - "@stdlib/math/base/special/lucasf": {}, - "@stdlib/math/base/special/lucas": {}, - "@stdlib/math/base/special/negafibonaccif": {}, - "@stdlib/math/base/special/negafibonacci": {}, - "@stdlib/math/base/special/negalucasf": {}, - "@stdlib/math/base/special/negalucas": {}, - "@stdlib/math/base/special/nonfibonaccif": {}, - "@stdlib/math/base/special/nonfibonacci": {}, - "@stdlib/math/base/special/rad2degf": {}, - "@stdlib/math/base/special/rad2deg": {}, - "@stdlib/math/base/special/rampf": {}, - "@stdlib/math/base/special/ramp": {}, - "@stdlib/math/base/special/rcbrtf": {}, - "@stdlib/math/base/special/rcbrt": {}, - "@stdlib/math/base/special/riemann-zeta": {}, - "@stdlib/math/base/special/roundf": {}, - "@stdlib/math/base/special/round": {}, - "@stdlib/math/base/special/croundf": {}, - "@stdlib/math/base/special/cround": {}, - "@stdlib/math/base/special/round-nearest-even": { + "@stdlib/math/base/special/signumf": { "$schema": "math/base@v1.0", - "base_alias": "roundNearestEven", - "alias": "roundNearestEven", - "pkg_desc": "round to the nearest integer with ties rounding to the nearest even integer", - "desc": "rounds to the nearest integer with ties rounding to the nearest even integer", - "short_desc": "rounds to nearest integer", + "base_alias": "signum", + "alias": "signumf", + "pkg_desc": "evaluate the signum function for a single-precision floating-point number", + "desc": "evaluates the signum function for a single-precision floating-point number", + "short_desc": "signum", "parameters": [ { "name": "x", @@ -9161,8 +10154,8 @@ "type": { "javascript": "number", "jsdoc": "number", - "c": "double", - "dtype": "float64" + "c": "float", + "dtype": "float32" }, "domain": [ { @@ -9173,72 +10166,63 @@ "rand": { "prng": "random/base/uniform", "parameters": [ - -10, - 10 + -100, + 100 ] }, "example_values": [ - 64, - 27, - 0, + -100, 0.1, - -9, - 8, + 0.5, + 1, + -50, + -10, + 10, + 25, + -5, + -3.5, -1, - 125, - -10.2, - 11.3, - -12.4, + -0.5, + -0.1, + 0, 3.5, - -1.6, - 15.7, - -16, - 17.9, - -188, - 19.11, - -200, - 21.15 + 5, + 50, + 75, + 100, + -75 ] } ], - "output_policy": "same", + "output_policy": "real_floating_point_and_generic", "returns": { - "desc": "function value", + "desc": "signum", "type": { "javascript": "number", "jsdoc": "number", - "c": "double", - "dtype": "float64" + "c": "float", + "dtype": "float32" } }, "keywords": [ - "round", - "round-nearest-even", - "round-nearest", - "integer", - "nearest", - "number" + "signum", + "sign" ], "extra_keywords": [ - "math.round" + "math.sign" ] }, - "@stdlib/math/base/special/round10": {}, - "@stdlib/math/base/special/round2": {}, - "@stdlib/math/base/special/rsqrtf": {}, - "@stdlib/math/base/special/rsqrt": {}, - "@stdlib/math/base/special/secf": {}, - "@stdlib/math/base/special/sec": { + "@stdlib/math/base/special/signum": { "$schema": "math/base@v1.0", - "base_alias": "sec", - "alias": "sec", - "pkg_desc": "compute the secant", - "desc": "computes the secant", - "short_desc": "secant", + "base_alias": "signum", + "alias": "signum", + "pkg_desc": "evaluate the signum function for a double-precision floating-point number", + "desc": "evaluates the signum function for a double-precision floating-point number", + "short_desc": "signum", "parameters": [ { "name": "x", - "desc": "input value (in radians)", + "desc": "input value", "type": { "javascript": "number", "jsdoc": "number", @@ -9254,37 +10238,37 @@ "rand": { "prng": "random/base/uniform", "parameters": [ - -10, - 10 + -100, + 100 ] }, "example_values": [ - 0, - 0.5236, - 0.7854, - 1.5708, - 1.0472, - 2.3562, - 3.1416, - 4.7124, - 6.2832, - -0.5236, - -0.7854, - -1.0472, - -1.5708, - -2.3562, - -3.1416, - 7.854, - -7.854, + -100, 0.1, + 0.5, + -50, + -10, + 10, + 25, + -5, + -3.5, + -1, + -0.5, -0.1, - 3.5 + 0, + 1, + 3.5, + 5, + 50, + 75, + 100, + -75 ] } ], "output_policy": "real_floating_point_and_generic", "returns": { - "desc": "secant", + "desc": "signum", "type": { "javascript": "number", "jsdoc": "number", @@ -9293,22 +10277,13 @@ } }, "keywords": [ - "sec", - "secant", - "trig", - "trigonometry", - "cos", - "cosine" + "signum", + "sign" ], "extra_keywords": [ - "math.sec", - "math.cos" + "math.sign" ] }, - "@stdlib/math/base/special/secd": {}, - "@stdlib/math/base/special/sech": {}, - "@stdlib/math/base/special/signumf": {}, - "@stdlib/math/base/special/signum": {}, "@stdlib/math/base/special/csignumf": {}, "@stdlib/math/base/special/csignum": {}, "@stdlib/math/base/special/sinf": { @@ -11727,5 +12702,83 @@ ], "extra_keywords": [] }, - "@stdlib/math/base/special/versin": {} + "@stdlib/math/base/special/versin": { + "$schema": "math/base@v1.0", + "base_alias": "versin", + "alias": "versin", + "pkg_desc": "compute the versed sine", + "desc": "computes the versed sine", + "short_desc": "versed sine", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "versed sine", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "versin", + "versine", + "versed sine", + "cosine", + "cos", + "trig", + "trigonometry", + "radians", + "angle" + ], + "extra_keywords": [ + "math.sin" + ] + } } diff --git a/lib/node_modules/@stdlib/ndarray/base/copy/README.md b/lib/node_modules/@stdlib/ndarray/base/copy/README.md index 2a3ff20ffd3c..738d28c961f7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/copy/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/copy/README.md @@ -130,11 +130,11 @@ console.log( ndarray2array( o ) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/count-falsy/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/count-falsy/lib/main.js index 325afeec0c95..5cd82577c9f9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/count-falsy/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/count-falsy/lib/main.js @@ -314,7 +314,7 @@ function countFalsy( arrays ) { xmmv = minmaxViewBufferIndex( shx, sx, x.offset ); // Determine whether we can ignore shape (and strides) and treat the ndarray as a linear one-dimensional strided array... - if ( len === ( xmmv[1]-xmmv[0]+1 ) || ( isCmplx && len*2 === ( xmmv[1]-xmmv[0]+1 ) ) ) { // eslint-disable-line max-len + if ( len === ( xmmv[1]-xmmv[0]+1 ) || ( isCmplx && len*2 === ( xmmv[1]-xmmv[0]+2 ) ) ) { // eslint-disable-line max-len // Note: the above is equivalent to @stdlib/ndarray/base/assert/is-contiguous, but in-lined so we can retain computed values... if ( iox === 1 ) { ox = xmmv[ 0 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/count-truthy/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/count-truthy/lib/main.js index fa3112c91862..e66613bfa3f4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/count-truthy/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/count-truthy/lib/main.js @@ -314,7 +314,7 @@ function countTruthy( arrays ) { xmmv = minmaxViewBufferIndex( shx, sx, x.offset ); // Determine whether we can ignore shape (and strides) and treat the ndarray as a linear one-dimensional strided array... - if ( len === ( xmmv[1]-xmmv[0]+1 ) || ( isCmplx && len*2 === ( xmmv[1]-xmmv[0]+1 ) ) ) { // eslint-disable-line max-len + if ( len === ( xmmv[1]-xmmv[0]+1 ) || ( isCmplx && len*2 === ( xmmv[1]-xmmv[0]+2 ) ) ) { // eslint-disable-line max-len // Note: the above is equivalent to @stdlib/ndarray/base/assert/is-contiguous, but in-lined so we can retain computed values... if ( iox === 1 ) { ox = xmmv[ 0 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/every/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/every/lib/main.js index 38f8df2bec71..124b05ed80bf 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/every/lib/main.js @@ -314,7 +314,7 @@ function every( arrays ) { xmmv = minmaxViewBufferIndex( shx, sx, x.offset ); // Determine whether we can ignore shape (and strides) and treat the ndarray as a linear one-dimensional strided array... - if ( len === ( xmmv[1]-xmmv[0]+1 ) || ( isCmplx && len*2 === ( xmmv[1]-xmmv[0]+1 ) ) ) { // eslint-disable-line max-len + if ( len === ( xmmv[1]-xmmv[0]+1 ) || ( isCmplx && len*2 === ( xmmv[1]-xmmv[0]+2 ) ) ) { // eslint-disable-line max-len // Note: the above is equivalent to @stdlib/ndarray/base/assert/is-contiguous, but in-lined so we can retain computed values... if ( iox === 1 ) { ox = xmmv[ 0 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/includes/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/includes/lib/main.js index 1d3b346f00e8..946f6fa45917 100644 --- a/lib/node_modules/@stdlib/ndarray/base/includes/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/includes/lib/main.js @@ -346,7 +346,7 @@ function includes( arrays ) { xmmv = minmaxViewBufferIndex( shx, sx, x.offset ); // Determine whether we can ignore shape (and strides) and treat the ndarray as a linear one-dimensional strided array... - if ( len === ( xmmv[1]-xmmv[0]+1 ) || ( isCmplx && len*2 === ( xmmv[1]-xmmv[0]+1 ) ) ) { // eslint-disable-line max-len + if ( len === ( xmmv[1]-xmmv[0]+1 ) || ( isCmplx && len*2 === ( xmmv[1]-xmmv[0]+2 ) ) ) { // eslint-disable-line max-len // Note: the above is equivalent to @stdlib/ndarray/base/assert/is-contiguous, but in-lined so we can retain computed values... if ( iox === 1 ) { ox = xmmv[ 0 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/README.md b/lib/node_modules/@stdlib/ndarray/base/some/README.md new file mode 100644 index 000000000000..6fc94a422caa --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/README.md @@ -0,0 +1,156 @@ + + +# some + +> Test whether at least `n` elements in an ndarray are truthy. + +
+ +
+ + + +
+ +## Usage + +```javascript +var some = require( '@stdlib/ndarray/base/some' ); +``` + +#### some( arrays ) + +Tests whether at least `n` elements in an ndarray are truthy. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +// Create a data buffer: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); + +// Define the shape of the input array: +var shape = [ 3, 1, 2 ]; + +// Define the array strides: +var sx = [ 4, 4, 1 ]; + +// Define the index offset: +var ox = 0; + +// Create an input ndarray-like object: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +// Define the success criterion: +var n = scalar2ndarray( 3, { + 'dtype': 'generic' +}); + +// Test elements: +var out = some( [ x, n ] ); +// returns true +``` + +The function accepts the following arguments: + +- **arrays**: array-like object containing an input ndarray and a zero-dimensional ndarray specifying the minimum number of elements in the input ndarray that must be truthy. + +Each provided ndarray should be an object with the following properties: + +- **dtype**: data type. +- **data**: data buffer. +- **shape**: dimensions. +- **strides**: stride lengths. +- **offset**: index offset. +- **order**: specifies whether an ndarray is row-major (C-style) or column major (Fortran-style). + +
+ + + +
+ +## Notes + +- For very high-dimensional ndarrays which are non-contiguous, one should consider copying the underlying data to contiguous memory before performing the operation in order to achieve better performance. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var some = require( '@stdlib/ndarray/base/some' ); + +var x = { + 'dtype': 'generic', + 'data': discreteUniform( 10, -2, 10, { + 'dtype': 'generic' + }), + 'shape': [ 5, 2 ], + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) ); + +var n = scalar2ndarray( 5, { + 'dtype': 'generic' +}); + +var out = some( [ x, n ] ); +console.log( out ); +``` + +
+ + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_blocked_columnmajor.js new file mode 100644 index 000000000000..86301d774dc3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_blocked_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/10d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/10.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 9 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_blocked_rowmajor.js new file mode 100644 index 000000000000..9516e166a94f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_blocked_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/10d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/10.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 9 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_columnmajor.js new file mode 100644 index 000000000000..bcbc34c237e3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/10d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/10.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 9 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_rowmajor.js new file mode 100644 index 000000000000..aea9ddd9e873 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.10d_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/10d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/10.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 9 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.11d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.11d_columnmajor.js new file mode 100644 index 000000000000..bb24210f1692 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.11d_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/nd.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/11.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 10 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.11d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.11d_rowmajor.js new file mode 100644 index 000000000000..a7c62e294290 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.11d_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/nd.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/11.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 10 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.1d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.1d_columnmajor.js new file mode 100644 index 000000000000..c7ebcf6b42fe --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.1d_columnmajor.js @@ -0,0 +1,128 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + var n; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + n = scalar2ndarray( len, { + 'dtype': 'generic', + 'order': order + }); + 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 = some( [ x, n ] ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.1d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.1d_rowmajor.js new file mode 100644 index 000000000000..18c1f7530d25 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.1d_rowmajor.js @@ -0,0 +1,128 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + var n; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + n = scalar2ndarray( len, { + 'dtype': 'generic', + 'order': order + }); + 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 = some( [ x, n ] ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_blocked_columnmajor.js new file mode 100644 index 000000000000..3fbf14e4d3e8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_blocked_columnmajor.js @@ -0,0 +1,134 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/2d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_blocked_rowmajor.js new file mode 100644 index 000000000000..50241de6f4d0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_blocked_rowmajor.js @@ -0,0 +1,134 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/2d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_columnmajor.js new file mode 100644 index 000000000000..ce18b2c2dc04 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_columnmajor.js @@ -0,0 +1,134 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/2d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_rowmajor.js new file mode 100644 index 000000000000..53821cfc5779 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_rowmajor.js @@ -0,0 +1,134 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/2d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_rowmajor_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_rowmajor_accessors.js new file mode 100644 index 000000000000..3bc93e9fa4d0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_rowmajor_accessors.js @@ -0,0 +1,160 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/2d_accessors.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Returns an array data buffer element. +* +* @private +* @param {Collection} buf - data buffer +* @param {NonNegativeInteger} idx - element index +* @returns {*} element +*/ +function get( buf, idx ) { + return buf[ idx ]; +} + +/** +* Sets an array data buffer element. +* +* @private +* @param {Collection} buf - data buffer +* @param {NonNegativeInteger} idx - element index +* @param {*} value - value to set +*/ +function set( buf, idx, value ) { + buf[ idx ] = value; +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order, + 'accessorProtocol': true, + 'accessors': [ get, set ] + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_rowmajor_accessors_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_rowmajor_accessors_complex.js new file mode 100644 index 000000000000..778ca1d28efa --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.2d_rowmajor_accessors_complex.js @@ -0,0 +1,162 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ctors = require( '@stdlib/array/typed-complex-ctors' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/2d_accessors.js' ); + + +// VARIABLES // + +var types = [ 'complex64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Returns an array data buffer element. +* +* @private +* @param {Collection} buf - data buffer +* @param {NonNegativeInteger} idx - element index +* @returns {*} element +*/ +function get( buf, idx ) { + return buf.get( idx ); +} + +/** +* Sets an array data buffer element. +* +* @private +* @param {Collection} buf - data buffer +* @param {NonNegativeInteger} idx - element index +* @param {*} value - value to set +*/ +function set( buf, idx, value ) { + buf.set( value, idx ); +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var xbuf; + var x; + + xbuf = discreteUniform( len*2, 1, 100 ); + x = { + 'dtype': xtype, + 'data': new ( ctors( xtype ) )( xbuf.buffer ), + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order, + 'accessorProtocol': true, + 'accessors': [ get, set ] + }; + 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 = some( x, len*2 ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 5; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_blocked_columnmajor.js new file mode 100644 index 000000000000..07d959e7a21d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_blocked_columnmajor.js @@ -0,0 +1,134 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var cbrt = require( '@stdlib/math/base/special/cbrt' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/3d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( cbrt( len ) ); + sh = [ len, len, len ]; + len *= len * len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_blocked_rowmajor.js new file mode 100644 index 000000000000..09f1fa4c3b1a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_blocked_rowmajor.js @@ -0,0 +1,134 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var cbrt = require( '@stdlib/math/base/special/cbrt' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/3d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( cbrt( len ) ); + sh = [ len, len, len ]; + len *= len * len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_columnmajor.js new file mode 100644 index 000000000000..814f863bdf31 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_columnmajor.js @@ -0,0 +1,134 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var cbrt = require( '@stdlib/math/base/special/cbrt' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/3d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( cbrt( len ) ); + sh = [ len, len, len ]; + len *= len * len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_rowmajor.js new file mode 100644 index 000000000000..12188fad529f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.3d_rowmajor.js @@ -0,0 +1,134 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var cbrt = require( '@stdlib/math/base/special/cbrt' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/3d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( cbrt( len ) ); + sh = [ len, len, len ]; + len *= len * len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_blocked_columnmajor.js new file mode 100644 index 000000000000..d78b00121684 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_blocked_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/4d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/4.0 ) ); + sh = [ len, len, len, len ]; + len *= len * len * len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_blocked_rowmajor.js new file mode 100644 index 000000000000..8923e05f5797 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_blocked_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/4d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/4.0 ) ); + sh = [ len, len, len, len ]; + len *= len * len * len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_columnmajor.js new file mode 100644 index 000000000000..249b6fb917a6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/4d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/4.0 ) ); + sh = [ len, len, len, len ]; + len *= len * len * len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_rowmajor.js new file mode 100644 index 000000000000..0ee5b4a0828a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.4d_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/4d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/4.0 ) ); + sh = [ len, len, len, len ]; + len *= len * len * len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_blocked_columnmajor.js new file mode 100644 index 000000000000..57aa6bef3805 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_blocked_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/5d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/5.0 ) ); + sh = [ len, len, len, len, len ]; + len *= pow( len, 4 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_blocked_rowmajor.js new file mode 100644 index 000000000000..e2b613cb8675 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_blocked_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/5d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/5.0 ) ); + sh = [ len, len, len, len, len ]; + len *= pow( len, 4 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_columnmajor.js new file mode 100644 index 000000000000..1a3871f3457d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/5d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/5.0 ) ); + sh = [ len, len, len, len, len ]; + len *= pow( len, 4 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_rowmajor.js new file mode 100644 index 000000000000..d051101a253f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.5d_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/5d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/5.0 ) ); + sh = [ len, len, len, len, len ]; + len *= pow( len, 4 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_blocked_columnmajor.js new file mode 100644 index 000000000000..f744e7aa4374 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_blocked_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/6d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/6.0 ) ); + sh = [ len, len, len, len, len, len ]; + len *= pow( len, 5 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_blocked_rowmajor.js new file mode 100644 index 000000000000..490ec85d6ac7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_blocked_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/6d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/6.0 ) ); + sh = [ len, len, len, len, len, len ]; + len *= pow( len, 5 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_columnmajor.js new file mode 100644 index 000000000000..8f933bf80fa5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/6d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/6.0 ) ); + sh = [ len, len, len, len, len, len ]; + len *= pow( len, 5 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_rowmajor.js new file mode 100644 index 000000000000..17b7f6c902ef --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.6d_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/6d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/6.0 ) ); + sh = [ len, len, len, len, len, len ]; + len *= pow( len, 5 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_blocked_columnmajor.js new file mode 100644 index 000000000000..053b64b28afb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_blocked_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/7d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/7.0 ) ); + sh = [ len, len, len, len, len, len, len ]; + len *= pow( len, 6 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_blocked_rowmajor.js new file mode 100644 index 000000000000..4c4b8affbe0e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_blocked_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/7d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/7.0 ) ); + sh = [ len, len, len, len, len, len, len ]; + len *= pow( len, 6 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_columnmajor.js new file mode 100644 index 000000000000..dc003ecae742 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/7d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/7.0 ) ); + sh = [ len, len, len, len, len, len, len ]; + len *= pow( len, 6 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_rowmajor.js new file mode 100644 index 000000000000..8053b2d5d47e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.7d_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/7d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/7.0 ) ); + sh = [ len, len, len, len, len, len, len ]; + len *= pow( len, 6 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_blocked_columnmajor.js new file mode 100644 index 000000000000..23c815487e5b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_blocked_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/8d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/8.0 ) ); + sh = [ len, len, len, len, len, len, len, len ]; + len *= pow( len, 7 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_blocked_rowmajor.js new file mode 100644 index 000000000000..23c815487e5b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_blocked_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/8d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/8.0 ) ); + sh = [ len, len, len, len, len, len, len, len ]; + len *= pow( len, 7 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_columnmajor.js new file mode 100644 index 000000000000..1b326a5a09ff --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/8d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/8.0 ) ); + sh = [ len, len, len, len, len, len, len, len ]; + len *= pow( len, 7 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_rowmajor.js new file mode 100644 index 000000000000..82040b982744 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.8d_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/8d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/8.0 ) ); + sh = [ len, len, len, len, len, len, len, len ]; + len *= pow( len, 7 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_blocked_columnmajor.js new file mode 100644 index 000000000000..389591dfce29 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_blocked_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/9d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/9.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 8 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_blocked_rowmajor.js new file mode 100644 index 000000000000..e2c68247f323 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_blocked_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/9d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/9.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 8 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::blocked:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_columnmajor.js new file mode 100644 index 000000000000..07aab1ec02c6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_columnmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/9d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/9.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 8 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_rowmajor.js new file mode 100644 index 000000000000..de02d84f7a17 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/benchmark/benchmark.9d_rowmajor.js @@ -0,0 +1,133 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var some = require( './../lib/9d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var x; + + x = discreteUniform( len, 1, 100 ); + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + 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 = some( x, len ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + 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 sh; + var t1; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2, 1, 1, 1, 1, 1, 1, 1 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 1, 1, 1, 1, 1, 1, 1, 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( pow( len, 1.0/9.0 ) ); + sh = [ len, len, len, len, len, len, len, len, len ]; + len *= pow( len, 8 ); + f = createBenchmark( len, sh, t1 ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/some/docs/repl.txt new file mode 100644 index 000000000000..420ecfde1c35 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/docs/repl.txt @@ -0,0 +1,58 @@ + +{{alias}}( arrays ) + Tests whether at least `n` elements in an ndarray are truthy. + + A provided "ndarray" should be an object with the following properties: + + - dtype: data type. + - data: data buffer. + - shape: dimensions. + - strides: stride lengths. + - offset: index offset. + - order: specifies whether an ndarray is row-major (C-style) or column-major + (Fortran-style). + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing an input ndarray and a zero-dimensional + ndarray specifying the minimum number of elements in the input ndarray + that must be truthy. + + Returns + ------- + out: boolean + Boolean indicating whether at least `n` elements in an ndarray are + truthy. + + Examples + -------- + // Define ndarray data and meta data... + > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0, 0.0, 1.0 ] ); + > var dt = 'float64'; + > var sh = [ 2, 2 ]; + > var sx = [ 2, 1 ]; + > var ox = 0; + > var ord = 'row-major'; + + // Using an ndarray... + > var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); + > var n = {{alias:@stdlib/ndarray/from-scalar}}( 3 ); + > {{alias}}( [ x, n ] ) + true + + // Using a minimal ndarray-like object... + > xbuf = new {{alias:@stdlib/array/float64}}( [ -1.0, 0.0, 0.0, -1.0 ] ); + > x = { + ... 'dtype': dt, + ... 'data': xbuf, + ... 'shape': sh, + ... 'strides': sx, + ... 'offset': ox, + ... 'order': ord + ... }; + > {{alias}}( [ x, n ] ) + false + + See Also + -------- diff --git a/lib/node_modules/@stdlib/ndarray/base/some/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/some/docs/types/index.d.ts new file mode 100644 index 000000000000..abe58421406e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/docs/types/index.d.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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { ndarray, typedndarray, genericndarray } from '@stdlib/types/ndarray'; + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @param arrays - array-like object containing an input ndarray and a zero-dimensional ndarray specifying the minimum number of elements in the input ndarray that must be truthy +* @returns boolean indicating whether `n` elements pass a test +* +* @example +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the array: +* var shape = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create the input ndarray: +* var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); +* var n = scalar2ndarray( 3, { +* 'dtype': 'generic' +* }); +* +* // Test elements: +* var out = some( [ x, n ] ); +* // returns true +*/ +declare function some( arrays: [ ndarray, typedndarray | genericndarray ] ): boolean; + + +// EXPORTS // + +export = some; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/some/docs/types/test.ts new file mode 100644 index 000000000000..c3141321c31b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/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. +*/ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +import some = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + const x = zeros( [ 2, 2 ] ); + const n = scalar2ndarray( 2, { 'dtype': 'generic' } ); + + some( [ x, n ] ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided a first argument which is not an array-like object containing ndarray-like objects... +{ + some( 5 ); // $ExpectError + some( true ); // $ExpectError + some( false ); // $ExpectError + some( null ); // $ExpectError + some( undefined ); // $ExpectError + some( {} ); // $ExpectError + some( [ 1 ] ); // $ExpectError + some( ( x: number ): number => x ); // $ExpectError + + some( 5 ); // $ExpectError + some( true ); // $ExpectError + some( false ); // $ExpectError + some( null ); // $ExpectError + some( undefined ); // $ExpectError + some( {} ); // $ExpectError + some( [ 1 ] ); // $ExpectError + some( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ] ); + const n = scalar2ndarray( 2, { 'dtype': 'generic' } ); + + some(); // $ExpectError + some( [ x ] ); // $ExpectError + some( [ x, n ], {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/base/some/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/some/examples/index.js new file mode 100644 index 000000000000..43b21af65c26 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/examples/index.js @@ -0,0 +1,43 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var some = require( './../lib' ); + +var x = { + 'dtype': 'generic', + 'data': discreteUniform( 10, -2, 10, { + 'dtype': 'generic' + }), + 'shape': [ 5, 2 ], + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) ); + +var n = scalar2ndarray( 5, { + 'dtype': 'generic' +}); + +var out = some( [ x, n ] ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/0d.js new file mode 100644 index 000000000000..4a3e5be83817 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/0d.js @@ -0,0 +1,76 @@ +/** +* @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'; + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0 ] ); +* +* // Define the shape of the input array: +* var shape = []; +* +* // Define the array strides: +* var sx = [ 0 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some0d( x, 1 ); +* // returns true +*/ +function some0d( x, n ) { + if ( n <= 1 && x.data[ x.offset ] ) { + return true; + } + return false; +} + + +// EXPORTS // + +module.exports = some0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/0d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/0d_accessors.js new file mode 100644 index 000000000000..768700f32219 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/0d_accessors.js @@ -0,0 +1,79 @@ +/** +* @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'; + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0 ] ); +* +* // Define the shape of the input array: +* var shape = []; +* +* // Define the array strides: +* var sx = [ 0 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = some0d( x, 1 ); +* // returns true +*/ +function some0d( x, n ) { + if ( n <= 1 && x.accessors[ 0 ]( x.data, x.offset ) ) { + return true; + } + return false; +} + + +// EXPORTS // + +module.exports = some0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/0d_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/0d_complex.js new file mode 100644 index 000000000000..1f2ee4879e6d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/0d_complex.js @@ -0,0 +1,76 @@ +/** +* @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'; + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0 ] ); +* +* // Define the shape of the input array: +* var shape = []; +* +* // Define the array strides: +* var sx = [ 0 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some0d( x, 1 ); +* // returns true +*/ +function some0d( x, n ) { + if ( n <= 1 && ( x.data[ x.offset ] || x.data[ x.offset+1 ] ) ) { + return true; + } + return false; +} + + +// EXPORTS // + +module.exports = some0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/10d.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d.js new file mode 100644 index 000000000000..e56266af812c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d.js @@ -0,0 +1,212 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some10d( x, 4 ); +* // returns true +*/ +function some10d( x, n ) { // eslint-disable-line max-statements + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dx9; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var S9; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var i9; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 9 ]; + S1 = sh[ 8 ]; + S2 = sh[ 7 ]; + S3 = sh[ 6 ]; + S4 = sh[ 5 ]; + S5 = sh[ 4 ]; + S6 = sh[ 3 ]; + S7 = sh[ 2 ]; + S8 = sh[ 1 ]; + S9 = sh[ 0 ]; + dx0 = sx[ 9 ]; // offset increment for innermost loop + dx1 = sx[ 8 ] - ( S0*sx[9] ); + dx2 = sx[ 7 ] - ( S1*sx[8] ); + dx3 = sx[ 6 ] - ( S2*sx[7] ); + dx4 = sx[ 5 ] - ( S3*sx[6] ); + dx5 = sx[ 4 ] - ( S4*sx[5] ); + dx6 = sx[ 3 ] - ( S5*sx[4] ); + dx7 = sx[ 2 ] - ( S6*sx[3] ); + dx8 = sx[ 1 ] - ( S7*sx[2] ); + dx9 = sx[ 0 ] - ( S8*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + S8 = sh[ 8 ]; + S9 = sh[ 9 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); + dx8 = sx[ 8 ] - ( S7*sx[7] ); + dx9 = sx[ 9 ] - ( S8*sx[8] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i9 = 0; i9 < S9; i9++ ) { + for ( i8 = 0; i8 < S8; i8++ ) { + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + ix += dx9; + } + return false; +} + + +// EXPORTS // + +module.exports = some10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_accessors.js new file mode 100644 index 000000000000..391062fba79c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_accessors.js @@ -0,0 +1,219 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = some10d( x, 4 ); +* // returns true +*/ +function some10d( x, n ) { // eslint-disable-line max-statements + var count; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dx9; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var S9; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var i9; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 9 ]; + S1 = sh[ 8 ]; + S2 = sh[ 7 ]; + S3 = sh[ 6 ]; + S4 = sh[ 5 ]; + S5 = sh[ 4 ]; + S6 = sh[ 3 ]; + S7 = sh[ 2 ]; + S8 = sh[ 1 ]; + S9 = sh[ 0 ]; + dx0 = sx[ 9 ]; // offset increment for innermost loop + dx1 = sx[ 8 ] - ( S0*sx[9] ); + dx2 = sx[ 7 ] - ( S1*sx[8] ); + dx3 = sx[ 6 ] - ( S2*sx[7] ); + dx4 = sx[ 5 ] - ( S3*sx[6] ); + dx5 = sx[ 4 ] - ( S4*sx[5] ); + dx6 = sx[ 3 ] - ( S5*sx[4] ); + dx7 = sx[ 2 ] - ( S6*sx[3] ); + dx8 = sx[ 1 ] - ( S7*sx[2] ); + dx9 = sx[ 0 ] - ( S8*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + S8 = sh[ 8 ]; + S9 = sh[ 9 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); + dx8 = sx[ 8 ] - ( S7*sx[7] ); + dx9 = sx[ 9 ] - ( S8*sx[8] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache accessor: + get = x.accessors[ 0 ]; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i9 = 0; i9 < S9; i9++ ) { + for ( i8 = 0; i8 < S8; i8++ ) { + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + ix += dx9; + } + return false; +} + + +// EXPORTS // + +module.exports = some10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_blocked.js new file mode 100644 index 000000000000..a3da5af1ecdb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_blocked.js @@ -0,0 +1,312 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome10d( x, 4 ); +* // returns true +*/ +function blockedsome10d( x, n ) { // eslint-disable-line max-statements, max-lines-per-function + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dx9; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var ox8; + var ox9; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var s8; + var s9; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var i9; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var j8; + var j9; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j9 = sh[9]; j9 > 0; ) { + if ( j9 < bsize ) { + s9 = j9; + j9 = 0; + } else { + s9 = bsize; + j9 -= bsize; + } + ox9 = ox + ( j9*sx[9] ); + for ( j8 = sh[8]; j8 > 0; ) { + if ( j8 < bsize ) { + s8 = j8; + j8 = 0; + } else { + s8 = bsize; + j8 -= bsize; + } + dx9 = sx[9] - ( s8*sx[8] ); + ox8 = ox9 + ( j8*sx[8] ); + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + dx8 = sx[8] - ( s7*sx[7] ); + ox7 = ox8 + ( j7*sx[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + ox6 = ox7 + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i9 = 0; i9 < s9; i9++ ) { + for ( i8 = 0; i8 < s8; i8++ ) { + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + ix += dx9; + } + } + } + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_blocked_accessors.js new file mode 100644 index 000000000000..f478d082e95c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_blocked_accessors.js @@ -0,0 +1,319 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedsome10d( x, 4 ); +* // returns true +*/ +function blockedsome10d( x, n ) { // eslint-disable-line max-statements, max-lines-per-function + var count; + var bsize; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dx9; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var ox8; + var ox9; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var s8; + var s9; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var i9; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var j8; + var j9; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Cache accessor: + get = x.accessors[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j9 = sh[9]; j9 > 0; ) { + if ( j9 < bsize ) { + s9 = j9; + j9 = 0; + } else { + s9 = bsize; + j9 -= bsize; + } + ox9 = ox + ( j9*sx[9] ); + for ( j8 = sh[8]; j8 > 0; ) { + if ( j8 < bsize ) { + s8 = j8; + j8 = 0; + } else { + s8 = bsize; + j8 -= bsize; + } + dx9 = sx[9] - ( s8*sx[8] ); + ox8 = ox9 + ( j8*sx[8] ); + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + dx8 = sx[8] - ( s7*sx[7] ); + ox7 = ox8 + ( j7*sx[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + ox6 = ox7 + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i9 = 0; i9 < s9; i9++ ) { + for ( i8 = 0; i8 < s8; i8++ ) { + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + ix += dx9; + } + } + } + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_blocked_complex.js new file mode 100644 index 000000000000..d01d9ed5ef58 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_blocked_complex.js @@ -0,0 +1,312 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome10d( x, 4 ); +* // returns true +*/ +function blockedsome10d( x, n ) { // eslint-disable-line max-statements, max-lines-per-function + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dx9; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var ox8; + var ox9; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var s8; + var s9; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var i9; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var j8; + var j9; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j9 = sh[9]; j9 > 0; ) { + if ( j9 < bsize ) { + s9 = j9; + j9 = 0; + } else { + s9 = bsize; + j9 -= bsize; + } + ox9 = ox + ( j9*sx[9] ); + for ( j8 = sh[8]; j8 > 0; ) { + if ( j8 < bsize ) { + s8 = j8; + j8 = 0; + } else { + s8 = bsize; + j8 -= bsize; + } + dx9 = sx[9] - ( s8*sx[8] ); + ox8 = ox9 + ( j8*sx[8] ); + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + dx8 = sx[8] - ( s7*sx[7] ); + ox7 = ox8 + ( j7*sx[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + ox6 = ox7 + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i9 = 0; i9 < s9; i9++ ) { + for ( i8 = 0; i8 < s8; i8++ ) { + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + ix += dx9; + } + } + } + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_complex.js new file mode 100644 index 000000000000..ecaa20fd7f9c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/10d_complex.js @@ -0,0 +1,212 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some10d( x, 4 ); +* // returns true +*/ +function some10d( x, n ) { // eslint-disable-line max-statements + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dx9; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var S9; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var i9; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 9 ]; + S1 = sh[ 8 ]; + S2 = sh[ 7 ]; + S3 = sh[ 6 ]; + S4 = sh[ 5 ]; + S5 = sh[ 4 ]; + S6 = sh[ 3 ]; + S7 = sh[ 2 ]; + S8 = sh[ 1 ]; + S9 = sh[ 0 ]; + dx0 = sx[ 9 ]; // offset increment for innermost loop + dx1 = sx[ 8 ] - ( S0*sx[9] ); + dx2 = sx[ 7 ] - ( S1*sx[8] ); + dx3 = sx[ 6 ] - ( S2*sx[7] ); + dx4 = sx[ 5 ] - ( S3*sx[6] ); + dx5 = sx[ 4 ] - ( S4*sx[5] ); + dx6 = sx[ 3 ] - ( S5*sx[4] ); + dx7 = sx[ 2 ] - ( S6*sx[3] ); + dx8 = sx[ 1 ] - ( S7*sx[2] ); + dx9 = sx[ 0 ] - ( S8*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + S8 = sh[ 8 ]; + S9 = sh[ 9 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); + dx8 = sx[ 8 ] - ( S7*sx[7] ); + dx9 = sx[ 9 ] - ( S8*sx[8] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i9 = 0; i9 < S9; i9++ ) { + for ( i8 = 0; i8 < S8; i8++ ) { + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + ix += dx9; + } + return false; +} + + +// EXPORTS // + +module.exports = some10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/1d.js new file mode 100644 index 000000000000..b6099eb4a549 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/1d.js @@ -0,0 +1,105 @@ +/** +* @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'; + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 4 ]; +* +* // Define the array strides: +* var sx = [ 2 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some1d( x, 4 ); +* // returns true +*/ +function some1d( x, n ) { + var count; + var xbuf; + var dx0; + var S0; + var ix; + var i0; + + // Note on variable naming convention: S#, dx#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables: dimensions and loop offset (pointer) increments: + S0 = x.shape[ 0 ]; + dx0 = x.strides[ 0 ]; + + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i0 = 0; i0 < S0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + return false; +} + + +// EXPORTS // + +module.exports = some1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/1d_accessors.js new file mode 100644 index 000000000000..0d3e295cb919 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/1d_accessors.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'; + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 4 ]; +* +* // Define the array strides: +* var sx = [ 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = some1d( x, 4 ); +* // returns true +*/ +function some1d( x, n ) { + var count; + var xbuf; + var get; + var dx0; + var S0; + var ix; + var i0; + + // Note on variable naming convention: S#, dx#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables: dimensions and loop offset (pointer) increments... + S0 = x.shape[ 0 ]; + dx0 = x.strides[ 0 ]; + + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache accessor: + get = x.accessors[ 0 ]; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i0 = 0; i0 < S0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + return false; +} + + +// EXPORTS // + +module.exports = some1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/1d_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/1d_complex.js new file mode 100644 index 000000000000..0b691de53e15 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/1d_complex.js @@ -0,0 +1,105 @@ +/** +* @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'; + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 4 ]; +* +* // Define the array strides: +* var sx = [ 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some1d( x, 4 ); +* // returns true +*/ +function some1d( x, n ) { + var count; + var xbuf; + var dx0; + var S0; + var ix; + var i0; + + // Note on variable naming convention: S#, dx#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables: dimensions and loop offset (pointer) increments: + S0 = x.shape[ 0 ]; + dx0 = x.strides[ 0 ]; + + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + return false; +} + + +// EXPORTS // + +module.exports = some1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d.js new file mode 100644 index 000000000000..f4c12cb7c636 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d.js @@ -0,0 +1,130 @@ +/** +* @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 strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some2d( x, 4 ); +* // returns true +*/ +function some2d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var sh; + var S0; + var S1; + var sx; + var ix; + var i0; + var i1; + + // Note on variable naming convention: S#, dx#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 1 ]; + S1 = sh[ 0 ]; + dx0 = sx[ 1 ]; // offset increment for innermost loop + dx1 = sx[ 0 ] - ( S0*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + return false; +} + + +// EXPORTS // + +module.exports = some2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_accessors.js new file mode 100644 index 000000000000..21793ff88150 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_accessors.js @@ -0,0 +1,137 @@ +/** +* @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 strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = some2d( x, 4 ); +* // returns true +*/ +function some2d( x, n ) { + var count; + var xbuf; + var get; + var dx0; + var dx1; + var sh; + var S0; + var S1; + var sx; + var ix; + var i0; + var i1; + + // Note on variable naming convention: S#, dx#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 1 ]; + S1 = sh[ 0 ]; + dx0 = sx[ 1 ]; // offset increment for innermost loop + dx1 = sx[ 0 ] - ( S0*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache accessor: + get = x.accessors[ 0 ]; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + return false; +} + + +// EXPORTS // + +module.exports = some2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_blocked.js new file mode 100644 index 000000000000..04a6abd5a13b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_blocked.js @@ -0,0 +1,160 @@ +/** +* @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'; + +/* eslint-disable max-depth */ + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome2d( x, 4 ); +* // returns true +*/ +function blockedsome2d( x, n ) { + var bsize; + var count; + var xbuf; + var dx0; + var dx1; + var ox1; + var sh; + var s0; + var s1; + var sx; + var ox; + var ix; + var i0; + var i1; + var j0; + var j1; + var o; + + // Note on variable naming convention: s#, dx#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + ox1 = ox + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_blocked_accessors.js new file mode 100644 index 000000000000..29556c820f61 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_blocked_accessors.js @@ -0,0 +1,167 @@ +/** +* @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'; + +/* eslint-disable max-depth */ + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedsome2d( x, 4 ); +* // returns true +*/ +function blockedsome2d( x, n ) { + var bsize; + var count; + var xbuf; + var get; + var dx0; + var dx1; + var ox1; + var sh; + var s0; + var s1; + var sx; + var ox; + var ix; + var i0; + var i1; + var j0; + var j1; + var o; + + // Note on variable naming convention: s#, dx#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Cache accessor: + get = x.accessors[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + ox1 = ox + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_blocked_complex.js new file mode 100644 index 000000000000..f737090b7b9c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_blocked_complex.js @@ -0,0 +1,160 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome2d( x, 4 ); +* // returns true +*/ +function blockedsome2d( x, n ) { + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var ox1; + var sh; + var s0; + var s1; + var sx; + var ox; + var ix; + var i0; + var i1; + var j0; + var j1; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + ox1 = ox + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_complex.js new file mode 100644 index 000000000000..82462941fa4a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/2d_complex.js @@ -0,0 +1,130 @@ +/** +* @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 strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some2d( x, 4 ); +* // returns true +*/ +function some2d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var sh; + var S0; + var S1; + var sx; + var ix; + var i0; + var i1; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 1 ]; + S1 = sh[ 0 ]; + dx0 = sx[ 1 ]; // offset increment for innermost loop + dx1 = sx[ 0 ] - ( S0*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + return false; +} + + +// EXPORTS // + +module.exports = some2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d.js new file mode 100644 index 000000000000..06bb78f40859 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d.js @@ -0,0 +1,140 @@ +/** +* @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 strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some3d( x, 4 ); +* // returns true +*/ +function some3d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var sh; + var S0; + var S1; + var S2; + var sx; + var ix; + var i0; + var i1; + var i2; + + // Note on variable naming convention: S#, dx#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 2 ]; + S1 = sh[ 1 ]; + S2 = sh[ 0 ]; + dx0 = sx[ 2 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[2] ); + dx2 = sx[ 0 ] - ( S1*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + return false; +} + + +// EXPORTS // + +module.exports = some3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_accessors.js new file mode 100644 index 000000000000..0631420a2610 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_accessors.js @@ -0,0 +1,147 @@ +/** +* @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 strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = some3d( x, 4 ); +* // returns true +*/ +function some3d( x, n ) { + var count; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var sh; + var S0; + var S1; + var S2; + var sx; + var ix; + var i0; + var i1; + var i2; + + // Note on variable naming convention: S#, dx#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 2 ]; + S1 = sh[ 1 ]; + S2 = sh[ 0 ]; + dx0 = sx[ 2 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[2] ); + dx2 = sx[ 0 ] - ( S1*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache accessor: + get = x.accessors[ 0 ]; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + return false; +} + + +// EXPORTS // + +module.exports = some3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_blocked.js new file mode 100644 index 000000000000..919b97cb0564 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_blocked.js @@ -0,0 +1,179 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome3d( x, 4 ); +* // returns true +*/ +function blockedsome3d( x, n ) { + var bsize; + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var ox1; + var ox2; + var sh; + var s0; + var s1; + var s2; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var j0; + var j1; + var j2; + var o; + + // Note on variable naming convention: s#, dx#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + ox2 = ox + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_blocked_accessors.js new file mode 100644 index 000000000000..1195668cab4b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_blocked_accessors.js @@ -0,0 +1,186 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedsome3d( x, 4 ); +* // returns true +*/ +function blockedsome3d( x, n ) { + var bsize; + var count; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var ox1; + var ox2; + var sh; + var s0; + var s1; + var s2; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var j0; + var j1; + var j2; + var o; + + // Note on variable naming convention: s#, dx#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Cache accessor: + get = x.accessors[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + ox2 = ox + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_blocked_complex.js new file mode 100644 index 000000000000..d7c7d6b71947 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_blocked_complex.js @@ -0,0 +1,179 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray is truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome3d( x, 4 ); +* // returns true +*/ +function blockedsome3d( x, n ) { + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var dx2; + var ox1; + var ox2; + var sh; + var s0; + var s1; + var s2; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var j0; + var j1; + var j2; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + ox2 = ox + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_complex.js new file mode 100644 index 000000000000..fe1e5a23b218 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/3d_complex.js @@ -0,0 +1,140 @@ +/** +* @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 strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some3d( x, 4 ); +* // returns true +*/ +function some3d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var sh; + var S0; + var S1; + var S2; + var sx; + var ix; + var i0; + var i1; + var i2; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 2 ]; + S1 = sh[ 1 ]; + S2 = sh[ 0 ]; + dx0 = sx[ 2 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[2] ); + dx2 = sx[ 0 ] - ( S1*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + return false; +} + + +// EXPORTS // + +module.exports = some3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/4d.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d.js new file mode 100644 index 000000000000..35e5554f6779 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d.js @@ -0,0 +1,152 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some4d( x, 4 ); +* // returns true +*/ +function some4d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var sh; + var S0; + var S1; + var S2; + var S3; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 3 ]; + S1 = sh[ 2 ]; + S2 = sh[ 1 ]; + S3 = sh[ 0 ]; + dx0 = sx[ 3 ]; // offset increment for innermost loop + dx1 = sx[ 2 ] - ( S0*sx[3] ); + dx2 = sx[ 1 ] - ( S1*sx[2] ); + dx3 = sx[ 0 ] - ( S2*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + return false; +} + + +// EXPORTS // + +module.exports = some4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_accessors.js new file mode 100644 index 000000000000..8d8a772ff4e9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_accessors.js @@ -0,0 +1,159 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = some4d( x, 4 ); +* // returns true +*/ +function some4d( x, n ) { + var count; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var sh; + var S0; + var S1; + var S2; + var S3; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 3 ]; + S1 = sh[ 2 ]; + S2 = sh[ 1 ]; + S3 = sh[ 0 ]; + dx0 = sx[ 3 ]; // offset increment for innermost loop + dx1 = sx[ 2 ] - ( S0*sx[3] ); + dx2 = sx[ 1 ] - ( S1*sx[2] ); + dx3 = sx[ 0 ] - ( S2*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache accessor: + get = x.accessors[ 0 ]; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + return false; +} + + +// EXPORTS // + +module.exports = some4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_blocked.js new file mode 100644 index 000000000000..4704bb66e32c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_blocked.js @@ -0,0 +1,198 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome4d( x, 4 ); +* // returns true +*/ +function blockedsome4d( x, n ) { + var bsize; + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var ox1; + var ox2; + var ox3; + var sh; + var s0; + var s1; + var s2; + var s3; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var j0; + var j1; + var j2; + var j3; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + ox3 = ox + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_blocked_accessors.js new file mode 100644 index 000000000000..ca728c40ffad --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_blocked_accessors.js @@ -0,0 +1,205 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedsome4d( x, 4 ); +* // returns true +*/ +function blockedsome4d( x, n ) { + var bsize; + var count; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var ox1; + var ox2; + var ox3; + var sh; + var s0; + var s1; + var s2; + var s3; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var j0; + var j1; + var j2; + var j3; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Cache accessor: + get = x.accessors[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + ox3 = ox + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_blocked_complex.js new file mode 100644 index 000000000000..dec6e6ba8fab --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_blocked_complex.js @@ -0,0 +1,198 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome4d( x, 4 ); +* // returns true +*/ +function blockedsome4d( x, n ) { + var bsize; + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var ox1; + var ox2; + var ox3; + var sh; + var s0; + var s1; + var s2; + var s3; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var j0; + var j1; + var j2; + var j3; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + ox3 = ox + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_complex.js new file mode 100644 index 000000000000..4b9aca4c1560 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/4d_complex.js @@ -0,0 +1,152 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some4d( x, 4 ); +* // returns true +*/ +function some4d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var sh; + var S0; + var S1; + var S2; + var S3; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 3 ]; + S1 = sh[ 2 ]; + S2 = sh[ 1 ]; + S3 = sh[ 0 ]; + dx0 = sx[ 3 ]; // offset increment for innermost loop + dx1 = sx[ 2 ] - ( S0*sx[3] ); + dx2 = sx[ 1 ] - ( S1*sx[2] ); + dx3 = sx[ 0 ] - ( S2*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + return false; +} + + +// EXPORTS // + +module.exports = some4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/5d.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d.js new file mode 100644 index 000000000000..46c478a120d0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d.js @@ -0,0 +1,162 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some5d( x, 4 ); +* // returns true +*/ +function some5d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 4 ]; + S1 = sh[ 3 ]; + S2 = sh[ 2 ]; + S3 = sh[ 1 ]; + S4 = sh[ 0 ]; + dx0 = sx[ 4 ]; // offset increment for innermost loop + dx1 = sx[ 3 ] - ( S0*sx[4] ); + dx2 = sx[ 2 ] - ( S1*sx[3] ); + dx3 = sx[ 1 ] - ( S2*sx[2] ); + dx4 = sx[ 0 ] - ( S3*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + return false; +} + + +// EXPORTS // + +module.exports = some5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_accessors.js new file mode 100644 index 000000000000..4cc8f3642bbd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_accessors.js @@ -0,0 +1,169 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = some5d( x, 4 ); +* // returns true +*/ +function some5d( x, n ) { + var count; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 4 ]; + S1 = sh[ 3 ]; + S2 = sh[ 2 ]; + S3 = sh[ 1 ]; + S4 = sh[ 0 ]; + dx0 = sx[ 4 ]; // offset increment for innermost loop + dx1 = sx[ 3 ] - ( S0*sx[4] ); + dx2 = sx[ 2 ] - ( S1*sx[3] ); + dx3 = sx[ 1 ] - ( S2*sx[2] ); + dx4 = sx[ 0 ] - ( S3*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache accessor: + get = x.accessors[ 0 ]; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + return false; +} + + +// EXPORTS // + +module.exports = some5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_blocked.js new file mode 100644 index 000000000000..006d4478acd1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_blocked.js @@ -0,0 +1,217 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome5d( x, 4 ); +* // returns true +*/ +function blockedsome5d( x, n ) { + var bsize; + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var ox1; + var ox2; + var ox3; + var ox4; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var j0; + var j1; + var j2; + var j3; + var j4; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + ox4 = ox + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_blocked_accessors.js new file mode 100644 index 000000000000..a102f0716878 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_blocked_accessors.js @@ -0,0 +1,224 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedsome5d( x, 4 ); +* // returns true +*/ +function blockedsome5d( x, n ) { + var count; + var bsize; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var ox1; + var ox2; + var ox3; + var ox4; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var j0; + var j1; + var j2; + var j3; + var j4; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Cache accessor: + get = x.accessors[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + ox4 = ox + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_blocked_complex.js new file mode 100644 index 000000000000..ec599defbc66 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_blocked_complex.js @@ -0,0 +1,217 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome5d( x, 4 ); +* // returns true +*/ +function blockedsome5d( x, n ) { + var bsize; + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var ox1; + var ox2; + var ox3; + var ox4; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var j0; + var j1; + var j2; + var j3; + var j4; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + ox4 = ox + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_complex.js new file mode 100644 index 000000000000..96919a12e9f3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/5d_complex.js @@ -0,0 +1,162 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some5d( x, 4 ); +* // returns true +*/ +function some5d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 4 ]; + S1 = sh[ 3 ]; + S2 = sh[ 2 ]; + S3 = sh[ 1 ]; + S4 = sh[ 0 ]; + dx0 = sx[ 4 ]; // offset increment for innermost loop + dx1 = sx[ 3 ] - ( S0*sx[4] ); + dx2 = sx[ 2 ] - ( S1*sx[3] ); + dx3 = sx[ 1 ] - ( S2*sx[2] ); + dx4 = sx[ 0 ] - ( S3*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + return false; +} + + +// EXPORTS // + +module.exports = some5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/6d.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d.js new file mode 100644 index 000000000000..3186d580cb00 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d.js @@ -0,0 +1,172 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some6d( x, 4 ); +* // returns true +*/ +function some6d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 5 ]; + S1 = sh[ 4 ]; + S2 = sh[ 3 ]; + S3 = sh[ 2 ]; + S4 = sh[ 1 ]; + S5 = sh[ 0 ]; + dx0 = sx[ 5 ]; // offset increment for innermost loop + dx1 = sx[ 4 ] - ( S0*sx[5] ); + dx2 = sx[ 3 ] - ( S1*sx[4] ); + dx3 = sx[ 2 ] - ( S2*sx[3] ); + dx4 = sx[ 1 ] - ( S3*sx[2] ); + dx5 = sx[ 0 ] - ( S4*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + return false; +} + + +// EXPORTS // + +module.exports = some6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_accessors.js new file mode 100644 index 000000000000..48dcefcfbe37 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_accessors.js @@ -0,0 +1,179 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = some6d( x, 4 ); +* // returns true +*/ +function some6d( x, n ) { + var count; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 5 ]; + S1 = sh[ 4 ]; + S2 = sh[ 3 ]; + S3 = sh[ 2 ]; + S4 = sh[ 1 ]; + S5 = sh[ 0 ]; + dx0 = sx[ 5 ]; // offset increment for innermost loop + dx1 = sx[ 4 ] - ( S0*sx[5] ); + dx2 = sx[ 3 ] - ( S1*sx[4] ); + dx3 = sx[ 2 ] - ( S2*sx[3] ); + dx4 = sx[ 1 ] - ( S3*sx[2] ); + dx5 = sx[ 0 ] - ( S4*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache accessor: + get = x.accessors[ 0 ]; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + return false; +} + + +// EXPORTS // + +module.exports = some6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_blocked.js new file mode 100644 index 000000000000..d033f8f229b4 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_blocked.js @@ -0,0 +1,236 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome6d( x, 4 ); +* // returns true +*/ +function blockedsome6d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + ox5 = ox + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_blocked_accessors.js new file mode 100644 index 000000000000..347a64e219bd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_blocked_accessors.js @@ -0,0 +1,243 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedsome6d( x, 4 ); +* // returns true +*/ +function blockedsome6d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Cache accessor: + get = x.accessors[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + ox5 = ox + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_blocked_complex.js new file mode 100644 index 000000000000..16b74cc0c7e7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_blocked_complex.js @@ -0,0 +1,236 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome6d( x, 4 ); +* // returns true +*/ +function blockedsome6d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + ox5 = ox + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_complex.js new file mode 100644 index 000000000000..e75d0d166791 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/6d_complex.js @@ -0,0 +1,172 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some6d( x, 4 ); +* // returns true +*/ +function some6d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 5 ]; + S1 = sh[ 4 ]; + S2 = sh[ 3 ]; + S3 = sh[ 2 ]; + S4 = sh[ 1 ]; + S5 = sh[ 0 ]; + dx0 = sx[ 5 ]; // offset increment for innermost loop + dx1 = sx[ 4 ] - ( S0*sx[5] ); + dx2 = sx[ 3 ] - ( S1*sx[4] ); + dx3 = sx[ 2 ] - ( S2*sx[3] ); + dx4 = sx[ 1 ] - ( S3*sx[2] ); + dx5 = sx[ 0 ] - ( S4*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + return false; +} + + +// EXPORTS // + +module.exports = some6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/7d.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d.js new file mode 100644 index 000000000000..47f3f6701d6f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d.js @@ -0,0 +1,182 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some7d( x, 4 ); +* // returns true +*/ +function some7d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 6 ]; + S1 = sh[ 5 ]; + S2 = sh[ 4 ]; + S3 = sh[ 3 ]; + S4 = sh[ 2 ]; + S5 = sh[ 1 ]; + S6 = sh[ 0 ]; + dx0 = sx[ 6 ]; // offset increment for innermost loop + dx1 = sx[ 5 ] - ( S0*sx[6] ); + dx2 = sx[ 4 ] - ( S1*sx[5] ); + dx3 = sx[ 3 ] - ( S2*sx[4] ); + dx4 = sx[ 2 ] - ( S3*sx[3] ); + dx5 = sx[ 1 ] - ( S4*sx[2] ); + dx6 = sx[ 0 ] - ( S5*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + return false; +} + + +// EXPORTS // + +module.exports = some7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_accessors.js new file mode 100644 index 000000000000..93951f3b99d8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_accessors.js @@ -0,0 +1,189 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = some7d( x, 4 ); +* // returns true +*/ +function some7d( x, n ) { + var count; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 6 ]; + S1 = sh[ 5 ]; + S2 = sh[ 4 ]; + S3 = sh[ 3 ]; + S4 = sh[ 2 ]; + S5 = sh[ 1 ]; + S6 = sh[ 0 ]; + dx0 = sx[ 6 ]; // offset increment for innermost loop + dx1 = sx[ 5 ] - ( S0*sx[6] ); + dx2 = sx[ 4 ] - ( S1*sx[5] ); + dx3 = sx[ 3 ] - ( S2*sx[4] ); + dx4 = sx[ 2 ] - ( S3*sx[3] ); + dx5 = sx[ 1 ] - ( S4*sx[2] ); + dx6 = sx[ 0 ] - ( S5*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache accessor: + get = x.accessors[ 0 ]; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + return false; +} + + +// EXPORTS // + +module.exports = some7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_blocked.js new file mode 100644 index 000000000000..fbc0ab2f21ce --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_blocked.js @@ -0,0 +1,255 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome7d( x, 4 ); +* // returns true +*/ +function blockedsome7d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + ox6 = ox + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_blocked_accessors.js new file mode 100644 index 000000000000..b1185e0f500c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_blocked_accessors.js @@ -0,0 +1,262 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedsome7d( x, 4 ); +* // returns true +*/ +function blockedsome7d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Cache accessor: + get = x.accessors[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + ox6 = ox + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_blocked_complex.js new file mode 100644 index 000000000000..2a894a3a157b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_blocked_complex.js @@ -0,0 +1,255 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome7d( x, 4 ); +* // returns true +*/ +function blockedsome7d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + ox6 = ox + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_complex.js new file mode 100644 index 000000000000..63ccf404038b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/7d_complex.js @@ -0,0 +1,182 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some7d( x, 4 ); +* // returns true +*/ +function some7d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 6 ]; + S1 = sh[ 5 ]; + S2 = sh[ 4 ]; + S3 = sh[ 3 ]; + S4 = sh[ 2 ]; + S5 = sh[ 1 ]; + S6 = sh[ 0 ]; + dx0 = sx[ 6 ]; // offset increment for innermost loop + dx1 = sx[ 5 ] - ( S0*sx[6] ); + dx2 = sx[ 4 ] - ( S1*sx[5] ); + dx3 = sx[ 3 ] - ( S2*sx[4] ); + dx4 = sx[ 2 ] - ( S3*sx[3] ); + dx5 = sx[ 1 ] - ( S4*sx[2] ); + dx6 = sx[ 0 ] - ( S5*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + return false; +} + + +// EXPORTS // + +module.exports = some7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/8d.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d.js new file mode 100644 index 000000000000..1ca293af6dc7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d.js @@ -0,0 +1,192 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some8d( x, 4 ); +* // returns true +*/ +function some8d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 7 ]; + S1 = sh[ 6 ]; + S2 = sh[ 5 ]; + S3 = sh[ 4 ]; + S4 = sh[ 3 ]; + S5 = sh[ 2 ]; + S6 = sh[ 1 ]; + S7 = sh[ 0 ]; + dx0 = sx[ 7 ]; // offset increment for innermost loop + dx1 = sx[ 6 ] - ( S0*sx[7] ); + dx2 = sx[ 5 ] - ( S1*sx[6] ); + dx3 = sx[ 4 ] - ( S2*sx[5] ); + dx4 = sx[ 3 ] - ( S3*sx[4] ); + dx5 = sx[ 2 ] - ( S4*sx[3] ); + dx6 = sx[ 1 ] - ( S5*sx[2] ); + dx7 = sx[ 0 ] - ( S6*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + return false; +} + + +// EXPORTS // + +module.exports = some8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_accessors.js new file mode 100644 index 000000000000..d94f1186fedc --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_accessors.js @@ -0,0 +1,199 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = some8d( x, 4 ); +* // returns true +*/ +function some8d( x, n ) { + var count; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 7 ]; + S1 = sh[ 6 ]; + S2 = sh[ 5 ]; + S3 = sh[ 4 ]; + S4 = sh[ 3 ]; + S5 = sh[ 2 ]; + S6 = sh[ 1 ]; + S7 = sh[ 0 ]; + dx0 = sx[ 7 ]; // offset increment for innermost loop + dx1 = sx[ 6 ] - ( S0*sx[7] ); + dx2 = sx[ 5 ] - ( S1*sx[6] ); + dx3 = sx[ 4 ] - ( S2*sx[5] ); + dx4 = sx[ 3 ] - ( S3*sx[4] ); + dx5 = sx[ 2 ] - ( S4*sx[3] ); + dx6 = sx[ 1 ] - ( S5*sx[2] ); + dx7 = sx[ 0 ] - ( S6*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache accessor: + get = x.accessors[ 0 ]; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + return false; +} + + +// EXPORTS // + +module.exports = some8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_blocked.js new file mode 100644 index 000000000000..52f55b585213 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_blocked.js @@ -0,0 +1,274 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome8d( x, 4 ); +* // returns true +*/ +function blockedsome8d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + ox7 = ox + ( j7*sx[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + ox6 = ox7 + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_blocked_accessors.js new file mode 100644 index 000000000000..2ef7743e11e4 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_blocked_accessors.js @@ -0,0 +1,281 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedsome8d( x, 4 ); +* // returns true +*/ +function blockedsome8d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Cache accessor: + get = x.accessors[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + ox7 = ox + ( j7*sx[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + ox6 = ox7 + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_blocked_complex.js new file mode 100644 index 000000000000..64581ef5d056 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_blocked_complex.js @@ -0,0 +1,274 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome8d( x, 4 ); +* // returns true +*/ +function blockedsome8d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + ox7 = ox + ( j7*sx[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + ox6 = ox7 + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_complex.js new file mode 100644 index 000000000000..c6accdbf9698 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/8d_complex.js @@ -0,0 +1,192 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some8d( x, 4 ); +* // returns true +*/ +function some8d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 7 ]; + S1 = sh[ 6 ]; + S2 = sh[ 5 ]; + S3 = sh[ 4 ]; + S4 = sh[ 3 ]; + S5 = sh[ 2 ]; + S6 = sh[ 1 ]; + S7 = sh[ 0 ]; + dx0 = sx[ 7 ]; // offset increment for innermost loop + dx1 = sx[ 6 ] - ( S0*sx[7] ); + dx2 = sx[ 5 ] - ( S1*sx[6] ); + dx3 = sx[ 4 ] - ( S2*sx[5] ); + dx4 = sx[ 3 ] - ( S3*sx[4] ); + dx5 = sx[ 2 ] - ( S4*sx[3] ); + dx6 = sx[ 1 ] - ( S5*sx[2] ); + dx7 = sx[ 0 ] - ( S6*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + return false; +} + + +// EXPORTS // + +module.exports = some8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/9d.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d.js new file mode 100644 index 000000000000..8169bab7610c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d.js @@ -0,0 +1,202 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some9d( x, 4 ); +* // returns true +*/ +function some9d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 8 ]; + S1 = sh[ 7 ]; + S2 = sh[ 6 ]; + S3 = sh[ 5 ]; + S4 = sh[ 4 ]; + S5 = sh[ 3 ]; + S6 = sh[ 2 ]; + S7 = sh[ 1 ]; + S8 = sh[ 0 ]; + dx0 = sx[ 8 ]; // offset increment for innermost loop + dx1 = sx[ 7 ] - ( S0*sx[8] ); + dx2 = sx[ 6 ] - ( S1*sx[7] ); + dx3 = sx[ 5 ] - ( S2*sx[6] ); + dx4 = sx[ 4 ] - ( S3*sx[5] ); + dx5 = sx[ 3 ] - ( S4*sx[4] ); + dx6 = sx[ 2 ] - ( S5*sx[3] ); + dx7 = sx[ 1 ] - ( S6*sx[2] ); + dx8 = sx[ 0 ] - ( S7*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + S8 = sh[ 8 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); + dx8 = sx[ 8 ] - ( S7*sx[7] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i8 = 0; i8 < S8; i8++ ) { + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + return false; +} + + +// EXPORTS // + +module.exports = some9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_accessors.js new file mode 100644 index 000000000000..266bb7b03e67 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_accessors.js @@ -0,0 +1,209 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = some9d( x, 4 ); +* // returns true +*/ +function some9d( x, n ) { + var count; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 8 ]; + S1 = sh[ 7 ]; + S2 = sh[ 6 ]; + S3 = sh[ 5 ]; + S4 = sh[ 4 ]; + S5 = sh[ 3 ]; + S6 = sh[ 2 ]; + S7 = sh[ 1 ]; + S8 = sh[ 0 ]; + dx0 = sx[ 8 ]; // offset increment for innermost loop + dx1 = sx[ 7 ] - ( S0*sx[8] ); + dx2 = sx[ 6 ] - ( S1*sx[7] ); + dx3 = sx[ 5 ] - ( S2*sx[6] ); + dx4 = sx[ 4 ] - ( S3*sx[5] ); + dx5 = sx[ 3 ] - ( S4*sx[4] ); + dx6 = sx[ 2 ] - ( S5*sx[3] ); + dx7 = sx[ 1 ] - ( S6*sx[2] ); + dx8 = sx[ 0 ] - ( S7*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + S8 = sh[ 8 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); + dx8 = sx[ 8 ] - ( S7*sx[7] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache accessor: + get = x.accessors[ 0 ]; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i8 = 0; i8 < S8; i8++ ) { + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + return false; +} + + +// EXPORTS // + +module.exports = some9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_blocked.js new file mode 100644 index 000000000000..ec5b20f9a72f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_blocked.js @@ -0,0 +1,293 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 12, 12, 12, 12, 12, 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome9d( x, 4 ); +* // returns true +*/ +function blockedsome9d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var ox8; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var s8; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var j8; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j8 = sh[8]; j8 > 0; ) { + if ( j8 < bsize ) { + s8 = j8; + j8 = 0; + } else { + s8 = bsize; + j8 -= bsize; + } + ox8 = ox + ( j8*sx[8] ); + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + dx8 = sx[8] - ( s7*sx[7] ); + ox7 = ox8 + ( j7*sx[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + ox6 = ox7 + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i8 = 0; i8 < s8; i8++ ) { + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + } + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_blocked_accessors.js new file mode 100644 index 000000000000..1ce711274442 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_blocked_accessors.js @@ -0,0 +1,300 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedsome9d( x, 4 ); +* // returns true +*/ +function blockedsome9d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var get; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var ox8; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var s8; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var j8; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Cache accessor: + get = x.accessors[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j8 = sh[8]; j8 > 0; ) { + if ( j8 < bsize ) { + s8 = j8; + j8 = 0; + } else { + s8 = bsize; + j8 -= bsize; + } + ox8 = ox + ( j8*sx[8] ); + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + dx8 = sx[8] - ( s7*sx[7] ); + ox7 = ox8 + ( j7*sx[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + ox6 = ox7 + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i8 = 0; i8 < s8; i8++ ) { + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + } + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_blocked_complex.js new file mode 100644 index 000000000000..27606d0b392a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_blocked_complex.js @@ -0,0 +1,293 @@ +/** +* @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 max-depth, max-len */ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedsome9d( x, 4 ); +* // returns true +*/ +function blockedsome9d( x, n ) { // eslint-disable-line max-statements + var count; + var bsize; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var ox1; + var ox2; + var ox3; + var ox4; + var ox5; + var ox6; + var ox7; + var ox8; + var sh; + var s0; + var s1; + var s2; + var s3; + var s4; + var s5; + var s6; + var s7; + var s8; + var sx; + var ox; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + var j0; + var j1; + var j2; + var j3; + var j4; + var j5; + var j6; + var j7; + var j8; + var o; + + // Note on variable naming convention: s#, dx#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + + // Determine the block size: + bsize = blockSize( x.dtype ); + + // Set a pointer to the first indexed element: + ox = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Cache the offset increment for the innermost loop: + dx0 = sx[0]; + + // Initialize a counter: + count = 0; + + // Iterate over blocks... + for ( j8 = sh[8]; j8 > 0; ) { + if ( j8 < bsize ) { + s8 = j8; + j8 = 0; + } else { + s8 = bsize; + j8 -= bsize; + } + ox8 = ox + ( j8*sx[8] ); + for ( j7 = sh[7]; j7 > 0; ) { + if ( j7 < bsize ) { + s7 = j7; + j7 = 0; + } else { + s7 = bsize; + j7 -= bsize; + } + dx8 = sx[8] - ( s7*sx[7] ); + ox7 = ox8 + ( j7*sx[7] ); + for ( j6 = sh[6]; j6 > 0; ) { + if ( j6 < bsize ) { + s6 = j6; + j6 = 0; + } else { + s6 = bsize; + j6 -= bsize; + } + dx7 = sx[7] - ( s6*sx[6] ); + ox6 = ox7 + ( j6*sx[6] ); + for ( j5 = sh[5]; j5 > 0; ) { + if ( j5 < bsize ) { + s5 = j5; + j5 = 0; + } else { + s5 = bsize; + j5 -= bsize; + } + dx6 = sx[6] - ( s5*sx[5] ); + ox5 = ox6 + ( j5*sx[5] ); + for ( j4 = sh[4]; j4 > 0; ) { + if ( j4 < bsize ) { + s4 = j4; + j4 = 0; + } else { + s4 = bsize; + j4 -= bsize; + } + dx5 = sx[5] - ( s4*sx[4] ); + ox4 = ox5 + ( j4*sx[4] ); + for ( j3 = sh[3]; j3 > 0; ) { + if ( j3 < bsize ) { + s3 = j3; + j3 = 0; + } else { + s3 = bsize; + j3 -= bsize; + } + dx4 = sx[4] - ( s3*sx[3] ); + ox3 = ox4 + ( j3*sx[3] ); + for ( j2 = sh[2]; j2 > 0; ) { + if ( j2 < bsize ) { + s2 = j2; + j2 = 0; + } else { + s2 = bsize; + j2 -= bsize; + } + dx3 = sx[3] - ( s2*sx[2] ); + ox2 = ox3 + ( j2*sx[2] ); + for ( j1 = sh[1]; j1 > 0; ) { + if ( j1 < bsize ) { + s1 = j1; + j1 = 0; + } else { + s1 = bsize; + j1 -= bsize; + } + dx2 = sx[2] - ( s1*sx[1] ); + ox1 = ox2 + ( j1*sx[1] ); + for ( j0 = sh[0]; j0 > 0; ) { + if ( j0 < bsize ) { + s0 = j0; + j0 = 0; + } else { + s0 = bsize; + j0 -= bsize; + } + // Compute the index offset for the first input ndarray element in the current block: + ix = ox1 + ( j0*sx[0] ); + + // Compute the loop offset increment: + dx1 = sx[1] - ( s0*sx[0] ); + + // Iterate over the ndarray dimensions... + for ( i8 = 0; i8 < s8; i8++ ) { + for ( i7 = 0; i7 < s7; i7++ ) { + for ( i6 = 0; i6 < s6; i6++ ) { + for ( i5 = 0; i5 < s5; i5++ ) { + for ( i4 = 0; i4 < s4; i4++ ) { + for ( i3 = 0; i3 < s3; i3++ ) { + for ( i2 = 0; i2 < s2; i2++ ) { + for ( i1 = 0; i1 < s1; i1++ ) { + for ( i0 = 0; i0 < s0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + } + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedsome9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_complex.js new file mode 100644 index 000000000000..716323f16575 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/9d_complex.js @@ -0,0 +1,202 @@ +/** +* @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 max-depth */ + +'use strict'; + +// MODULES // + +var strides2order = require( '@stdlib/ndarray/base/strides2order' ); + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = some9d( x, 4 ); +* // returns true +*/ +function some9d( x, n ) { + var count; + var xbuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var sx; + var ix; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + var i8; + + // Note on variable naming convention: S#, dx#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + if ( strides2order( sx ) === 1 ) { + // For row-major ndarrays, the last dimensions have the fastest changing indices... + S0 = sh[ 8 ]; + S1 = sh[ 7 ]; + S2 = sh[ 6 ]; + S3 = sh[ 5 ]; + S4 = sh[ 4 ]; + S5 = sh[ 3 ]; + S6 = sh[ 2 ]; + S7 = sh[ 1 ]; + S8 = sh[ 0 ]; + dx0 = sx[ 8 ]; // offset increment for innermost loop + dx1 = sx[ 7 ] - ( S0*sx[8] ); + dx2 = sx[ 6 ] - ( S1*sx[7] ); + dx3 = sx[ 5 ] - ( S2*sx[6] ); + dx4 = sx[ 4 ] - ( S3*sx[5] ); + dx5 = sx[ 3 ] - ( S4*sx[4] ); + dx6 = sx[ 2 ] - ( S5*sx[3] ); + dx7 = sx[ 1 ] - ( S6*sx[2] ); + dx8 = sx[ 0 ] - ( S7*sx[1] ); // offset increment for outermost loop + } else { // order === 'column-major' + // For column-major ndarrays, the first dimensions have the fastest changing indices... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + S2 = sh[ 2 ]; + S3 = sh[ 3 ]; + S4 = sh[ 4 ]; + S5 = sh[ 5 ]; + S6 = sh[ 6 ]; + S7 = sh[ 7 ]; + S8 = sh[ 8 ]; + dx0 = sx[ 0 ]; // offset increment for innermost loop + dx1 = sx[ 1 ] - ( S0*sx[0] ); + dx2 = sx[ 2 ] - ( S1*sx[1] ); + dx3 = sx[ 3 ] - ( S2*sx[2] ); + dx4 = sx[ 4 ] - ( S3*sx[3] ); + dx5 = sx[ 5 ] - ( S4*sx[4] ); + dx6 = sx[ 6 ] - ( S5*sx[5] ); + dx7 = sx[ 7 ] - ( S6*sx[6] ); + dx8 = sx[ 8 ] - ( S7*sx[7] ); // offset increment for outermost loop + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Initialize a counter: + count = 0; + + // Iterate over the ndarray dimensions... + for ( i8 = 0; i8 < S8; i8++ ) { + for ( i7 = 0; i7 < S7; i7++ ) { + for ( i6 = 0; i6 < S6; i6++ ) { + for ( i5 = 0; i5 < S5; i5++ ) { + for ( i4 = 0; i4 < S4; i4++ ) { + for ( i3 = 0; i3 < S3; i3++ ) { + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + return false; +} + + +// EXPORTS // + +module.exports = some9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/index.js new file mode 100644 index 000000000000..38f19a993445 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/index.js @@ -0,0 +1,70 @@ +/** +* @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'; + +/** +* Test whether at least `n` elements in an ndarray are truthy. +* +* @module @stdlib/ndarray/base/some +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var some = require( '@stdlib/ndarray/base/some' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Define the success criterion: +* var n = scalar2ndarray( 3, { +* 'dtype': 'generic' +* }); +* +* // Test elements: +* var out = some( [ x, n ] ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/main.js new file mode 100644 index 000000000000..8249e2628a0b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/main.js @@ -0,0 +1,391 @@ +/** +* @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 isComplexArray = require( '@stdlib/array/base/assert/is-complex-typed-array' ); +var isBooleanArray = require( '@stdlib/array/base/assert/is-booleanarray' ); +var iterationOrder = require( '@stdlib/ndarray/base/iteration-order' ); +var minmaxViewBufferIndex = require( '@stdlib/ndarray/base/minmax-view-buffer-index' ); +var ndarray2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); +var reinterpretComplex = require( '@stdlib/strided/base/reinterpret-complex' ); +var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); +var gscal = require( '@stdlib/blas/base/gscal' ); +var blockedaccessorsome2d = require( './2d_blocked_accessors.js' ); +var blockedaccessorsome3d = require( './3d_blocked_accessors.js' ); +var blockedaccessorsome4d = require( './4d_blocked_accessors.js' ); +var blockedaccessorsome5d = require( './5d_blocked_accessors.js' ); +var blockedaccessorsome6d = require( './6d_blocked_accessors.js' ); +var blockedaccessorsome7d = require( './7d_blocked_accessors.js' ); +var blockedaccessorsome8d = require( './8d_blocked_accessors.js' ); +var blockedaccessorsome9d = require( './9d_blocked_accessors.js' ); +var blockedaccessorsome10d = require( './10d_blocked_accessors.js' ); +var blockedcomplexsome2d = require( './2d_blocked_complex.js' ); +var blockedcomplexsome3d = require( './3d_blocked_complex.js' ); +var blockedcomplexsome4d = require( './4d_blocked_complex.js' ); +var blockedcomplexsome5d = require( './5d_blocked_complex.js' ); +var blockedcomplexsome6d = require( './6d_blocked_complex.js' ); +var blockedcomplexsome7d = require( './7d_blocked_complex.js' ); +var blockedcomplexsome8d = require( './8d_blocked_complex.js' ); +var blockedcomplexsome9d = require( './9d_blocked_complex.js' ); +var blockedcomplexsome10d = require( './10d_blocked_complex.js' ); +var blockedsome2d = require( './2d_blocked.js' ); +var blockedsome3d = require( './3d_blocked.js' ); +var blockedsome4d = require( './4d_blocked.js' ); +var blockedsome5d = require( './5d_blocked.js' ); +var blockedsome6d = require( './6d_blocked.js' ); +var blockedsome7d = require( './7d_blocked.js' ); +var blockedsome8d = require( './8d_blocked.js' ); +var blockedsome9d = require( './9d_blocked.js' ); +var blockedsome10d = require( './10d_blocked.js' ); +var accessorsome0d = require( './0d_accessors.js' ); +var accessorsome1d = require( './1d_accessors.js' ); +var accessorsome2d = require( './2d_accessors.js' ); +var accessorsome3d = require( './3d_accessors.js' ); +var accessorsome4d = require( './4d_accessors.js' ); +var accessorsome5d = require( './5d_accessors.js' ); +var accessorsome6d = require( './6d_accessors.js' ); +var accessorsome7d = require( './7d_accessors.js' ); +var accessorsome8d = require( './8d_accessors.js' ); +var accessorsome9d = require( './9d_accessors.js' ); +var accessorsome10d = require( './10d_accessors.js' ); +var accessorsomend = require( './nd_accessors.js' ); +var complexsome0d = require( './0d_complex.js' ); +var complexsome1d = require( './1d_complex.js' ); +var complexsome2d = require( './2d_complex.js' ); +var complexsome3d = require( './3d_complex.js' ); +var complexsome4d = require( './4d_complex.js' ); +var complexsome5d = require( './5d_complex.js' ); +var complexsome6d = require( './6d_complex.js' ); +var complexsome7d = require( './7d_complex.js' ); +var complexsome8d = require( './8d_complex.js' ); +var complexsome9d = require( './9d_complex.js' ); +var complexsome10d = require( './10d_complex.js' ); +var complexsomend = require( './nd_complex.js' ); +var some0d = require( './0d.js' ); +var some1d = require( './1d.js' ); +var some2d = require( './2d.js' ); +var some3d = require( './3d.js' ); +var some4d = require( './4d.js' ); +var some5d = require( './5d.js' ); +var some6d = require( './6d.js' ); +var some7d = require( './7d.js' ); +var some8d = require( './8d.js' ); +var some9d = require( './9d.js' ); +var some10d = require( './10d.js' ); +var somend = require( './nd.js' ); + + +// VARIABLES // + +var SOME = [ + some0d, + some1d, + some2d, + some3d, + some4d, + some5d, + some6d, + some7d, + some8d, + some9d, + some10d, + somend +]; +var ACCESSOR_SOME = [ + accessorsome0d, + accessorsome1d, + accessorsome2d, + accessorsome3d, + accessorsome4d, + accessorsome5d, + accessorsome6d, + accessorsome7d, + accessorsome8d, + accessorsome9d, + accessorsome10d, + accessorsomend +]; +var COMPLEX_SOME = [ + complexsome0d, + complexsome1d, + complexsome2d, + complexsome3d, + complexsome4d, + complexsome5d, + complexsome6d, + complexsome7d, + complexsome8d, + complexsome9d, + complexsome10d, + complexsomend +]; +var BLOCKED_SOME = [ + blockedsome2d, // 0 + blockedsome3d, + blockedsome4d, + blockedsome5d, + blockedsome6d, + blockedsome7d, + blockedsome8d, + blockedsome9d, + blockedsome10d // 8 +]; +var BLOCKED_ACCESSOR_SOME = [ + blockedaccessorsome2d, // 0 + blockedaccessorsome3d, + blockedaccessorsome4d, + blockedaccessorsome5d, + blockedaccessorsome6d, + blockedaccessorsome7d, + blockedaccessorsome8d, + blockedaccessorsome9d, + blockedaccessorsome10d // 8 +]; +var BLOCKED_COMPLEX_SOME = [ + blockedcomplexsome2d, // 0 + blockedcomplexsome3d, + blockedcomplexsome4d, + blockedcomplexsome5d, + blockedcomplexsome6d, + blockedcomplexsome7d, + blockedcomplexsome8d, + blockedcomplexsome9d, + blockedcomplexsome10d // 8 +]; +var MAX_DIMS = SOME.length - 1; + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* ## Notes +* +* - A provided ndarray should be an object with the following properties: +* +* - **dtype**: data type. +* - **data**: data buffer. +* - **shape**: dimensions. +* - **strides**: stride lengths. +* - **offset**: index offset. +* - **order**: specifies whether an ndarray is row-major (C-style) or column major (Fortran-style). +* +* @param {ArrayLikeObject} arrays - array-like object containing an input ndarray and a zero-dimensional ndarray specifying the minimum number of elements in the input ndarray that must satisfy the predicate function +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 3, 1, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Define the success criterion: +* var n = scalar2ndarray( 3, { +* 'dtype': 'generic' +* }); +* +* // Test elements: +* var out = some( [ x, n ] ); +* // returns true +*/ +function some( arrays ) { + var isCmplx; + var ndims; + var xmmv; + var shx; + var iox; + var len; + var sx; + var ox; + var ns; + var N; + var x; + var n; + var d; + var i; + + // Unpack the ndarray and standardize ndarray meta data: + x = ndarray2object( arrays[ 0 ] ); + n = ndarray2object( arrays[ 1 ] ); + + shx = x.shape; + ndims = shx.length; + + // Resolve the success criterion: + N = n.accessors[ 0 ]( n.data, n.offset ); + + // Check for known array types which can be reinterpreted for better iteration performance... + if ( isBooleanArray( x.data ) ) { + x.data = reinterpretBoolean( x.data, 0 ); + x.accessorProtocol = false; + } else if ( isComplexArray( x.data ) ) { + x.data = reinterpretComplex( x.data, 0 ); + x.accessorProtocol = false; + x.strides = gscal( ndims, 2, x.strides, 1 ); + x.offset *= 2; + isCmplx = true; + } + // Determine whether we can avoid iteration altogether... + if ( ndims === 0 ) { + if ( x.accessorProtocol ) { + return ACCESSOR_SOME[ ndims ]( x, N ); + } + if ( isCmplx ) { + return COMPLEX_SOME[ ndims ]( x, N ); + } + return SOME[ ndims ]( x, N ); + } + // Compute the number of elements and the number of singleton dimensions... + len = 1; // number of elements + ns = 0; // number of singleton dimensions + for ( i = 0; i < ndims; i++ ) { + d = shx[ i ]; + + // Note that, if one of the dimensions is `0`, the length will be `0`... + len *= d; + + // Check whether the current dimension is a singleton dimension... + if ( d === 1 ) { + ns += 1; + } + } + // Check whether we were provided an empty ndarray... + if ( len === 0 ) { + return false; + } + // Determine whether the ndarray is one-dimensional and thus readily translates to a one-dimensional strided array... + if ( ndims === 1 ) { + if ( x.accessorProtocol ) { + return ACCESSOR_SOME[ ndims ]( x, N ); + } + if ( isCmplx ) { + return COMPLEX_SOME[ ndims ]( x, N ); + } + return SOME[ ndims ]( x, N ); + } + sx = x.strides; + + // Determine whether the ndarray has only **one** non-singleton dimension (e.g., ndims=4, shape=[10,1,1,1]) so that we can treat an ndarray as being equivalent to a one-dimensional strided array... + if ( ns === ndims-1 ) { + // Get the index of the non-singleton dimension... + for ( i = 0; i < ndims; i++ ) { + if ( shx[ i ] !== 1 ) { + break; + } + } + x.shape = [ shx[i] ]; + x.strides = [ sx[i] ]; + if ( x.accessorProtocol ) { + return ACCESSOR_SOME[ 1 ]( x, N ); + } + if ( isCmplx ) { + return COMPLEX_SOME[ 1 ]( x, N ); + } + return SOME[ 1 ]( x, N ); + } + iox = iterationOrder( sx ); // +/-1 + + // Determine whether we can avoid blocked iteration... + if ( iox !== 0 ) { + // Determine the minimum and maximum linear indices which are accessible by the array view: + xmmv = minmaxViewBufferIndex( shx, sx, x.offset ); + + // Determine whether we can ignore shape (and strides) and treat the ndarray as a linear one-dimensional strided array... + if ( len === ( xmmv[1]-xmmv[0]+1 ) || ( isCmplx && len*2 === ( xmmv[1]-xmmv[0]+2 ) ) ) { // eslint-disable-line max-len + // Note: the above is equivalent to @stdlib/ndarray/base/assert/is-contiguous, but in-lined so we can retain computed values... + if ( iox === 1 ) { + ox = xmmv[ 0 ]; + } else { + ox = xmmv[ 1 ]; + } + x.shape = [ len ]; + x.strides = [ ( isCmplx ) ? iox*2 : iox ]; + x.offset = ox; + if ( x.accessorProtocol ) { + return ACCESSOR_SOME[ 1 ]( x, N ); + } + if ( isCmplx ) { + return COMPLEX_SOME[ 1 ]( x, N ); + } + return SOME[ 1 ]( x, N ); + } + // The ndarray is non-contiguous, so we cannot directly use one-dimensional array functionality... + + // Determine whether we can use simple nested loops... + if ( ndims <= MAX_DIMS ) { + // So long as iteration always moves in the same direction (i.e., no mixed sign strides), we can leverage cache-optimal (i.e., normal) nested loops without resorting to blocked iteration... + if ( x.accessorProtocol ) { + return ACCESSOR_SOME[ ndims ]( x, N ); + } + if ( isCmplx ) { + return COMPLEX_SOME[ ndims ]( x, N ); + } + return SOME[ ndims ]( x, N ); + } + // Fall-through to blocked iteration... + } + // At this point, we're either dealing with a non-contiguous n-dimensional array or a high dimensional n-dimensional array, so our only hope is that we can still perform blocked iteration... + + // Determine whether we can perform blocked iteration... + if ( ndims <= MAX_DIMS ) { + if ( x.accessorProtocol ) { + return BLOCKED_ACCESSOR_SOME[ ndims-2 ]( x, N ); + } + if ( isCmplx ) { + return BLOCKED_COMPLEX_SOME[ ndims-2 ]( x, N ); + } + return BLOCKED_SOME[ ndims-2 ]( x, N ); + } + // Fall-through to linear view iteration without regard for how data is stored in memory (i.e., take the slow path)... + if ( x.accessorProtocol ) { + return accessorsomend( x, N ); + } + if ( isCmplx ) { + return complexsomend( x, N ); + } + return somend( x, N ); +} + + +// EXPORTS // + +module.exports = some; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/nd.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/nd.js new file mode 100644 index 000000000000..da3efdabef87 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/nd.js @@ -0,0 +1,124 @@ +/** +* @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 numel = require( '@stdlib/ndarray/base/numel' ); +var vind2bind = require( '@stdlib/ndarray/base/vind2bind' ); + + +// VARIABLES // + +var MODE = 'throw'; + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 1 ]; +* +* // Define the index offset: +* var ox = 1; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = somend( x, 2 ); +* // returns true +*/ +function somend( x, n ) { + var count; + var xbuf; + var ordx; + var len; + var sh; + var sx; + var ox; + var ix; + var i; + + sh = x.shape; + + // Compute the total number of elements over which to iterate: + len = numel( sh ); + + // Cache a reference to the input ndarray data buffer: + xbuf = x.data; + + // Cache a reference to the stride array: + sx = x.strides; + + // Cache the index of the first indexed element: + ox = x.offset; + + // Cache the array order: + ordx = x.order; + + // Initialize a counter: + count = 0; + + // Iterate over each element based on the linear **view** index, regardless as to how the data is stored in memory... + for ( i = 0; i < len; i++ ) { + ix = vind2bind( sh, sx, ox, ordx, i, MODE ); + if ( xbuf[ ix ] ) { + count += 1; + if ( count >= n ) { + return true; + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = somend; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/nd_accessors.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/nd_accessors.js new file mode 100644 index 000000000000..a9b02737c2f3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/nd_accessors.js @@ -0,0 +1,131 @@ +/** +* @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 numel = require( '@stdlib/ndarray/base/numel' ); +var vind2bind = require( '@stdlib/ndarray/base/vind2bind' ); + + +// VARIABLES // + +var MODE = 'throw'; + + +// MAIN // + +/** +* Tests whether at least `n` elements in an ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {Array} x.accessors - data buffer accessors +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* // Create a data buffer: +* var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = somend( x, 2 ); +* // returns true +*/ +function somend( x, n ) { + var count; + var xbuf; + var ordx; + var len; + var get; + var sh; + var sx; + var ox; + var ix; + var i; + + sh = x.shape; + + // Compute the total number of elements over which to iterate: + len = numel( sh ); + + // Cache a reference to the input ndarray data buffer: + xbuf = x.data; + + // Cache a reference to the stride array: + sx = x.strides; + + // Cache the index of the first indexed element: + ox = x.offset; + + // Cache the array order: + ordx = x.order; + + // Cache accessor: + get = x.accessors[ 0 ]; + + // Initialize a counter: + count = 0; + + // Iterate over each element based on the linear **view** index, regardless as to how the data is stored in memory... + for ( i = 0; i < len; i++ ) { + ix = vind2bind( sh, sx, ox, ordx, i, MODE ); + if ( get( xbuf, ix ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = somend; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/lib/nd_complex.js b/lib/node_modules/@stdlib/ndarray/base/some/lib/nd_complex.js new file mode 100644 index 000000000000..537bdf798863 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/lib/nd_complex.js @@ -0,0 +1,124 @@ +/** +* @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 numel = require( '@stdlib/ndarray/base/numel' ); +var vind2bind = require( '@stdlib/ndarray/base/vind2bind' ); + + +// VARIABLES // + +var MODE = 'throw'; + + +// MAIN // + +/** +* Tests whether at least `n` elements of a reinterpreted complex number ndarray are truthy. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {string} x.dtype - data type +* @param {Collection} x.data - data buffer +* @param {NonNegativeIntegerArray} x.shape - dimensions +* @param {IntegerArray} x.strides - stride lengths +* @param {NonNegativeInteger} x.offset - index offset +* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) +* @param {PositiveInteger} n - number of elements +* @returns {boolean} boolean indicating whether at least `n` elements are truthy +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = somend( x, 4 ); +* // returns true +*/ +function somend( x, n ) { + var count; + var xbuf; + var ordx; + var len; + var sh; + var sx; + var ox; + var ix; + var i; + + sh = x.shape; + + // Compute the total number of elements over which to iterate: + len = numel( sh ); + + // Cache a reference to the output ndarray data buffer: + xbuf = x.data; + + // Cache a reference to the stride array: + sx = x.strides; + + // Cache the index of the first indexed element: + ox = x.offset; + + // Cache the array order: + ordx = x.order; + + // Initialize a counter: + count = 0; + + // Iterate over each element based on the linear **view** index, regardless as to how the data is stored in memory... + for ( i = 0; i < len; i++ ) { + ix = vind2bind( sh, sx, ox, ordx, i, MODE ); + if ( ( xbuf[ ix ] || xbuf[ ix+1 ] ) ) { + count += 1; + if ( count >= n ) { + return true; + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = somend; diff --git a/lib/node_modules/@stdlib/ndarray/base/some/package.json b/lib/node_modules/@stdlib/ndarray/base/some/package.json new file mode 100644 index 000000000000..499295b3b962 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/ndarray/base/some", + "version": "0.0.0", + "description": "Test whether at least `n` elements in an ndarray are truthy.", + "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", + "base", + "strided", + "array", + "ndarray", + "some", + "count", + "search", + "find", + "utility", + "utils" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.0d.js new file mode 100644 index 000000000000..05c80deeff57 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.0d.js @@ -0,0 +1,105 @@ +/** +* @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 Complex128 = require( '@stdlib/complex/float64/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 0-dimensional ndarray are truthy', function test( t ) { + var actual; + var x; + var n; + + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + x = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = scalar2ndarray( 1.0, { + 'dtype': 'float64' + }); + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 0-dimensional ndarray are truthy (complex)', function test( t ) { + var actual; + var x; + var n; + + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + x = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' + }); + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = scalar2ndarray( new Complex128( 1.0, 1.0 ), { + 'dtype': 'complex128' + }); + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 0-dimensional ndarray are truthy (accessors)', function test( t ) { + var actual; + var x; + var n; + + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + x = ndarray( 'generic', toAccessorArray( [ 0.0 ] ), [], [ 0 ], 0, 'row-major' ); + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( 'generic', toAccessorArray( [ 1.0 ] ), [], [ 0 ], 0, 'row-major' ); + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.10d.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.10d.js new file mode 100644 index 000000000000..9d1e5f47a1f0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.10d.js @@ -0,0 +1,3302 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var zeros = require( '@stdlib/array/zeros' ); +var ones = require( '@stdlib/array/ones' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, -8, -4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 1, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ 32, 16, 16, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, 32, 16, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, bsize*32, 16, -8, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, bsize*64, bsize*32, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ bsize*32, bsize*32, bsize*32, -bsize*16, 8, 4, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ bsize*32, bsize*32, bsize*32, -bsize*32, bsize*16, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ + bsize*64, + bsize*64, + bsize*32, + -bsize*32, + bsize*32, + bsize*16, + -8, + 4, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ + bsize*64, + bsize*64, + bsize*32, + -bsize*32, + bsize*32, + bsize*32, + -bsize*16, + 8, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ + bsize*64, + bsize*64, + bsize*32, + -bsize*32, + bsize*16, + bsize*16, + -bsize*16, + bsize*8, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 2, bsize*2 ]; + st = [ + bsize*32, + bsize*32, + bsize*16, + -bsize*16, + bsize*8, + bsize*8, + -bsize*8, + bsize*8, + bsize*4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, -16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 1, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ 32, 16, 16, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, 32, 16, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, bsize*32, 16, -8, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, bsize*64, bsize*32, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ bsize*32, bsize*32, bsize*32, -bsize*16, 8, 4, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ bsize*32, bsize*32, bsize*32, -bsize*32, bsize*16, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ + bsize*64, + bsize*64, + bsize*32, + -bsize*32, + bsize*32, + bsize*16, + -8, + 4, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ + bsize*64, + bsize*64, + bsize*32, + -bsize*32, + bsize*32, + bsize*32, + -bsize*16, + 8, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ + bsize*64, + bsize*64, + bsize*32, + -bsize*32, + bsize*16, + bsize*16, + -bsize*16, + bsize*8, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 2, bsize*2 ]; + st = [ + bsize*32, + bsize*32, + bsize*16, + -bsize*16, + bsize*8, + bsize*8, + -bsize*8, + bsize*8, + bsize*4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, -16, 16, -8, -4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 1, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ 32, 16, 16, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, 32, 16, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, bsize*32, 16, -8, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, bsize*64, bsize*32, -16, 8, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ bsize*32, bsize*32, bsize*32, -bsize*16, 8, 4, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ bsize*32, bsize*32, bsize*32, -bsize*32, bsize*16, 8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ + bsize*64, + bsize*64, + bsize*32, + -bsize*32, + bsize*32, + bsize*16, + -8, + 4, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ + bsize*64, + bsize*64, + bsize*32, + -bsize*32, + bsize*32, + bsize*32, + -bsize*16, + 8, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ + bsize*64, + bsize*64, + bsize*32, + -bsize*32, + bsize*16, + bsize*16, + -bsize*16, + bsize*8, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 2, bsize*2 ]; + st = [ + bsize*32, + bsize*32, + bsize*16, + -bsize*16, + bsize*8, + bsize*8, + -bsize*8, + bsize*8, + bsize*4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -1, -1, -1, -1, -1, -1, -1, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, 2, -2, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 1, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ + 2, + bsize*4, + bsize*8, + -bsize*8, + bsize*8, + bsize*16, + bsize*16, + -bsize*32, + bsize*32, + bsize*32 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ + 2, + 4, + bsize*8, + bsize*16, + bsize*16, + bsize*32, + bsize*32, + bsize*64, + bsize*64, + bsize*64 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ + 2, + 4, + 8, + bsize*16, + bsize*32, + bsize*32, + bsize*32, + bsize*64, + bsize*64, + bsize*64 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ + 2, + 4, + 4, + 8, + bsize*16, + bsize*32, + bsize*32, + bsize*64, + bsize*64, + bsize*64 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 2, bsize*2, 2, 1 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 32, bsize*64, bsize*128 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 16, 32, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 16, -16, 16, 16, 32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -1, -1, -2, -4, -4, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, -2, 2, -2, 2, 2, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 1, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ + 2, + bsize*4, + bsize*8, + -bsize*8, + bsize*8, + bsize*16, + bsize*16, + -bsize*32, + bsize*32, + bsize*32 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ + 2, + 4, + bsize*8, + bsize*16, + bsize*16, + bsize*32, + bsize*32, + bsize*64, + bsize*64, + bsize*64 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ + 2, + 4, + 8, + bsize*16, + bsize*32, + bsize*32, + bsize*32, + bsize*64, + bsize*64, + bsize*64 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ + 2, + 4, + 4, + 8, + bsize*16, + bsize*32, + bsize*32, + bsize*64, + bsize*64, + bsize*64 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 2, bsize*2, 2, 1 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 32, bsize*64, bsize*128 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 16, 32, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 16, -16, 16, 16, 32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -1, -1, -2, -4, -4, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, -2, 2, -2, 2, 2, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 1, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ + 2, + bsize*4, + bsize*8, + -bsize*8, + bsize*8, + bsize*16, + bsize*16, + -bsize*32, + bsize*32, + bsize*32 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 2, 1, 2, 1, 1, 2 ]; + st = [ + 2, + 4, + bsize*8, + bsize*16, + bsize*16, + bsize*32, + bsize*32, + bsize*64, + bsize*64, + bsize*64 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ + 2, + 4, + 8, + bsize*16, + bsize*32, + bsize*32, + bsize*32, + bsize*64, + bsize*64, + bsize*64 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ + 2, + 4, + 4, + 8, + bsize*16, + bsize*32, + bsize*32, + bsize*64, + bsize*64, + bsize*64 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 2, bsize*2, 2, 1 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 32, bsize*64, bsize*128 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 16, 32, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 10-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 16, -16, 16, 16, 32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.1d.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.1d.js new file mode 100644 index 000000000000..cfcd12e023d1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.1d.js @@ -0,0 +1,128 @@ +/** +* @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 ones = require( '@stdlib/array/ones' ); +var zeros = require( '@stdlib/array/zeros' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 1-dimensional ndarray are truthy', function test( t ) { + var actual; + var x; + var n; + + x = ndarray( 'float64', zeros( 8, 'float64' ), [ 4 ], [ 2 ], 1, 'row-major' ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( 'float64', ones( 8, 'float64' ), [ 4 ], [ 2 ], 1, 'row-major' ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 1-dimensional ndarray are truthy (complex)', function test( t ) { + var actual; + var xbuf; + var x; + var n; + + xbuf = zeros( 6*2, 'float64' ); + x = ndarray( 'complex128', new Complex128Array( xbuf ), [ 4 ], [ 1 ], 1, 'row-major' ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 6*2, 'float64' ); + x = ndarray( 'complex128', new Complex128Array( xbuf ), [ 4 ], [ 1 ], 1, 'row-major' ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 1-dimensional ndarray are truthy (accessors)', function test( t ) { + var actual; + var x; + var n; + + x = ndarray( 'generic', toAccessorArray( zeros( 8, 'generic' ) ), [ 4 ], [ 2 ], 1, 'row-major' ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( 'generic', toAccessorArray( ones( 8, 'generic' ) ), [ 4 ], [ 2 ], 1, 'row-major' ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 1-dimensional ndarray are truthy (bool)', function test( t ) { + var actual; + var x; + var n; + + x = ndarray( 'bool', new BooleanArray( 8 ), [ 4 ], [ 2 ], 1, 'row-major' ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( 'bool', new BooleanArray( 8 ), [ 4 ], [ 2 ], 1, 'row-major' ); + x.set( 3, true ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.2d.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.2d.js new file mode 100644 index 000000000000..1f4d5b0301a7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.2d.js @@ -0,0 +1,1507 @@ +/** +* @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 zeros = require( '@stdlib/array/zeros' ); +var ones = require( '@stdlib/array/ones' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, singleton dimensions, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ bsize*4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, contiguous, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ bsize*4, -2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ bsize*4, -2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, singleton dimensions, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -1, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 2, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -2, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ 2, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ -2, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, contiguous, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -1, -2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -1, -2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 2, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 2, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -2, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -2, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -2, bsize*2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -2, bsize*2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ 2, -4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 2-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ 2, -4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( numel( sh ), { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.3d.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.3d.js new file mode 100644 index 000000000000..6defa116514a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.3d.js @@ -0,0 +1,1729 @@ +/** +* @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 zeros = require( '@stdlib/array/zeros' ); +var ones = require( '@stdlib/array/ones' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, singleton dimensions, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 4, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2 ]; + st = [ -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1 ]; + st = [ bsize*4, -2, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2 ]; + st = [ bsize*4, -bsize*4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, contiguous, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ 4, 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ 4, 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ -4, 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ -4, 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2 ]; + st = [ -4, 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2 ]; + st = [ -4, 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1 ]; + st = [ bsize*4, -2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1 ]; + st = [ bsize*4, -2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2 ]; + st = [ bsize*4, -bsize*4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2 ]; + st = [ bsize*4, -bsize*4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, singleton dimensions, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ -1, -2, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ 2, 4, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ -2, 4, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2 ]; + st = [ 2, -bsize*4, bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1 ]; + st = [ -2, 4, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2 ]; + st = [ -2, 4, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, contiguous, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ -1, -2, -2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ -1, -2, -2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ 2, 4, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ 2, 4, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ -2, 4, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ -2, 4, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2 ]; + st = [ -2, bsize*4, bsize*4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2 ]; + st = [ -2, bsize*4, bsize*4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1 ]; + st = [ 2, -4, bsize*8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1 ]; + st = [ 2, -4, bsize*8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2 ]; + st = [ 2, -4, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 3-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2 ]; + st = [ 2, -4, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.4d.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.4d.js new file mode 100644 index 000000000000..34ddd64dc3e8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.4d.js @@ -0,0 +1,1778 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var zeros = require( '@stdlib/array/zeros' ); +var ones = require( '@stdlib/array/ones' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, -4, -2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1 ]; + st = [ -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, bsize*2, 2, 1 ]; + st = [ -bsize*8, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, bsize*2, 1 ]; + st = [ bsize*8, bsize*4, -2, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, 1, bsize*2 ]; + st = [ bsize*8, bsize*4, -bsize*4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2, 1, 2 ]; + st = [ -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, -4, -2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1 ]; + st = [ -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, bsize*2, 2, 1 ]; + st = [ -bsize*8, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, bsize*2, 1 ]; + st = [ -bsize*4, -bsize*4, -2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2 ]; + st = [ -bsize*4, -bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 2, 1, 2 ]; + st = [ -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 8, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 8, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, -4, -2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 8, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 8, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1 ]; + st = [ -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, bsize*2, 2, 1 ]; + st = [ -bsize*8, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1 ]; + st = [ bsize*4, bsize*4, -2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2 ]; + st = [ bsize*4, bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2, 1, 2 ]; + st = [ -1, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 2, 4, 4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 2, -4, -4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, 1, bsize*2 ]; + st = [ 2, 2, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, bsize*2, 1 ]; + st = [ 2, -2, -4, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 1, bsize*2, 1, 2 ]; + st = [ 2, 2, -bsize*4, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 1, 2 ]; + st = [ 2, -bsize*4, bsize*4, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2, 1, 2 ]; + st = [ -1, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 2, 4, 4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 2, 4, -4, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1 ]; + st = [ 2, -bsize*4, -bsize*4, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1 ]; + st = [ 1, 2, -bsize*4, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1 ]; + st = [ 2, 4, -4, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*4 ]; + st = [ 2, 4, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 2, 1, 2 ]; + st = [ -1, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 2, 4, 4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 8, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 8, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 2, -4, -4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 8, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 8, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, 1, bsize*2 ]; + st = [ 2, 2, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, bsize*2, 1 ]; + st = [ 2, 2, -4, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 1, bsize*2, 1, 2 ]; + st = [ 2, 2, -bsize*4, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 4-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 1, 2 ]; + st = [ 2, -bsize*4, bsize*4, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.5d.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.5d.js new file mode 100644 index 000000000000..0fb599f7bc55 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.5d.js @@ -0,0 +1,1988 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var zeros = require( '@stdlib/array/zeros' ); +var ones = require( '@stdlib/array/ones' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2, 1, 2, 2 ]; + st = [ -8, -4, -4, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 8, -4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2 ]; + st = [ 8, -8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2 ]; + st = [ bsize*8, -4, 4, -4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2 ]; + st = [ bsize*8, bsize*8, -4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1 ]; + st = [ bsize*8, bsize*8, -bsize*4, -2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, -bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ -4, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 8, -4, -4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2 ]; + st = [ 8, -8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2 ]; + st = [ -bsize*8, -4, 4, -4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2 ]; + st = [ bsize*8, bsize*8, -4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, -bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ -4, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 8, -4, -4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2 ]; + st = [ 8, -8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2 ]; + st = [ -bsize*8, -4, 4, -4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2 ]; + st = [ bsize*8, bsize*8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, -bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2, 1, 2, 2 ]; + st = [ -1, -2, -4, -4, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 2, -4, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2 ]; + st = [ -2, bsize*4, -bsize*4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2 ]; + st = [ -2, 4, -bsize*8, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2 ]; + st = [ -2, 4, -4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2 ]; + st = [ -2, 4, -4, 4, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2 ]; + st = [ -2, 4, -4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ -1, -2, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 2, 4, -4, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2 ]; + st = [ -2, bsize*4, -bsize*4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1 ]; + st = [ -2, 4, -bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2 ]; + st = [ -2, 4, -4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2 ]; + st = [ -2, -4, -4, 4, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2 ]; + st = [ 2, 4, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ -1, -2, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 2, -4, -4, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2 ]; + st = [ -2, bsize*4, -bsize*4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1 ]; + st = [ -2, 4, -bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2 ]; + st = [ -2, 4, -4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2 ]; + st = [ -2, -4, -4, 4, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 5-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2 ]; + st = [ 2, 4, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.6d.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.6d.js new file mode 100644 index 000000000000..91fbdde607a0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.6d.js @@ -0,0 +1,2198 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var zeros = require( '@stdlib/array/zeros' ); +var ones = require( '@stdlib/array/ones' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, -16, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2 ]; + st = [ 8, -8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2 ]; + st = [ bsize*8, -4, -4, 4, 4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 1, 2 ]; + st = [ bsize*8, bsize*8, -4, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2 ]; + st = [ bsize*8, bsize*8, -bsize*8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, bsize*2, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, -bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, -16, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2 ]; + st = [ 8, -8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2 ]; + st = [ -bsize*8, -4, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 1, 2 ]; + st = [ bsize*8, bsize*8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, bsize*2, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, -bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, -bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 8, -4, -4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2 ]; + st = [ 8, -8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2 ]; + st = [ -bsize*8, -4, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 1, 2 ]; + st = [ bsize*8, bsize*8, -4, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 1, bsize*2, 2 ]; + st = [ bsize*8, -bsize*8, -bsize*8, -bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, -bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ -1, -1, -1, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 2, -2, 2, -4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, bsize*4, bsize*4, -bsize*4, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2 ]; + st = [ 2, 4, bsize*8, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 1, 2 ]; + st = [ 2, 4, 4, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2 ]; + st = [ 2, 4, 4, -4, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 1 ]; + st = [ 2, 4, 4, -4, 8, -bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2 ]; + st = [ 2, 4, 4, -8, 8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ -1, -1, -1, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, -4, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2 ]; + st = [ 2, bsize*4, bsize*4, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2 ]; + st = [ 2, 4, bsize*8, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 1, 2 ]; + st = [ 2, 4, 4, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2 ]; + st = [ 2, 4, 4, -4, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 1 ]; + st = [ 2, 4, 4, -4, 8, -bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2 ]; + st = [ 2, 4, 4, -8, 8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ -1, -1, -1, -2, -4, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, -4, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2 ]; + st = [ 2, bsize*4, bsize*4, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2 ]; + st = [ 2, 4, bsize*8, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 1, 2 ]; + st = [ 2, 4, 4, -bsize*8, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2 ]; + st = [ 2, 4, 4, -4, bsize*8, -bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 1 ]; + st = [ 2, 4, 4, -4, 8, -bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 6-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2 ]; + st = [ 2, 4, 4, -8, 8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.7d.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.7d.js new file mode 100644 index 000000000000..5befd5f7b1bb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.7d.js @@ -0,0 +1,2408 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var zeros = require( '@stdlib/array/zeros' ); +var ones = require( '@stdlib/array/ones' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, -16, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 2 ]; + st = [ 16, -16, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 2, 1, 1, 2 ]; + st = [ bsize*16, -8, 8, 4, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 2 ]; + st = [ bsize*16, -bsize*16, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 2 ]; + st = [ bsize*16, -bsize*16, bsize*8, 4, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 2 ]; + st = [ bsize*16, -bsize*16, bsize*8, bsize*8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2 ]; + st = [ bsize*16, -bsize*16, -bsize*8, bsize*8, bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, bsize*2 ]; + st = [ bsize*16, -bsize*16, -bsize*8, bsize*8, bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 1, 2 ]; + st = [ -8, -8, -4, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -16, 16, -16, -8, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 2 ]; + st = [ 16, -16, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ bsize*16, -8, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 2 ]; + st = [ bsize*16, bsize*16, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 2 ]; + st = [ bsize*16, -bsize*16, -bsize*8, 4, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 2 ]; + st = [ bsize*16, -bsize*16, bsize*8, bsize*8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, 1, bsize*2, 2 ]; + st = [ bsize*16, -bsize*16, -bsize*16, -bsize*8, bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, bsize*2 ]; + st = [ bsize*16, -bsize*16, bsize*8, bsize*8, bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 1, 2 ]; + st = [ -8, -8, -4, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -16, 16, -16, 8, -4, -2, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 2 ]; + st = [ 16, -16, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ -bsize*16, -8, 8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 2 ]; + st = [ bsize*16, -bsize*16, -8, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 2 ]; + st = [ bsize*16, -bsize*16, bsize*8, 4, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 2 ]; + st = [ bsize*16, -bsize*16, -bsize*8, -bsize*8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, 1, bsize*2, 2 ]; + st = [ bsize*16, -bsize*16, bsize*16, bsize*8, -bsize*8, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, bsize*2 ]; + st = [ bsize*16, -bsize*16, bsize*8, bsize*8, -bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 2 ]; + st = [ -1, -2, -2, -4, -4, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, -2, 2, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 2 ]; + st = [ 2, -bsize*4, bsize*4, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 2, 1, 2, 1 ]; + st = [ 2, -4, bsize*8, -bsize*8, bsize*16, -bsize*16, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, -4, -4, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1, 2 ]; + st = [ 2, -4, -4, 4, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 2 ]; + st = [ 2, -4, -4, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2 ]; + st = [ 2, -4, -4, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, bsize*2 ]; + st = [ 2, -4, -4, 8, 8, 16, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 2 ]; + st = [ -1, -2, -2, -4, -4, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, -2, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 2 ]; + st = [ 2, bsize*4, bsize*4, -bsize*8, bsize*8, -bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, 4, -bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, -4, 4, -bsize*8, bsize*8, -bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2, 2 ]; + st = [ 2, -4, -4, 4, bsize*8, bsize*8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 2 ]; + st = [ 2, -4, -4, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2 ]; + st = [ 2, -4, -4, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, bsize*2 ]; + st = [ 2, -4, -4, 8, 8, 16, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 2 ]; + st = [ -1, -2, -2, -4, -4, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, -4, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 2 ]; + st = [ 2, -bsize*4, -bsize*4, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, -4, -bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, -4, -4, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 1, 2, 2 ]; + st = [ 2, -4, -4, 4, bsize*8, bsize*8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 2 ]; + st = [ 2, -4, -4, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2 ]; + st = [ 2, -4, -4, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 7-dimensional ndarray is truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, bsize*2 ]; + st = [ 2, -4, -4, 8, 8, 16, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.8d.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.8d.js new file mode 100644 index 000000000000..9c4e195d9aae --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.8d.js @@ -0,0 +1,2645 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var zeros = require( '@stdlib/array/zeros' ); +var ones = require( '@stdlib/array/ones' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, -16, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 2 ]; + st = [ 32, -16, 8, -8, -8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 2, 1, 2 ]; + st = [ -bsize*32, -16, 8, -8, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 2, 1, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, 16, -8, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*32, -16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*16, -bsize*16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2, 2 ]; + st = [ -bsize*32, -bsize*32, -bsize*16, -bsize*16, -bsize*16, 8, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 2 ]; + st = [ -bsize*16, -bsize*16, -bsize*8, bsize*8, bsize*8, bsize*8, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, 1, bsize*2 ]; + st = [ + -bsize*16, + -bsize*16, + -bsize*8, + bsize*8, + bsize*8, + bsize*4, + bsize*4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, -16, 16, -16, -8, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 2 ]; + st = [ 32, 16, 8, -8, -8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 2, 1, 2 ]; + st = [ -bsize*32, -16, 8, -8, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 2, 1, 2, 1, 2 ]; + st = [ bsize*32, bsize*32, 16, 8, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 2, 1, 2 ]; + st = [ bsize*32, -bsize*32, -bsize*32, -16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 2, 1, 2 ]; + st = [ bsize*32, -bsize*32, bsize*16, -bsize*16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2, 2 ]; + st = [ bsize*32, -bsize*32, -bsize*16, -bsize*16, bsize*16, 8, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 2 ]; + st = [ -bsize*16, -bsize*16, bsize*8, -bsize*8, -bsize*8, bsize*8, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, 1, bsize*2 ]; + st = [ + -bsize*16, + -bsize*16, + bsize*8, + -bsize*8, + -bsize*8, + bsize*4, + bsize*4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, -16, 16, -16, 8, -4, -2, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 2 ]; + st = [ 32, 16, 8, -8, -8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 2, 1, 2 ]; + st = [ -bsize*32, -16, 8, -8, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 2, 1, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, 16, -8, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 2, 1, 2 ]; + st = [ -bsize*32, bsize*32, -bsize*32, -16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, -bsize*16, -bsize*16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 2, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*16, bsize*16, -bsize*16, 8, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 2 ]; + st = [ -bsize*16, -bsize*16, bsize*8, bsize*8, -bsize*8, bsize*8, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, 1, bsize*2 ]; + st = [ + -bsize*16, + -bsize*16, + bsize*8, + bsize*8, + -bsize*8, + bsize*4, + -bsize*4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -2, -4, -4, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, -2, 2, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2, 1, 2 ]; + st = [ 2, -bsize*4, bsize*4, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2, 1, 2 ]; + st = [ 2, -4, bsize*8, -bsize*8, bsize*8, bsize*8, -bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*16, bsize*16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 2, bsize*2, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, 16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 1, 2 ]; + st = [ 2, -4, -4, 8, 8, 16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, 32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -2, -4, -4, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -2, 2, -2, 2, 2, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2, 1, 2 ]; + st = [ 2, bsize*4, bsize*4, -bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2, 1, 2 ]; + st = [ 2, -4, -bsize*8, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, 4, 8, -bsize*16, bsize*16, -bsize*16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 2, bsize*2, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, 16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, 32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -2, -4, -4, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2, 1, 2 ]; + st = [ 2, -bsize*4, -bsize*4, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2, 1, 2 ]; + st = [ 2, -4, bsize*8, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, -4, -8, bsize*16, bsize*16, bsize*16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, -4, -4, 8, bsize*16, bsize*16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 2, bsize*2, 1, 1, 2 ]; + st = [ 2, -4, -4, 8, 16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 1, 2 ]; + st = [ 2, -4, -4, 8, 8, 16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, -4, -4, 8, 8, 8, 16, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an 8-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, 32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.9d.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.9d.js new file mode 100644 index 000000000000..8605dba3482c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.9d.js @@ -0,0 +1,2978 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var zeros = require( '@stdlib/array/zeros' ); +var ones = require( '@stdlib/array/ones' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, -16, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ 32, -16, 8, -8, -8, 4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ -bsize*32, -16, 8, -8, -8, 4, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 1, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ -bsize*64, -bsize*32, 16, -8, -8, 4, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, 16, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ -bsize*64, -bsize*64, bsize*32, -bsize*16, -8, 4, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ -bsize*64, -bsize*64, -bsize*32, -bsize*32, -bsize*16, 8, -4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ + -bsize*64, + -bsize*64, + -bsize*32, + bsize*32, + bsize*32, + bsize*16, + 8, + -4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2 ]; + st = [ + -bsize*32, + -bsize*32, + -bsize*16, + bsize*16, + bsize*16, + -bsize*16, + bsize*8, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2 ]; + st = [ + -bsize*32, + -bsize*32, + -bsize*16, + bsize*16, + bsize*8, + -bsize*8, + bsize*8, + bsize*4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, -16, 16, -8, -4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ 32, -16, -8, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ bsize*32, -16, -8, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*32, -16, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, 16, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, bsize*16, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, bsize*32, bsize*16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ + bsize*64, + -bsize*64, + -bsize*32, + bsize*32, + bsize*32, + -bsize*16, + 8, + -4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2 ]; + st = [ + -bsize*32, + -bsize*32, + -bsize*16, + bsize*16, + bsize*16, + -bsize*16, + bsize*8, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2 ]; + st = [ + -bsize*32, + -bsize*32, + -bsize*16, + bsize*16, + bsize*8, + -bsize*8, + bsize*8, + bsize*4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, -16, 16, -8, -4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ 32, -16, -8, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ bsize*32, -16, -8, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*32, -16, 8, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, 16, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, bsize*16, 8, -4, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ bsize*64, -bsize*64, -bsize*32, bsize*32, bsize*16, -8, 4, -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ + bsize*64, + -bsize*64, + -bsize*32, + bsize*32, + bsize*32, + -bsize*16, + 8, + -4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2 ]; + st = [ + -bsize*32, + -bsize*32, + -bsize*16, + bsize*16, + bsize*16, + -bsize*16, + bsize*8, + 4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, 1, 1, 2, bsize*2 ]; + st = [ + -bsize*32, + -bsize*32, + -bsize*16, + bsize*16, + bsize*8, + -bsize*8, + bsize*8, + bsize*4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ -1, -2, -4, -4, -8, -8, -8, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, -2, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ + 2, + bsize*4, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*32, + bsize*32, + bsize*32 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 1, 1, 1, 2 ]; + st = [ + 2, + 4, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*16, + bsize*16, + bsize*16 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 1, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32, bsize*32 ]; // eslint-disable-line max-len + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, bsize*32, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 8, 16, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 8, 16, 32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, contiguous, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ -1, -2, -4, -4, -8, -8, -8, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, -2, 2, -2, 2, 1, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 16, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ + 2, + bsize*4, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*32, + bsize*32, + bsize*32 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 1, 1, 1, 2 ]; + st = [ + 2, + 4, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*16, + bsize*16, + bsize*16 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 1, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32, bsize*32 ]; // eslint-disable-line max-len + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, bsize*32, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 8, 16, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 8, 16, 32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ -1, -2, -4, -4, -8, -8, -8, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, 2, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 2, 2, 2, 2, 2, -2, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( 16, dt ) ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( 16, dt ) ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2, 2, 1, 1, 2, 1, 1, 2 ]; + st = [ + 2, + bsize*4, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*32, + bsize*32, + bsize*32 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 2, 1, 1, 1, 1, 1, 2 ]; + st = [ + 2, + 4, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*16, + bsize*16, + bsize*16 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 2, 1, 1, 1, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32, bsize*32 ]; // eslint-disable-line max-len + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 2, 1, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, 2, bsize*2, 2, 1, 1, 2 ]; + st = [ 2, 4, 4, 4, 8, bsize*16, bsize*32, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, bsize*32, bsize*64, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32, bsize*64 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 8, 16, bsize*32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in a 9-dimensional ndarray are truthy (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 8, 16, 32 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( zeros( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, toAccessorArray( ones( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.js new file mode 100644 index 000000000000..9ec769a568ee --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.js @@ -0,0 +1,52 @@ +/** +* @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 ones = require( '@stdlib/array/ones' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `false` if provided an empty input ndarray', function test( t ) { + var actual; + var x; + var n; + + x = ndarray( 'float64', ones( 8, 'float64' ), [ 0 ], [ 1 ], 0, 'row-major' ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/some/test/test.nd.js b/lib/node_modules/@stdlib/ndarray/base/some/test/test.nd.js new file mode 100644 index 000000000000..81cfc0a78d13 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/some/test/test.nd.js @@ -0,0 +1,1062 @@ +/** +* @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 zeros = require( '@stdlib/array/zeros' ); +var ones = require( '@stdlib/array/ones' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var some = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof some, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, singleton dimensions, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -8, -4, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 8, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, contiguous, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -8, -4, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -8, -8, -4, -4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 8, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 8, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, -16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, -16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, singleton dimensions, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1 ]; + st = [ -1, -2, -2, -4, -4, -8, -8, -8, -8, -8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 16, 16, 16, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 1, -1, -4, 8, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, contiguous, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1 ]; + st = [ -1, -2, -2, -4, -4, -8, -8, -8, -8, -8, -8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1 ]; + st = [ -1, -2, -2, -4, -4, -8, -8, -8, -8, -8, -8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh ), 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 16, 16, 16, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1 ]; + st = [ 2, 4, 4, 8, 8, 16, 16, 16, 16, 16, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, -1, 1, -1, 1, 1, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether at least `n` elements in an n-dimensional ndarray are truthy (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var n; + + dt = 'generic'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, -1, 1, -1, 1, 1, -4, -8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + n = scalar2ndarray( 1, { + 'dtype': 'generic' + }); + + actual = some( [ x, n ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'generic' ); + x = ndarray( dt, toAccessorArray( xbuf ), sh, st, o, ord ); + + actual = some( [ x, n ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/concat/README.md b/lib/node_modules/@stdlib/ndarray/concat/README.md new file mode 100644 index 000000000000..7d3d00d921a8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/README.md @@ -0,0 +1,176 @@ + + +# concat + +> Concatenate a list of [ndarrays][@stdlib/ndarray/ctor] along a specified [ndarray][@stdlib/ndarray/ctor] dimension. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var concat = require( '@stdlib/ndarray/concat' ); +``` + +#### concat( arrays\[, dim] ) + +Concatenates a list of [ndarrays][@stdlib/ndarray/ctor] along a specified [ndarray][@stdlib/ndarray/ctor] dimension. + +```javascript +var array = require( '@stdlib/ndarray/array' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); + +var x = array( [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ] ); +var y = array( [ [ -5.0, 6.0, -7.0 ], [ 8.0, -9.0, 10.0 ] ] ); + +var out = concat( [ x, y ], -1 ); +// returns + +var arr = ndarray2array( out ); +// returns [ [ -1.0, 2.0, -5.0, 6.0, -7.0 ], [ -3.0, 4.0, 8.0, -9.0, 10.0 ] ] +``` + +The function accepts the following arguments: + +- **arrays**: a list of input [ndarrays][@stdlib/ndarray/ctor]. Must be [broadcast compatible][@stdlib/ndarray/base/broadcast-shapes] except for the dimension along which to concatenate. The data type of the output [ndarray][@stdlib/ndarray/ctor] is determined by applying [type promotion rules][@stdlib/ndarray/promotion-rules] to the list of input [ndarrays][@stdlib/ndarray/ctor]. If provided [ndarrays][@stdlib/ndarray/ctor] having different [memory layouts][@stdlib/ndarray/orders], the output [ndarray][@stdlib/ndarray/ctor] has the [default order][@stdlib/ndarray/defaults]. +- **dim**: dimension along which to concatenate input [ndarrays][@stdlib/ndarray/ctor] (_optional_). Must be a negative integer. The index of the dimension along which to concatenate is resolved relative to the last dimension, with the last dimension corresponding to the value `-1`. Default: `-1`. + +#### concat.assign( arrays, out\[, dim] ) + +Concatenates a list of ndarrays along a specified ndarray dimension and assigns results to an output ndarray. + +```javascript +var array = require( '@stdlib/ndarray/array' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); + +var x = array( [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ] ); +var y = array( [ [ -5.0, 6.0, -7.0 ], [ 8.0, -9.0, 10.0 ] ] ); + +var z = zeros( [ 2, 5 ] ); + +var out = concat.assign( [ x, y ], z, -1 ); +// returns + +var bool = ( out === z ); +// returns true + +var arr = ndarray2array( z ); +// returns [ [ -1.0, 2.0, -5.0, 6.0, -7.0 ], [ -3.0, 4.0, 8.0, -9.0, 10.0 ] ] +``` + +The function accepts the following arguments: + +- **arrays**: a list of input [ndarrays][@stdlib/ndarray/ctor]. Must be [broadcast compatible][@stdlib/ndarray/base/broadcast-shapes] except for the dimension along which to concatenate. Must [promote][@stdlib/ndarray/promotion-rules] to a [data type][@stdlib/ndarray/dtypes] which can be (mostly) [safely cast][@stdlib/ndarray/mostly-safe-casts] to the [data type][@stdlib/ndarray/dtypes] of the output [ndarray][@stdlib/ndarray/ctor]. +- **out**: output [ndarray][@stdlib/ndarray/ctor]. +- **dim**: dimension along which to concatenate input [ndarrays][@stdlib/ndarray/ctor] (_optional_). Must be a negative integer. The index of the dimension along which to concatenate is resolved relative to the last dimension, with the last dimension corresponding to the value `-1`. Default: `-1`. + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var concat = require( '@stdlib/ndarray/concat' ); + +var xbuf = discreteUniform( 6, 0, 10, { + 'dtype': 'generic' +}); +var x = new ndarray( 'generic', xbuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var ybuf = discreteUniform( 8, 0, 10, { + 'dtype': 'generic' +}); +var y = new ndarray( 'generic', ybuf, [ 2, 4 ], [ 4, 1 ], 0, 'row-major' ); +console.log( ndarray2array( y ) ); + +var out = concat( [ x, y ], -1 ); +console.log( ndarray2array( out ) ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/concat/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/ndarray/concat/benchmark/benchmark.assign.js new file mode 100644 index 000000000000..eab82229c1cf --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/benchmark/benchmark.assign.js @@ -0,0 +1,365 @@ +/** +* @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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var pkg = require( './../package.json' ).name; +var concat = require( './../lib/assign.js' ); + + +// MAIN // + +bench( pkg+'::1d', function benchmark( b ) { + var values; + var opts; + var out; + var v; + var i; + + opts = { + 'dtype': 'float64' + }; + + values = [ + zeros( [ 32 ], opts ), + zeros( [ 32 ], opts ), + zeros( [ 32 ], opts ), + zeros( [ 32 ], opts ) + ]; + out = zeros( [ 128 ], opts ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, out, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::1d,casting', function benchmark( b ) { + var values; + var out; + var v; + var i; + + /* eslint-disable object-curly-newline */ + + values = [ + zeros( [ 32 ], { 'dtype': 'float64' }), + zeros( [ 32 ], { 'dtype': 'float32' }), + zeros( [ 32 ], { 'dtype': 'int32' }), + zeros( [ 32 ], { 'dtype': 'generic' }) + ]; + out = zeros( [ 128 ], { 'dtype': 'generic' }); + + /* eslint-enable object-curly-newline */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, out, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::2d', function benchmark( b ) { + var values; + var opts; + var out; + var v; + var i; + + opts = { + 'dtype': 'float64' + }; + + values = [ + zeros( [ 2, 16 ], opts ), + zeros( [ 2, 16 ], opts ), + zeros( [ 2, 16 ], opts ), + zeros( [ 2, 16 ], opts ) + ]; + out = zeros( [ 2, 64 ], opts ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, out, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::2d,casting', function benchmark( b ) { + var values; + var out; + var v; + var i; + + /* eslint-disable object-curly-newline */ + + values = [ + zeros( [ 2, 16 ], { 'dtype': 'float64' }), + zeros( [ 2, 16 ], { 'dtype': 'float32' }), + zeros( [ 2, 16 ], { 'dtype': 'int32' }), + zeros( [ 2, 16 ], { 'dtype': 'generic' }) + ]; + out = zeros( [ 2, 64 ], { 'dtype': 'generic' }); + + /* eslint-enable object-curly-newline */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, out, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::3d', function benchmark( b ) { + var values; + var opts; + var out; + var v; + var i; + + opts = { + 'dtype': 'float64' + }; + + values = [ + zeros( [ 2, 2, 8 ], opts ), + zeros( [ 2, 2, 8 ], opts ), + zeros( [ 2, 2, 8 ], opts ), + zeros( [ 2, 2, 8 ], opts ) + ]; + out = zeros( [ 2, 2, 32 ], opts ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, out, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::3d,casting', function benchmark( b ) { + var values; + var out; + var v; + var i; + + /* eslint-disable object-curly-newline */ + + values = [ + zeros( [ 2, 2, 8 ], { 'dtype': 'float64' }), + zeros( [ 2, 2, 8 ], { 'dtype': 'float32' }), + zeros( [ 2, 2, 8 ], { 'dtype': 'int32' }), + zeros( [ 2, 2, 8 ], { 'dtype': 'generic' }) + ]; + out = zeros( [ 2, 2, 32 ], { 'dtype': 'generic' }); + + /* eslint-enable object-curly-newline */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, out, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::4d', function benchmark( b ) { + var values; + var opts; + var out; + var v; + var i; + + opts = { + 'dtype': 'float64' + }; + + values = [ + zeros( [ 2, 2, 2, 4 ], opts ), + zeros( [ 2, 2, 2, 4 ], opts ), + zeros( [ 2, 2, 2, 4 ], opts ), + zeros( [ 2, 2, 2, 4 ], opts ) + ]; + out = zeros( [ 2, 2, 2, 16 ], opts ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, out, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::4d,casting', function benchmark( b ) { + var values; + var out; + var v; + var i; + + /* eslint-disable object-curly-newline */ + + values = [ + zeros( [ 2, 2, 2, 4 ], { 'dtype': 'float64' }), + zeros( [ 2, 2, 2, 4 ], { 'dtype': 'float32' }), + zeros( [ 2, 2, 2, 4 ], { 'dtype': 'int32' }), + zeros( [ 2, 2, 2, 4 ], { 'dtype': 'generic' }) + ]; + out = zeros( [ 2, 2, 2, 16 ], { 'dtype': 'generic' }); + + /* eslint-enable object-curly-newline */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, out, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::5d', function benchmark( b ) { + var values; + var opts; + var out; + var v; + var i; + + opts = { + 'dtype': 'float64' + }; + + values = [ + zeros( [ 2, 2, 2, 2, 2 ], opts ), + zeros( [ 2, 2, 2, 2, 2 ], opts ), + zeros( [ 2, 2, 2, 2, 2 ], opts ), + zeros( [ 2, 2, 2, 2, 2 ], opts ) + ]; + out = zeros( [ 2, 2, 2, 2, 8 ], opts ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, out, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::5d,casting', function benchmark( b ) { + var values; + var out; + var v; + var i; + + /* eslint-disable object-curly-newline */ + + values = [ + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' }), + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' }), + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' }), + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' }) + ]; + out = zeros( [ 2, 2, 2, 2, 8 ], { 'dtype': 'generic' }); + + /* eslint-enable object-curly-newline */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, out, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/concat/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/concat/benchmark/benchmark.js new file mode 100644 index 000000000000..513d864440e3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/benchmark/benchmark.js @@ -0,0 +1,345 @@ +/** +* @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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var pkg = require( './../package.json' ).name; +var concat = require( './../lib' ); + + +// MAIN // + +bench( pkg+'::1d', function benchmark( b ) { + var values; + var opts; + var v; + var i; + + opts = { + 'dtype': 'float64' + }; + + values = [ + zeros( [ 32 ], opts ), + zeros( [ 32 ], opts ), + zeros( [ 32 ], opts ), + zeros( [ 32 ], opts ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::1d,casting', function benchmark( b ) { + var values; + var v; + var i; + + /* eslint-disable object-curly-newline */ + + values = [ + zeros( [ 32 ], { 'dtype': 'float64' }), + zeros( [ 32 ], { 'dtype': 'float32' }), + zeros( [ 32 ], { 'dtype': 'int32' }), + zeros( [ 32 ], { 'dtype': 'generic' }) + ]; + + /* eslint-enable object-curly-newline */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::2d', function benchmark( b ) { + var values; + var opts; + var v; + var i; + + opts = { + 'dtype': 'float64' + }; + + values = [ + zeros( [ 2, 16 ], opts ), + zeros( [ 2, 16 ], opts ), + zeros( [ 2, 16 ], opts ), + zeros( [ 2, 16 ], opts ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::2d,casting', function benchmark( b ) { + var values; + var v; + var i; + + /* eslint-disable object-curly-newline */ + + values = [ + zeros( [ 2, 16 ], { 'dtype': 'float64' }), + zeros( [ 2, 16 ], { 'dtype': 'float32' }), + zeros( [ 2, 16 ], { 'dtype': 'int32' }), + zeros( [ 2, 16 ], { 'dtype': 'generic' }) + ]; + + /* eslint-enable object-curly-newline */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::3d', function benchmark( b ) { + var values; + var opts; + var v; + var i; + + opts = { + 'dtype': 'float64' + }; + + values = [ + zeros( [ 2, 2, 8 ], opts ), + zeros( [ 2, 2, 8 ], opts ), + zeros( [ 2, 2, 8 ], opts ), + zeros( [ 2, 2, 8 ], opts ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::3d,casting', function benchmark( b ) { + var values; + var v; + var i; + + /* eslint-disable object-curly-newline */ + + values = [ + zeros( [ 2, 2, 8 ], { 'dtype': 'float64' }), + zeros( [ 2, 2, 8 ], { 'dtype': 'float32' }), + zeros( [ 2, 2, 8 ], { 'dtype': 'int32' }), + zeros( [ 2, 2, 8 ], { 'dtype': 'generic' }) + ]; + + /* eslint-enable object-curly-newline */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::4d', function benchmark( b ) { + var values; + var opts; + var v; + var i; + + opts = { + 'dtype': 'float64' + }; + + values = [ + zeros( [ 2, 2, 2, 4 ], opts ), + zeros( [ 2, 2, 2, 4 ], opts ), + zeros( [ 2, 2, 2, 4 ], opts ), + zeros( [ 2, 2, 2, 4 ], opts ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::4d,casting', function benchmark( b ) { + var values; + var v; + var i; + + /* eslint-disable object-curly-newline */ + + values = [ + zeros( [ 2, 2, 2, 4 ], { 'dtype': 'float64' }), + zeros( [ 2, 2, 2, 4 ], { 'dtype': 'float32' }), + zeros( [ 2, 2, 2, 4 ], { 'dtype': 'int32' }), + zeros( [ 2, 2, 2, 4 ], { 'dtype': 'generic' }) + ]; + + /* eslint-enable object-curly-newline */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::5d', function benchmark( b ) { + var values; + var opts; + var v; + var i; + + opts = { + 'dtype': 'float64' + }; + + values = [ + zeros( [ 2, 2, 2, 2, 2 ], opts ), + zeros( [ 2, 2, 2, 2, 2 ], opts ), + zeros( [ 2, 2, 2, 2, 2 ], opts ), + zeros( [ 2, 2, 2, 2, 2 ], opts ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::5d,casting', function benchmark( b ) { + var values; + var v; + var i; + + /* eslint-disable object-curly-newline */ + + values = [ + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' }), + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' }), + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' }), + zeros( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' }) + ]; + + /* eslint-enable object-curly-newline */ + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = concat( values, -1 ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( !isndarrayLike( v ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/concat/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/concat/docs/repl.txt new file mode 100644 index 000000000000..da49c69232fd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/docs/repl.txt @@ -0,0 +1,75 @@ + +{{alias}}( arrays[, dim] ) + Concatenates a list of ndarrays along a specified ndarray dimension. + + Parameters + ---------- + arrays: ArrayLikeObject + List of ndarrays to concatenate. Must be broadcast compatible except for + the dimension along which to concatenate. The data type of the output + ndarray is determined by applying type promotion rules to the list of + input ndarrays. If provided ndarrays having different memory layouts, + the output ndarray has the default order. + + dim: integer (optional) + Dimension along which to concatenate input ndarrays. Must be a negative + integer. The index of the dimension along which to concatenate is + resolved relative to the last dimension, with the last dimension + corresponding to the value `-1`. Default: -1. + + Returns + ------- + out: ndarray + Output ndarray. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); + > var y = {{alias:@stdlib/ndarray/array}}( [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] ); + > var out = {{alias}}( [ x, y ], -1 ) + + > var arr = {{alias:@stdlib/ndarray/to-array}}( out ) + [ [ 1.0, 2.0, 5.0, 6.0 ], [ 3.0, 4.0, 7.0, 8.0 ] ] + + +{{alias}}.assign( arrays, out[, dim] ) + Concatenates a list of ndarrays along a specified ndarray dimension and + assigns results to a provided output ndarray. + + Parameters + ---------- + arrays: ArrayLikeObject + List of ndarrays to concatenate. Must be broadcast compatible except for + the dimension along which to concatenate. Must promote] to a data type + which can be (mostly) safely cast to the data type of the output + ndarray. + + out: ndarray + Output ndarray. + + dim: integer (optional) + Dimension along which to concatenate input ndarrays. Must be a negative + integer. The index of the dimension along which to concatenate is + resolved relative to the last dimension, with the last dimension + corresponding to the value `-1`. Default: -1. + + Returns + ------- + out: ndarray + Output ndarray. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0 ], [ 2.0 ] ] ); + > var y = {{alias:@stdlib/ndarray/array}}( [ [ 3.0 ], [ 4.0 ] ] ); + > var z = {{alias:@stdlib/ndarray/array}}( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ); + > var out = {{alias}}.assign( [ x, y ], z, -1 ) + + > var bool = ( out === z ) + true + > var arr = {{alias:@stdlib/ndarray/to-array}}( out ) + [ [ 1.0, 3.0 ], [ 2.0, 4.0 ] ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/concat/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/concat/docs/types/index.d.ts new file mode 100644 index 000000000000..c09d62a24133 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/docs/types/index.d.ts @@ -0,0 +1,138 @@ +/* +* @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 { ArrayLike } from '@stdlib/types/array'; +import { typedndarray } from '@stdlib/types/ndarray'; + +/** +* Interface describing `concat`. +*/ +interface Concat { + /** + * Concatenates a list of ndarrays along a specified ndarray dimension. + * + * @param arrays - array-like object containing input ndarrays + * @param dim - dimension along which to concatenate input ndarrays + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * var ndarray = require( '@stdlib/ndarray/ctor' ); + * + * var xbuf = new Float64Array( [ -1.0, 2.0, -3.0, 4.0 ] ); + * var x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + * + * var ybuf = new Float64Array( [ -5.0, 6.0, -7.0, 8.0, -9.0, 10.0 ] ); + * var y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); + * + * var out = concat( [ x, y ], -1 ); + * // returns + * + * var arr = ndarray2array( out ); + * // returns [ [ -1.0, 2.0, -5.0, 6.0, -7.0 ], [ -3.0, 4.0, 8.0, -9.0, 10.0 ] ] + */ + ( arrays: ArrayLike>, dim?: number ): typedndarray; + + /** + * Concatenates a list of ndarrays along a specified ndarray dimension and assigns results to a provided output ndarray. + * + * @param arrays - array-like object containing input ndarrays + * @param out - output ndarray + * @param dim - dimension along which to concatenate input ndarrays + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * var ndarray = require( '@stdlib/ndarray/ctor' ); + * + * var xbuf = new Float64Array( [ -1.0, 2.0, -3.0, 4.0 ] ); + * var x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + * + * var ybuf = new Float64Array( [ -5.0, 6.0, -7.0, 8.0, -9.0, 10.0 ] ); + * var y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); + * + * var z = new ndarray( 'float64', new Float64Array( 10 ), [ 2, 5 ], [ 5, 1 ], 0, 'row-major' ); + * + * var out = concat.assign( [ x, y ], z, -1 ); + * + * var bool = ( out === z ); + * // returns true + * + * var arr = ndarray2array( z ); + * // returns [ [ -1.0, 2.0, -5.0, 6.0, -7.0 ], [ -3.0, 4.0, 8.0, -9.0, 10.0 ] ] + */ + assign = typedndarray>( arrays: ArrayLike>, out: V, dim?: number ): V; +} + +/** +* Concatenates a list of ndarrays along a specified ndarray dimension. +* +* @param arrays - array-like object containing input ndarrays +* @param dim - dimension along which to concatenate input ndarrays +* @returns output ndarray +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* var xbuf = new Float64Array( [ -1.0, 2.0, -3.0, 4.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); +* +* var ybuf = new Float64Array( [ -5.0, 6.0, -7.0, 8.0, -9.0, 10.0 ] ); +* var y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); +* +* var out = concat( [ x, y ], -1 ); +* // returns +* +* var arr = ndarray2array( out ); +* // returns [ [ -1.0, 2.0, -5.0, 6.0, -7.0 ], [ -3.0, 4.0, 8.0, -9.0, 10.0 ] ] +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* var xbuf = new Float64Array( [ -1.0, 2.0, -3.0, 4.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); +* +* var ybuf = new Float64Array( [ -5.0, 6.0, -7.0, 8.0, -9.0, 10.0 ] ); +* var y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); +* +* var z = new ndarray( 'float64', new Float64Array( 10 ), [ 2, 5 ], [ 5, 1 ], 0, 'row-major' ); +* +* var out = concat.assign( [ x, y ], z, -1 ); +* +* var bool = ( out === z ); +* // returns true +* +* var arr = ndarray2array( z ); +* // returns [ [ -1.0, 2.0, -5.0, 6.0, -7.0 ], [ -3.0, 4.0, 8.0, -9.0, 10.0 ] ] +*/ +declare var concat: Concat; + + +// EXPORTS // + +export = concat; diff --git a/lib/node_modules/@stdlib/ndarray/concat/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/concat/docs/types/test.ts new file mode 100644 index 000000000000..ff76be611a3d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/docs/types/test.ts @@ -0,0 +1,162 @@ +/* +* @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. +*/ + +/// + +import zeros = require( '@stdlib/ndarray/zeros' ); +import concat = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 2, 2 ] ); + const y = zeros( [ 2, 3 ] ); + + concat( [ x, y ] ); // $ExpectType typedndarray + concat( [ x, y ], -1 ); // $ExpectType typedndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array-like object containing ndarrays... +{ + concat( 5 ); // $ExpectError + concat( true ); // $ExpectError + concat( false ); // $ExpectError + concat( null ); // $ExpectError + concat( undefined ); // $ExpectError + concat( [ 1 ] ); // $ExpectError + concat( {} ); // $ExpectError + concat( ( x: number ): number => x ); // $ExpectError + + concat( 5, -1 ); // $ExpectError + concat( true, -1 ); // $ExpectError + concat( false, -1 ); // $ExpectError + concat( null, -1 ); // $ExpectError + concat( undefined, -1 ); // $ExpectError + concat( [ 1 ], -1 ); // $ExpectError + concat( {}, -1 ); // $ExpectError + concat( ( x: number ): number => x, -1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = zeros( [ 2, 2 ] ); + const y = zeros( [ 2, 3 ] ); + + concat( [ x, y ], '5' ); // $ExpectError + concat( [ x, y ], true ); // $ExpectError + concat( [ x, y ], false ); // $ExpectError + concat( [ x, y ], null ); // $ExpectError + concat( [ x, y ], [ 1 ] ); // $ExpectError + concat( [ x, y ], {} ); // $ExpectError + concat( [ x, y ], ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ] ); + const y = zeros( [ 2, 3 ] ); + + concat(); // $ExpectError + concat( x ); // $ExpectError + concat( [ x, y ], -1, {} ); // $ExpectError +} + +// Attached to the function is an `assign` method which returns an ndarray... +{ + const x = zeros( [ 2, 2 ] ); + const y = zeros( [ 2, 3 ] ); + const z = zeros( [ 2, 5 ] ); + + concat.assign( [ x, y ], z ); // $ExpectType float64ndarray + concat.assign( [ x, y ], z, -1 ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object containing ndarrays...... +{ + const z = zeros( [ 2, 5 ] ); + + concat.assign( 5, z ); // $ExpectError + concat.assign( true, z ); // $ExpectError + concat.assign( false, z ); // $ExpectError + concat.assign( null, z ); // $ExpectError + concat.assign( undefined, z ); // $ExpectError + concat.assign( [ 1 ], z ); // $ExpectError + concat.assign( {}, z ); // $ExpectError + concat.assign( ( x: number ): number => x, z ); // $ExpectError + + concat.assign( 5, z, -1 ); // $ExpectError + concat.assign( true, z, -1 ); // $ExpectError + concat.assign( false, z, -1 ); // $ExpectError + concat.assign( null, z, -1 ); // $ExpectError + concat.assign( undefined, z, -1 ); // $ExpectError + concat.assign( [ 1 ], z, -1 ); // $ExpectError + concat.assign( {}, z, -1 ); // $ExpectError + concat.assign( ( x: number ): number => x, z, -1 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a second argument which is not an ndarray... +{ + const x = zeros( [ 2, 2 ] ); + const y = zeros( [ 2, 3 ] ); + + concat.assign( [ x, y ], '5' ); // $ExpectError + concat.assign( [ x, y ], 5 ); // $ExpectError + concat.assign( [ x, y ], true ); // $ExpectError + concat.assign( [ x, y ], false ); // $ExpectError + concat.assign( [ x, y ], null ); // $ExpectError + concat.assign( [ x, y ], [ 1 ] ); // $ExpectError + concat.assign( [ x, y ], {} ); // $ExpectError + concat.assign( [ x, y ], ( x: number ): number => x ); // $ExpectError + + concat.assign( [ x, y ], '5', -1 ); // $ExpectError + concat.assign( [ x, y ], 5, -1 ); // $ExpectError + concat.assign( [ x, y ], true, -1 ); // $ExpectError + concat.assign( [ x, y ], false, -1 ); // $ExpectError + concat.assign( [ x, y ], null, -1 ); // $ExpectError + concat.assign( [ x, y ], [ 1 ], -1 ); // $ExpectError + concat.assign( [ x, y ], {}, -1 ); // $ExpectError + concat.assign( [ x, y ], ( x: number ): number => x, -1 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a third argument which is not a number... +{ + const x = zeros( [ 2, 2 ] ); + const y = zeros( [ 2, 3 ] ); + const z = zeros( [ 2, 5 ] ); + + concat.assign( [ x, y ], z, '5' ); // $ExpectError + concat.assign( [ x, y ], z, true ); // $ExpectError + concat.assign( [ x, y ], z, false ); // $ExpectError + concat.assign( [ x, y ], z, null ); // $ExpectError + concat.assign( [ x, y ], z, [ 1 ] ); // $ExpectError + concat.assign( [ x, y ], z, {} ); // $ExpectError + concat.assign( [ x, y ], z, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ] ); + const y = zeros( [ 2, 3 ] ); + const z = zeros( [ 2, 5 ] ); + + concat.assign(); // $ExpectError + concat.assign( [ x, y ] ); // $ExpectError + concat.assign( [ x, y ], z, -1, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/concat/examples/index.js b/lib/node_modules/@stdlib/ndarray/concat/examples/index.js new file mode 100644 index 000000000000..f4d99b5b9524 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/examples/index.js @@ -0,0 +1,39 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var concat = require( './../lib' ); + +var xbuf = discreteUniform( 6, 0, 10, { + 'dtype': 'generic' +}); +var x = new ndarray( 'generic', xbuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var ybuf = discreteUniform( 8, 0, 10, { + 'dtype': 'generic' +}); +var y = new ndarray( 'generic', ybuf, [ 2, 4 ], [ 4, 1 ], 0, 'row-major' ); +console.log( ndarray2array( y ) ); + +var out = concat( [ x, y ], -1 ); +console.log( ndarray2array( out ) ); diff --git a/lib/node_modules/@stdlib/ndarray/concat/lib/assign.js b/lib/node_modules/@stdlib/ndarray/concat/lib/assign.js new file mode 100644 index 000000000000..ce6deaab0129 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/lib/assign.js @@ -0,0 +1,141 @@ +/** +* @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 hasEqualValuesIndexed = require( '@stdlib/array/base/assert/has-equal-values-indexed' ); +var isMostlySafeCast = require( '@stdlib/ndarray/base/assert/is-mostly-safe-data-type-cast' ); +var isNegativeInteger = require( '@stdlib/assert/is-negative-integer' ).isPrimitive; +var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var promoteDataTypes = require( '@stdlib/ndarray/base/promote-dtypes' ); +var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); +var ndarraylike2ndarray = require( '@stdlib/ndarray/base/ndarraylike2ndarray' ); +var getShape = require( '@stdlib/ndarray/base/shape' ); +var getDType = require( '@stdlib/ndarray/base/dtype' ); +var ndims = require( '@stdlib/ndarray/base/ndims' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var normalizeArrays = require( './normalize_arrays.js' ); +var broadcastArrays = require( './broadcast_arrays.js' ); +var resolveDataTypes = require( './resolve_dtypes.js' ); +var resolveShape = require( './resolve_shape.js' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Concatenates a list of ndarrays along a specified ndarray dimension and assigns results to a provided output ndarray. +* +* @param {ArrayLikeObject} arrays - array-like object containing input ndarrays +* @param {ndarrayLike} out - output ndarray +* @param {NegativeInteger} [dim] - dimension along which to concatenate input ndarrays +* @throws {TypeError} first argument must be an array of ndarray-like objects +* @throws {RangeError} first argument must contain one or more ndarrays +* @throws {TypeError} second argument must be an ndarray-like object +* @throws {TypeError} third argument must be a negative integer +* @throws {Error} must provide ndarrays which can be safely cast to a common data type +* @returns {ndarrayLike} output ndarray +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* var xbuf = new Float64Array( [ -1.0, 2.0, -3.0, 4.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); +* +* var ybuf = new Float64Array( [ -5.0, 6.0, -7.0, 8.0, -9.0, 10.0 ] ); +* var y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); +* +* var z = new ndarray( 'float64', new Float64Array( 10 ), [ 2, 5 ], [ 5, 1 ], 0, 'row-major' ); +* +* var out = assign( [ x, y ], z, -1 ); +* // returns +* +* var bool = ( out === z ); +* // returns true +* +* var arr = ndarray2array( z ); +* // returns [ [ -1.0, 2.0, -5.0, 6.0, -7.0 ], [ -3.0, 4.0, 8.0, -9.0, 10.0 ] ] +*/ +function assign( arrays, out, dim ) { + var arrs; + var view; + var osh; + var sh; + var dt; + var d; + + if ( !isArrayLikeObject( arrays ) || arrays.length < 1 ) { + throw new TypeError( format( 'invalid argument. First argument must be an array of ndarrays. Value: `%s`.', arrays ) ); + } + if ( !isndarrayLike( out ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', out ) ); + } + if ( arguments.length > 2 ) { + if ( !isNegativeInteger( dim ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be a negative integer. Value: `%s`.', dim ) ); + } + } else { + dim = -1; + } + // Normalize the list of input ndarrays: + arrs = normalizeArrays( arrays ); + + // Normalize the output ndarray: + view = ndarraylike2ndarray( out ); + + // Broadcast the input ndarrays to a common shape: + arrs = broadcastArrays( arrs, dim ); + + // Apply type promotion rules to the data types of the input ndarrays: + dt = promoteDataTypes( resolveDataTypes( arrs ) ); + if ( dt === null ) { + throw new Error( format( 'invalid argument. Unable to apply type promotion rules when resolving a data type to which the input ndarrays can be safely cast. Data types: [%s].', join( resolveDataTypes( arrs ), ', ' ) ) ); + } + // Verify that the data types of the input ndarrays can be safely cast to the data type of the output ndarray: + if ( !isMostlySafeCast( dt, getDType( view ) ) ) { + throw new Error( format( 'invalid argument. The list of input ndarrays cannot be safely cast to the data of the output ndarray. Input data types: [%s]. Output data type: %s.', join( resolveDataTypes( arrs ), ', ' ), getDType( view ) ) ); + } + // Normalize the dimension index: + d = normalizeIndex( dim, ndims( arrs[ 0 ] )-1 ); + + // Resolve the expected shape of the output ndarray: + sh = resolveShape( arrs, d ); + + // Resolve the actual shape of the output ndarray: + osh = getShape( view, false ); + + // Verify that the expected and actual shapes are equal: + if ( !hasEqualValuesIndexed( osh, sh ) ) { + throw new TypeError( format( 'invalid argument. Second argument is not broadcast compatible with the list of input ndarrays. Array shape: (%s). Desired shape: (%s).', join( osh, ', ' ), join( sh, ', ' ) ) ); + } + // Perform concatenation: + base( arrs, d, view ); + + return out; +} + + +// EXPORTS // + +module.exports = assign; diff --git a/lib/node_modules/@stdlib/ndarray/concat/lib/base.js b/lib/node_modules/@stdlib/ndarray/concat/lib/base.js new file mode 100644 index 000000000000..d29c353f2edc --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/lib/base.js @@ -0,0 +1,94 @@ +/** +* @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 indicesComplement = require( '@stdlib/array/base/indices-complement' ); +var getShape = require( '@stdlib/ndarray/base/shape' ); +var getDType = require( '@stdlib/ndarray/base/dtype' ); +var getOrder = require( '@stdlib/ndarray/base/order' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var assign = require( '@stdlib/ndarray/base/assign' ); +var nditerStacks = require( '@stdlib/ndarray/iter/stacks' ); + + +// MAIN // + +/** +* Concatenates a list of ndarrays along a specified ndarray dimension. +* +* @private +* @param {ArrayLikeObject} arrays - array-like object containing input ndarrays +* @param {NegativeInteger} dim - dimension along which to concatenate input ndarrays +* @param {ndarray} out - output ndarray +* @returns {ndarray} output ndarray +*/ +function concat( arrays, dim, out ) { + var istacks; + var ostacks; + var offset; + var buf; + var ord; + var sh; + var dt; + var s; + var i; + var v; + + // Resolve the output ndarray shape: + sh = getShape( out, false ); + + // When concatenating one-dimensional ndarrays, opt for a faster path in which we write to output ndarray segments directly... + if ( sh.length === 1 ) { + dt = getDType( out ); + buf = getData( out ); + ord = getOrder( out ); + offset = 0; + for ( i = 0; i < arrays.length; i++ ) { + sh = getShape( arrays[ i ], false ); + v = new ndarray( dt, buf, sh, [ 1 ], offset, ord ); + assign( [ arrays[ i ], v ] ); + offset += sh[ 0 ]; + } + return out; + } + // Create iterator for iterating over subarray views within the output ndarray: + ostacks = nditerStacks( out, indicesComplement( sh.length, [ dim ] ) ); + + // Assign each input ndarray subarray to a corresponding output subarray view... + for ( i = 0; i < arrays.length; i++ ) { + sh = getShape( arrays[ i ], false ); + istacks = nditerStacks( arrays[ i ], indicesComplement( sh.length, [ dim ] ) ); // eslint-disable-line max-len + while ( true ) { + s = istacks.next(); + if ( s.done ) { + break; + } + assign( [ s.value, ostacks.next().value ] ); + } + } + return out; +} + + +// EXPORTS // + +module.exports = concat; diff --git a/lib/node_modules/@stdlib/ndarray/concat/lib/broadcast_arrays.js b/lib/node_modules/@stdlib/ndarray/concat/lib/broadcast_arrays.js new file mode 100644 index 000000000000..f51989b5783a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/lib/broadcast_arrays.js @@ -0,0 +1,72 @@ +/** +* @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 broadcastArrayExceptDimensions = require( '@stdlib/ndarray/base/broadcast-array-except-dimensions' ); // eslint-disable-line id-length +var getShape = require( '@stdlib/ndarray/base/shape' ); + + +// MAIN // + +/** +* Broadcasts a list of input ndarrays to a common shape. +* +* ## Notes +* +* - The function mutates the input array. +* +* @private +* @param {Array} arrays - list of input ndarrays +* @param {NegativeInteger} dim - dimension along which to concatenate input ndarrays +* @returns {Array} list of broadcasted ndarrays +*/ +function broadcastArrays( arrays, dim ) { + var dims; + var tmp; + var sh; + var i; + var j; + + // Find the shape of the ndarray with the most dimensions... + sh = getShape( arrays[ 0 ], false ); + j = 0; + for ( i = 1; i < arrays.length; i++ ) { + tmp = getShape( arrays[ i ], false ); + if ( tmp.length > sh.length ) { + sh = tmp; + j = i; + } + } + // Broadcast ndarrays to the shape with the most dimensions... + dims = [ dim ]; + for ( i = 0; i < arrays.length; i++ ) { + if ( i === j ) { + continue; + } + arrays[ i ] = broadcastArrayExceptDimensions( arrays[ i ], sh, dims ); + } + return arrays; +} + + +// EXPORTS // + +module.exports = broadcastArrays; diff --git a/lib/node_modules/@stdlib/ndarray/concat/lib/index.js b/lib/node_modules/@stdlib/ndarray/concat/lib/index.js new file mode 100644 index 000000000000..46ff181d902c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/lib/index.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'; + +/** +* Concatenate a list of ndarrays along a specified ndarray dimension. +* +* @module @stdlib/ndarray/concat +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var concat = require( '@stdlib/ndarray/concat' ); +* +* var xbuf = new Float64Array( [ -1.0, 2.0, -3.0, 4.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); +* +* var ybuf = new Float64Array( [ -5.0, 6.0, -7.0, 8.0, -9.0, 10.0 ] ); +* var y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); +* +* var out = concat( [ x, y ], -1 ); +* // returns +* +* var arr = ndarray2array( out ); +* // returns [ [ -1.0, 2.0, -5.0, 6.0, -7.0 ], [ -3.0, 4.0, 8.0, -9.0, 10.0 ] ] +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var assign = require( './assign.js' ); + + +// MAIN // + +setReadOnly( main, 'assign', assign ); + + +// EXPORTS // + +module.exports = main; + +// exports: { "assign": "main.assign" } diff --git a/lib/node_modules/@stdlib/ndarray/concat/lib/main.js b/lib/node_modules/@stdlib/ndarray/concat/lib/main.js new file mode 100644 index 000000000000..57bb17d0c405 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/lib/main.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 isNegativeInteger = require( '@stdlib/assert/is-negative-integer' ).isPrimitive; +var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); +var promoteDataTypes = require( '@stdlib/ndarray/base/promote-dtypes' ); +var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); +var ndims = require( '@stdlib/ndarray/base/ndims' ); +var empty = require( '@stdlib/ndarray/empty' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var normalizeArrays = require( './normalize_arrays.js' ); +var broadcastArrays = require( './broadcast_arrays.js' ); +var resolveDataTypes = require( './resolve_dtypes.js' ); +var resolveShape = require( './resolve_shape.js' ); +var resolveOrder = require( './resolve_order.js' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Concatenates a list of ndarrays along a specified ndarray dimension. +* +* @param {ArrayLikeObject} arrays - array-like object containing input ndarrays +* @param {NegativeInteger} [dim] - dimension along which to concatenate input ndarrays +* @throws {TypeError} first argument must be an array of ndarray-like objects +* @throws {RangeError} first argument must contain one or more ndarrays +* @throws {TypeError} second argument must be a negative integer +* @throws {Error} must provide ndarrays which can be safely cast to a common data type +* @returns {ndarray} output ndarray +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* var xbuf = new Float64Array( [ -1.0, 2.0, -3.0, 4.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); +* +* var ybuf = new Float64Array( [ -5.0, 6.0, -7.0, 8.0, -9.0, 10.0 ] ); +* var y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); +* +* var out = concat( [ x, y ], -1 ); +* // returns +* +* var arr = ndarray2array( out ); +* // returns [ [ -1.0, 2.0, -5.0, 6.0, -7.0 ], [ -3.0, 4.0, 8.0, -9.0, 10.0 ] ] +*/ +function concat( arrays, dim ) { + var arrs; + var out; + var dt; + var d; + + if ( !isArrayLikeObject( arrays ) || arrays.length < 1 ) { + throw new TypeError( format( 'invalid argument. First argument must be an array of ndarrays. Value: `%s`.', arrays ) ); + } + if ( arguments.length > 1 ) { + if ( !isNegativeInteger( dim ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a negative integer. Value: `%s`.', dim ) ); + } + } else { + dim = -1; + } + // Normalize the list of input ndarrays: + arrs = normalizeArrays( arrays ); + + // Broadcast the input ndarrays to a common shape: + arrs = broadcastArrays( arrs, dim ); + + // Resolve the data type of the output ndarray by applying type promotion rules to the data types of the input ndarrays: + dt = promoteDataTypes( resolveDataTypes( arrs ) ); + if ( dt === null ) { + throw new Error( format( 'invalid argument. Unable to apply type promotion rules when resolving a data type to which the input ndarrays can be safely cast. Data types: [%s].', join( resolveDataTypes( arrs ), ', ' ) ) ); + } + // Normalize the dimension index: + d = normalizeIndex( dim, ndims( arrs[ 0 ] )-1 ); + + // Create an output ndarray: + out = empty( resolveShape( arrs, d ), { + 'dtype': dt, + 'order': resolveOrder( arrs ) + }); + + // Perform concatenation: + return base( arrs, d, out ); +} + + +// EXPORTS // + +module.exports = concat; diff --git a/lib/node_modules/@stdlib/ndarray/concat/lib/normalize_arrays.js b/lib/node_modules/@stdlib/ndarray/concat/lib/normalize_arrays.js new file mode 100644 index 000000000000..766b71c48acd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/lib/normalize_arrays.js @@ -0,0 +1,55 @@ +/** +* @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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var ndarraylike2ndarray = require( '@stdlib/ndarray/base/ndarraylike2ndarray' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Normalizes a list of ndarray-like objects. +* +* @private +* @param {Array} arrays - list of input ndarrays +* @throws {TypeError} first argument must be an array of ndarrays +* @returns {Array} list of ndarrays +*/ +function normalize( arrays ) { + var out; + var i; + + out = []; + for ( i = 0; i < arrays.length; i++ ) { + if ( !isndarrayLike( arrays[ i ] ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an array of ndarrays. Value: `%s`.', arrays[ i ] ) ); + } + out.push( ndarraylike2ndarray( arrays[ i ] ) ); + } + return out; +} + + +// EXPORTS // + +module.exports = normalize; diff --git a/lib/node_modules/@stdlib/ndarray/concat/lib/resolve_dtypes.js b/lib/node_modules/@stdlib/ndarray/concat/lib/resolve_dtypes.js new file mode 100644 index 000000000000..9e3f771e23af --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/lib/resolve_dtypes.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'; + +// MODULES // + +var getDType = require( '@stdlib/ndarray/base/dtype' ); + + +// MAIN // + +/** +* Resolves a list of ndarray data types from a list of ndarrays. +* +* @private +* @param {Array} arrays - list of input ndarrays +* @returns {Array} list of data types +*/ +function resolveDataTypes( arrays ) { + var out; + var i; + + out = []; + for ( i = 0; i < arrays.length; i++ ) { + out.push( getDType( arrays[ i ] ) ); + } + return out; +} + + +// EXPORTS // + +module.exports = resolveDataTypes; diff --git a/lib/node_modules/@stdlib/ndarray/concat/lib/resolve_order.js b/lib/node_modules/@stdlib/ndarray/concat/lib/resolve_order.js new file mode 100644 index 000000000000..85da333045e4 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/lib/resolve_order.js @@ -0,0 +1,60 @@ +/** +* @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 getOrder = require( '@stdlib/ndarray/base/order' ); +var defaults = require( '@stdlib/ndarray/defaults' ); + + +// VARIABLES // + +var DEFAULT_ORDER = defaults.get( 'order' ); + + +// MAIN // + +/** +* Resolves the order (i.e. memory layout) of an output ndarray according to a list of input ndarrays. +* +* @private +* @param {Array} arrays - list of input ndarrays +* @returns {string} order +*/ +function resolveOrder( arrays ) { + var o; + var i; + + // Resolve the order of the first ndarray: + o = getOrder( arrays[ 0 ] ); + + // If a subsequent input ndarray has a different order, return the default memory layout... + for ( i = 1; i < arrays.length; i++ ) { + if ( getOrder( arrays[ i ] ) !== o ) { + return DEFAULT_ORDER; + } + } + return o; +} + + +// EXPORTS // + +module.exports = resolveOrder; diff --git a/lib/node_modules/@stdlib/ndarray/concat/lib/resolve_shape.js b/lib/node_modules/@stdlib/ndarray/concat/lib/resolve_shape.js new file mode 100644 index 000000000000..7cb53d0527a0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/lib/resolve_shape.js @@ -0,0 +1,53 @@ +/** +* @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 getShape = require( '@stdlib/ndarray/base/shape' ); + + +// MAIN // + +/** +* Resolves the shape of an output ndarray according to a list of input ndarrays. +* +* @private +* @param {Array} arrays - list of input ndarrays +* @param {integer} dim - dimension along which to concatenate input ndarrays +* @returns {Array} shape +*/ +function resolveShape( arrays, dim ) { + var sh; + var i; + + // Resolve the shape of the first ndarray: + sh = getShape( arrays[ 0 ], true ); + + // Expand the concatenation dimension in order to accommodate other input ndarrays... + for ( i = 1; i < arrays.length; i++ ) { + sh[ dim ] += getShape( arrays[ i ], false )[ dim ]; + } + return sh; +} + + +// EXPORTS // + +module.exports = resolveShape; diff --git a/lib/node_modules/@stdlib/ndarray/concat/package.json b/lib/node_modules/@stdlib/ndarray/concat/package.json new file mode 100644 index 000000000000..b3a03ed1ee7d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/ndarray/concat", + "version": "0.0.0", + "description": "Concatenate a list of ndarrays along a specified ndarray dimension.", + "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", + "stdtypes", + "types", + "data", + "structure", + "matrix", + "vector", + "ndarray", + "multidimensional", + "array", + "concatenate", + "join", + "concat", + "stack" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/concat/test/test.assign.js b/lib/node_modules/@stdlib/ndarray/concat/test/test.assign.js new file mode 100644 index 000000000000..823a4e4941b1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/test/test.assign.js @@ -0,0 +1,669 @@ +/** +* @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 ndarray = require( '@stdlib/ndarray/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var empty = require( '@stdlib/ndarray/empty' ); +var assign = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof assign, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an array of ndarrays', function test( t ) { + var values; + var out; + var i; + + out = zeros( [ 2, 2 ] ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + [ 'beep', 'boop' ], + [ 1, 2, 3 ], + [ null ], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, out ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an array of ndarrays (dim)', function test( t ) { + var values; + var out; + var i; + + out = zeros( [ 2, 2 ] ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + [ 'beep', 'boop' ], + [ 1, 2, 3 ], + [ null ], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, out, -1 ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument containing ndarrays which do not promote to a common data type', function test( t ) { + var values; + var out; + var i; + + values = [ + [ + empty( [ 2 ], { + 'dtype': 'bool' + }), + empty( [ 2 ], { + 'dtype': 'float64' + }) + ] + ]; + out = zeros( [ 4 ], { + 'dtype': 'float64' + }); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, out ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument containing ndarrays which do not promote to a common data type (dim)', function test( t ) { + var values; + var out; + var i; + + values = [ + [ + empty( [ 2 ], { + 'dtype': 'bool' + }), + empty( [ 2 ], { + 'dtype': 'float64' + }) + ] + ]; + out = zeros( [ 4 ], { + 'dtype': 'float64' + }); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, out, -1 ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument containing ndarrays which are not broadcast compatible', function test( t ) { + var values; + var out; + var i; + + values = [ + [ + empty( [ 3, 2 ], { + 'dtype': 'float64' + }), + empty( [ 2, 2 ], { + 'dtype': 'float64' + }) + ] + ]; + out = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, out ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument containing ndarrays which are not broadcast compatible (dim)', function test( t ) { + var values; + var out; + var i; + + values = [ + [ + empty( [ 3, 2 ], { + 'dtype': 'float64' + }), + empty( [ 2, 2 ], { + 'dtype': 'float64' + }) + ] + ]; + out = zeros( [ 5, 4 ], { + 'dtype': 'float64' + }); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, out, -1 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ] ); + y = zeros( [ 2, 2 ] ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( [ x, y ], value ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray (dim)', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ] ); + y = zeros( [ 2, 2 ] ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( [ x, y ], value, -1 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which has a data type to which input ndarrays cannot be safely cast', function test( t ) { + var values; + var out; + var i; + + values = [ + [ + empty( [ 2 ], { + 'dtype': 'float32' + }), + empty( [ 2 ], { + 'dtype': 'float64' + }) + ] + ]; + out = zeros( [ 4 ], { + 'dtype': 'bool' + }); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, out ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which has a data type to which input ndarrays cannot be safely cast (dim)', function test( t ) { + var values; + var out; + var i; + + values = [ + [ + empty( [ 2 ], { + 'dtype': 'float32' + }), + empty( [ 2 ], { + 'dtype': 'float64' + }) + ] + ]; + out = zeros( [ 4 ], { + 'dtype': 'bool' + }); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, out, -1 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument having an invalid shape', function test( t ) { + var values; + var out; + var i; + + values = [ + [ + empty( [ 2 ], { + 'dtype': 'float64' + }), + empty( [ 2 ], { + 'dtype': 'float64' + }) + ] + ]; + out = zeros( [ 10 ], { + 'dtype': 'float64' + }); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, out ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument having an invalid shape (dim)', function test( t ) { + var values; + var out; + var i; + + values = [ + [ + empty( [ 2 ], { + 'dtype': 'float64' + }), + empty( [ 2 ], { + 'dtype': 'float64' + }) + ] + ]; + out = zeros( [ 10 ], { + 'dtype': 'float64' + }); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( value, out, -1 ); + }; + } +}); + +tape( 'the function throws an error if provided a third argument which is not a negative integer', function test( t ) { + var values; + var x; + var y; + var z; + var i; + + x = zeros( [ 2, 2 ] ); + y = zeros( [ 2, 2 ] ); + z = zeros( [ 2, 4 ] ); + + values = [ + '5', + 5.5, + 0, + 1, + 2, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( [ x, y ], z, value ); + }; + } +}); + +tape( 'the function concatenates ndarrays along a specified dimension', function test( t ) { + var expected; + var actual; + var xbuf; + var ybuf; + var out; + var x; + var y; + var z; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); + + z = zeros( [ 2, 5 ], { + 'dtype': 'float64' + }); + + out = assign( [ x, y ], z ); + + actual = ndarray2array( z ); + expected = [ + [ 1.0, 2.0, 5.0, 6.0, 7.0 ], + [ 3.0, 4.0, 8.0, 9.0, 10.0 ] + ]; + + t.strictEqual( out, z, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); + + z = zeros( [ 2, 5 ], { + 'dtype': 'float64' + }); + + out = assign( [ x, y ], z, -1 ); + + actual = ndarray2array( z ); + expected = [ + [ 1.0, 2.0, 5.0, 6.0, 7.0 ], + [ 3.0, 4.0, 8.0, 9.0, 10.0 ] + ]; + + t.strictEqual( out, z, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 5.0, 6.0, 7.0, 8.0 ] ); + y = new ndarray( 'float64', ybuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + z = zeros( [ 4, 2 ], { + 'dtype': 'float64' + }); + + out = assign( [ x, y ], z, -2 ); + + actual = ndarray2array( z ); + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ]; + + t.strictEqual( out, z, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + z = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + out = assign( [ x ], z, -1 ); + + actual = ndarray2array( z ); + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ] + ]; + + t.strictEqual( out, z, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function concatenates ndarrays along a specified dimension (type promotion)', function test( t ) { + var expected; + var actual; + var xbuf; + var ybuf; + var out; + var x; + var y; + var z; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 5.0, 6.0, 7.0, 8.0 ] ); + y = new ndarray( 'float64', ybuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + z = zeros( [ 2, 4 ], { + 'dtype': 'float32' + }); + + out = assign( [ x, y ], z, -1 ); + + actual = ndarray2array( z ); + expected = [ + [ 1.0, 2.0, 5.0, 6.0 ], + [ 3.0, 4.0, 7.0, 8.0 ] + ]; + + t.strictEqual( out, z, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function concatenates ndarray along a specified dimension (broadcasting)', function test( t ) { + var expected; + var actual; + var xbuf; + var ybuf; + var out; + var x; + var y; + var z; + + xbuf = new Float64Array( [ 1.0, 2.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2 ], [ 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 3.0, 4.0, 5.0, 6.0 ] ); + y = new ndarray( 'float64', ybuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + z = zeros( [ 2, 4 ], { + 'dtype': 'float64' + }); + + out = assign( [ x, y ], z, -1 ); + actual = ndarray2array( z ); + expected = [ + [ 1.0, 2.0, 3.0, 4.0 ], + [ 1.0, 2.0, 5.0, 6.0 ] + ]; + + t.strictEqual( out, z, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function concatenates ndarrays along a specified dimension (ndims=1)', function test( t ) { + var expected; + var actual; + var xbuf; + var ybuf; + var out; + var x; + var y; + var z; + + xbuf = new Float64Array( [ 1.0, 2.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2 ], [ 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 3.0, 4.0, 5.0 ] ); + y = new ndarray( 'float64', ybuf, [ 3 ], [ 1 ], 0, 'row-major' ); + + z = zeros( [ 5 ], { + 'dtype': 'float64' + }); + + out = assign( [ x, y ], z ); + + actual = ndarray2array( z ); + expected = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + + t.strictEqual( out, z, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + z = zeros( [ 5 ], { + 'dtype': 'float64' + }); + + out = assign( [ x, y ], z, -1 ); + + actual = ndarray2array( z ); + expected = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + + t.strictEqual( out, z, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/concat/test/test.js b/lib/node_modules/@stdlib/ndarray/concat/test/test.js new file mode 100644 index 000000000000..e85cd1995432 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/test/test.js @@ -0,0 +1,39 @@ +/** +* @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 isMethod = require( '@stdlib/assert/is-method' ); +var concat = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof concat, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( isMethod( concat, 'assign' ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/concat/test/test.main.js b/lib/node_modules/@stdlib/ndarray/concat/test/test.main.js new file mode 100644 index 000000000000..19da2b8b1196 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/concat/test/test.main.js @@ -0,0 +1,456 @@ +/** +* @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 resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var getOrder = require( '@stdlib/ndarray/order' ); +var defaults = require( '@stdlib/ndarray/defaults' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var empty = require( '@stdlib/ndarray/empty' ); +var concat = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof concat, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an array of ndarrays', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + [ 'beep', 'boop' ], + [ 1, 2, 3 ], + [ null ], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + concat( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an array of ndarrays (dim)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + [ 'beep', 'boop' ], + [ 1, 2, 3 ], + [ null ], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + concat( value, -1 ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument containing ndarrays which do not promote to a common data type', function test( t ) { + var values; + var i; + + values = [ + [ + empty( [ 2 ], { + 'dtype': 'bool' + }), + empty( [ 2 ], { + 'dtype': 'float64' + }) + ] + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + concat( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument containing ndarrays which do not promote to a common data type (dim)', function test( t ) { + var values; + var i; + + values = [ + [ + empty( [ 2 ], { + 'dtype': 'bool' + }), + empty( [ 2 ], { + 'dtype': 'float64' + }) + ] + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + concat( value, -1 ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument containing ndarrays which are not broadcast compatible', function test( t ) { + var values; + var i; + + values = [ + [ + empty( [ 3, 2 ], { + 'dtype': 'float64' + }), + empty( [ 2, 2 ], { + 'dtype': 'float64' + }) + ] + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + concat( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument containing ndarrays which are not broadcast compatible (dim)', function test( t ) { + var values; + var i; + + values = [ + [ + empty( [ 3, 2 ], { + 'dtype': 'float64' + }), + empty( [ 2, 2 ], { + 'dtype': 'float64' + }) + ] + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + concat( value, -1 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not a negative integer', function test( t ) { + var values; + var x; + var y; + var i; + + x = zeros( [ 2, 2 ] ); + y = zeros( [ 2, 2 ] ); + + values = [ + '5', + 5.5, + 0, + 1, + 2, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + concat( [ x, y ], value ); + }; + } +}); + +tape( 'the function concatenates ndarrays along a specified dimension', function test( t ) { + var expected; + var actual; + var xbuf; + var ybuf; + var out; + var x; + var y; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); + + out = concat( [ x, y ] ); + + actual = ndarray2array( out ); + expected = [ + [ 1.0, 2.0, 5.0, 6.0, 7.0 ], + [ 3.0, 4.0, 8.0, 9.0, 10.0 ] + ]; + + t.strictEqual( resolveStr( getDType( out ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( out ), [ 2, 5 ], 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 3, 1 ], 0, 'row-major' ); + + out = concat( [ x, y ], -1 ); + + actual = ndarray2array( out ); + expected = [ + [ 1.0, 2.0, 5.0, 6.0, 7.0 ], + [ 3.0, 4.0, 8.0, 9.0, 10.0 ] + ]; + + t.strictEqual( resolveStr( getDType( out ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( out ), [ 2, 5 ], 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 5.0, 6.0, 7.0, 8.0 ] ); + y = new ndarray( 'float64', ybuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + out = concat( [ x, y ], -2 ); + + actual = ndarray2array( out ); + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ]; + + t.strictEqual( resolveStr( getDType( out ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( out ), [ 4, 2 ], 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + out = concat( [ x ], -1 ); + + actual = ndarray2array( out ); + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ] + ]; + + t.strictEqual( resolveStr( getDType( out ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( out ), [ 2, 2 ], 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function concatenates ndarrays along a specified dimension (different orders)', function test( t ) { + var expected; + var actual; + var xbuf; + var ybuf; + var out; + var x; + var y; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + y = new ndarray( 'float64', ybuf, [ 2, 3 ], [ 1, 2 ], 0, 'column-major' ); + + out = concat( [ x, y ] ); + + actual = ndarray2array( out ); + expected = [ + [ 1.0, 2.0, 5.0, 7.0, 9.0 ], + [ 3.0, 4.0, 6.0, 8.0, 10.0 ] + ]; + + t.strictEqual( resolveStr( getDType( out ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( out ), [ 2, 5 ], 'returns expected value' ); + t.strictEqual( getOrder( out ), defaults.get( 'order' ), 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function concatenates ndarrays along a specified dimension (type promotion)', function test( t ) { + var expected; + var actual; + var xbuf; + var ybuf; + var out; + var x; + var y; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + ybuf = new Int32Array( [ 5, 6, 7, 8 ] ); + y = new ndarray( 'int32', ybuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + out = concat( [ x, y ], -1 ); + + actual = ndarray2array( out ); + expected = [ + [ 1.0, 2.0, 5.0, 6.0 ], + [ 3.0, 4.0, 7.0, 8.0 ] + ]; + + t.strictEqual( resolveStr( getDType( out ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( out ), [ 2, 4 ], 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function concatenates ndarray along a specified dimension (broadcasting)', function test( t ) { + var expected; + var actual; + var xbuf; + var ybuf; + var out; + var x; + var y; + + xbuf = new Float64Array( [ 1.0, 2.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2 ], [ 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 3.0, 4.0, 5.0, 6.0 ] ); + y = new ndarray( 'float64', ybuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + out = concat( [ x, y ], -1 ); + actual = ndarray2array( out ); + expected = [ + [ 1.0, 2.0, 3.0, 4.0 ], + [ 1.0, 2.0, 5.0, 6.0 ] + ]; + t.strictEqual( resolveStr( getDType( out ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( out ), [ 2, 4 ], 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function concatenates ndarrays along a specified dimension (ndims=1)', function test( t ) { + var expected; + var xbuf; + var ybuf; + var out; + var x; + var y; + + xbuf = new Float64Array( [ 1.0, 2.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2 ], [ 1 ], 0, 'row-major' ); + + ybuf = new Float64Array( [ 3.0, 4.0, 5.0 ] ); + y = new ndarray( 'float64', ybuf, [ 3 ], [ 1 ], 0, 'row-major' ); + + out = concat( [ x, y ] ); + expected = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + + t.strictEqual( resolveStr( getDType( out ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( out ), [ 5 ], 'returns expected value' ); + t.deepEqual( ndarray2array( out ), expected, 'returns expected value' ); + + out = concat( [ x, y ], -1 ); + expected = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + + t.strictEqual( resolveStr( getDType( out ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( out ), [ 5 ], 'returns expected value' ); + t.deepEqual( ndarray2array( out ), expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/dtype/README.md b/lib/node_modules/@stdlib/ndarray/dtype/README.md index 7c89d06dcb02..8768ac77306d 100644 --- a/lib/node_modules/@stdlib/ndarray/dtype/README.md +++ b/lib/node_modules/@stdlib/ndarray/dtype/README.md @@ -112,7 +112,7 @@ var s; var i; for ( i = 0; i < slices.length; i++ ) { s = slice( x, slices[ i ] ); - console.log( '%s => %s', s.dtype, dtype( s ) ); + console.log( '%s => %s', dtype( x ), dtype( s ) ); } ``` diff --git a/lib/node_modules/@stdlib/ndarray/dtype/examples/index.js b/lib/node_modules/@stdlib/ndarray/dtype/examples/index.js index a0dd118ed9e0..fa2a05ad2d81 100644 --- a/lib/node_modules/@stdlib/ndarray/dtype/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/dtype/examples/index.js @@ -53,5 +53,5 @@ var s; var i; for ( i = 0; i < slices.length; i++ ) { s = slice( x, slices[ i ] ); - console.log( '%s => %s', s.dtype, dtype( s ) ); + console.log( '%s => %s', dtype( x ), dtype( s ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/README.md b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/README.md new file mode 100644 index 000000000000..5383c2315d18 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/README.md @@ -0,0 +1,30 @@ + + +# Half-Normal Distribution (PDF only) + +> Probability Density Function (PDF) of the half-normal distribution. + + +## Usage + +```javascript +var pdf = require( '@stdlib/stats/base/dists/halfnormal' ).pdf; + +var y = pdf( 1.0, 1.0 ); +console.log( y ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js new file mode 100644 index 000000000000..db8ad922218f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js @@ -0,0 +1,17 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2016-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. +*/ diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/pdf.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/pdf.js new file mode 100644 index 000000000000..4ae9f4ae6ae1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/pdf.js @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2016-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 sqrt = require('@stdlib/math/base/special/sqrt'); +var exp = require('@stdlib/math/base/special/exp'); +var pow = require('@stdlib/math/base/special/pow'); +var PI = require('@stdlib/constants/float64/pi'); +// var TWO = require('@stdlib/constants/float64/two'); +const TWO = 2.0; + +function pdf(x, sigma) { + if (sigma <= 0.0) { + return NaN; + } + if (x < 0.0) { + return 0.0; + } + return sqrt(TWO / (PI * pow(sigma, 2))) * exp(-pow(x, 2) / (TWO * pow(sigma, 2))); +} + +module.exports = pdf; + diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/test/test.pdf.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/test/test.pdf.js new file mode 100644 index 000000000000..eef6b998dc8c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/test/test.pdf.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2016-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 tape = require('tape'); +var pdf = require('../lib/pdf.js'); +var isnan = require('@stdlib/math/base/assert/is-nan'); + +tape('main export is a function', function(t) { + t.equal(typeof pdf, 'function', 'main export is a function'); + t.end(); +}); + +tape('returns NaN if sigma <= 0', function(t) { + t.equal(isnan(pdf(1.0, 0.0)), true, 'sigma = 0 returns NaN'); + t.equal(isnan(pdf(1.0, -1.0)), true, 'negative sigma returns NaN'); + t.end(); +}); + +tape('pdf is zero for x < 0', function(t) { + t.equal(pdf(-0.5, 1.0), 0.0, 'x < 0 returns 0'); + t.end(); +}); + +tape('pdf evaluates half-normal distribution for valid inputs', function(t) { + var sigma = 1.0; + var xs = [0.0, 0.5, 1.0, 2.0]; + for (var i = 0; i < xs.length; i++) { + var v = pdf(xs[i], sigma); + t.ok(v >= 0, 'pdf(' + xs[i] + ',1.0) = ' + v); + } + t.end(); +}); +