From f6362fcc8605d7217068212c7b9f2066a55da614 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Tue, 15 Jul 2025 05:28:46 +0000 Subject: [PATCH 1/7] feat: add ndarray/base/any-by --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/base/any-by/README.md | 208 +++ .../benchmark/benchmark.1d_columnmajor.js | 132 ++ .../any-by/benchmark/benchmark.1d_rowmajor.js | 132 ++ .../benchmark.2d_blocked_columnmajor.js | 144 ++ .../benchmark.2d_blocked_rowmajor.js | 144 ++ .../benchmark/benchmark.2d_columnmajor.js | 144 ++ .../any-by/benchmark/benchmark.2d_rowmajor.js | 144 ++ .../benchmark.2d_rowmajor_accessors.js | 170 ++ .../benchmark.3d_blocked_columnmajor.js | 144 ++ .../benchmark.3d_blocked_rowmajor.js | 144 ++ .../benchmark/benchmark.3d_columnmajor.js | 144 ++ .../any-by/benchmark/benchmark.3d_rowmajor.js | 144 ++ .../@stdlib/ndarray/base/any-by/docs/repl.txt | 73 + .../ndarray/base/any-by/docs/types/index.d.ts | 109 ++ .../ndarray/base/any-by/docs/types/test.ts | 99 ++ .../ndarray/base/any-by/examples/index.js | 42 + .../@stdlib/ndarray/base/any-by/lib/0d.js | 83 + .../ndarray/base/any-by/lib/0d_accessors.js | 86 + .../@stdlib/ndarray/base/any-by/lib/1d.js | 105 ++ .../ndarray/base/any-by/lib/1d_accessors.js | 112 ++ .../@stdlib/ndarray/base/any-by/lib/2d.js | 136 ++ .../ndarray/base/any-by/lib/2d_accessors.js | 143 ++ .../ndarray/base/any-by/lib/2d_blocked.js | 162 ++ .../base/any-by/lib/2d_blocked_accessors.js | 169 ++ .../@stdlib/ndarray/base/any-by/lib/3d.js | 146 ++ .../ndarray/base/any-by/lib/3d_accessors.js | 153 ++ .../ndarray/base/any-by/lib/3d_blocked.js | 183 ++ .../base/any-by/lib/3d_blocked_accessors.js | 190 +++ .../@stdlib/ndarray/base/any-by/lib/index.js | 69 + .../@stdlib/ndarray/base/any-by/lib/main.js | 167 ++ .../@stdlib/ndarray/base/any-by/lib/nd.js | 127 ++ .../ndarray/base/any-by/lib/nd_accessors.js | 134 ++ .../@stdlib/ndarray/base/any-by/package.json | 66 + .../ndarray/base/any-by/test/test.0d.js | 87 + .../ndarray/base/any-by/test/test.1d.js | 202 +++ .../ndarray/base/any-by/test/test.2d.js | 1285 ++++++++++++++ .../ndarray/base/any-by/test/test.3d.js | 1479 +++++++++++++++++ .../@stdlib/ndarray/base/any-by/test/test.js | 51 + .../ndarray/base/any-by/test/test.nd.js | 1040 ++++++++++++ 39 files changed, 8492 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.1d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.1d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_rowmajor_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.0d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.1d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.2d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.3d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.nd.js diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/README.md b/lib/node_modules/@stdlib/ndarray/base/any-by/README.md new file mode 100644 index 000000000000..ee3ac0da1aea --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/README.md @@ -0,0 +1,208 @@ + + +# anyBy + +> Test whether at least one element in an ndarray pass a test implemented by a predicate function. + +
+ +
+ + + +
+ +## Usage + +```javascript +var anyBy = require( '@stdlib/ndarray/base/any-by' ); +``` + +#### anyBy( arrays, predicate\[, thisArg] ) + +Tests whether at least one element in an ndarray pass a test implemented by a predicate function. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +function clbk( value ) { + return value > 0.0; +} + +// 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 = 0; + +// Create the input ndarray-like object: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +// Test elements: +var out = anyBy( [ x ], clbk ); +// returns true +``` + +The function accepts the following arguments: + +- **arrays**: array-like object containing an input ndarray. +- **predicate**: predicate function. +- **thisArg**: predicate function execution context (_optional_). + +The 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). + +The predicate function is provided the following arguments: + +- **value**: current array element. +- **indices**: current array element indices. +- **arr**: the input ndarray. + +To set the predicate function execution context, provide a `thisArg`. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +function clbk( value ) { + this.count += 1; + return value < 0.0; +} + +// 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 = 0; + +// Create the input ndarray-like object: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': sx, + 'offset': ox, + 'order': 'row-major' +}; + +var ctx = { + 'count': 0 +}; + +// Test elements: +var out = anyBy( [ x ], clbk, ctx ); +// returns false + +var count = ctx.count; +// returns 6 +``` + +
+ + + +
+ +## 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. +- If provided an empty ndarray, the function returns `false`. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var anyBy = require( '@stdlib/ndarray/base/any-by' ); + +function clbk( value ) { + return value > 0; +} + +var x = { + 'dtype': 'generic', + 'data': discreteUniform( 10, -5, 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 out = anyBy( [ x ], clbk ); +console.log( out ); +``` + +
+ + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.1d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.1d_columnmajor.js new file mode 100644 index 000000000000..e906de1eded6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.1d_columnmajor.js @@ -0,0 +1,132 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var anyBy = require( './../lib' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( [ x ], clbk ); + 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/any-by/benchmark/benchmark.1d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.1d_rowmajor.js new file mode 100644 index 000000000000..0f7b498e503a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.1d_rowmajor.js @@ -0,0 +1,132 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var anyBy = require( './../lib' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( [ x ], clbk ); + 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/any-by/benchmark/benchmark.2d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_blocked_columnmajor.js new file mode 100644 index 000000000000..b732297243d4 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_blocked_columnmajor.js @@ -0,0 +1,144 @@ +/** +* @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 anyBy = require( './../lib/2d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.2d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_blocked_rowmajor.js new file mode 100644 index 000000000000..6fe3443a0aca --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_blocked_rowmajor.js @@ -0,0 +1,144 @@ +/** +* @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 anyBy = require( './../lib/2d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.2d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_columnmajor.js new file mode 100644 index 000000000000..f6bd61f79b17 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_columnmajor.js @@ -0,0 +1,144 @@ +/** +* @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 anyBy = require( './../lib/2d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.2d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_rowmajor.js new file mode 100644 index 000000000000..ebaf2dcc8fcb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_rowmajor.js @@ -0,0 +1,144 @@ +/** +* @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 anyBy = require( './../lib/2d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.2d_rowmajor_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_rowmajor_accessors.js new file mode 100644 index 000000000000..3e048782170f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.2d_rowmajor_accessors.js @@ -0,0 +1,170 @@ +/** +* @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 anyBy = require( './../lib/2d_accessors.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.3d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_blocked_columnmajor.js new file mode 100644 index 000000000000..b2de411a2d5f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_blocked_columnmajor.js @@ -0,0 +1,144 @@ +/** +* @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 anyBy = require( './../lib/3d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.3d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_blocked_rowmajor.js new file mode 100644 index 000000000000..24e484d37256 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_blocked_rowmajor.js @@ -0,0 +1,144 @@ +/** +* @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 anyBy = require( './../lib/3d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.3d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_columnmajor.js new file mode 100644 index 000000000000..31e3bb3edae0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_columnmajor.js @@ -0,0 +1,144 @@ +/** +* @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 anyBy = require( './../lib/3d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.3d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_rowmajor.js new file mode 100644 index 000000000000..cbc3c2d7ad91 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.3d_rowmajor.js @@ -0,0 +1,144 @@ +/** +* @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 anyBy = require( './../lib/3d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/repl.txt new file mode 100644 index 000000000000..083e0eeb86b5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/repl.txt @@ -0,0 +1,73 @@ + +{{alias}}( arrays, predicate[, thisArg] ) + Tests whether at least one element in an ndarray pass a test implemented by + a predicate function. + + 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). + + The predicate function is provided the following arguments: + + - value: current array element. + - indices: current array element indices. + - arr: the input ndarray. + + If provided an empty ndarray, the function returns `false`. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing an input ndarray. + + predicate: Function + Predicate function. + + thisArg: any (optional) + Predicate function execution context. + + Returns + ------- + out: boolean + Boolean indicating whether at least one element in an ndarray pass a + test implemented by a predicate function. + + Examples + -------- + // Define ndarray data and meta data... + > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0, 1.0, 1.0 ] ); + > var dt = 'float64'; + > var sh = [ 2, 2 ]; + > var sx = [ 2, 1 ]; + > var ox = 0; + > var ord = 'row-major'; + + // Define a callback... + > function clbk( v ) { return v > 0.0; }; + + // Using an ndarray... + > var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); + > {{alias}}( [ x ], clbk ) + true + + // Using a minimal ndarray-like object... + > xbuf = new {{alias:@stdlib/array/float64}}( [ -1.0, -1.0, -1.0, 0.0 ] ); + > x = { + ... 'dtype': dt, + ... 'data': xbuf, + ... 'shape': sh, + ... 'strides': sx, + ... 'offset': ox, + ... 'order': ord + ... }; + > {{alias}}( [ x ], clbk ) + false + + See Also + -------- diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts new file mode 100644 index 000000000000..aeaa5b0525a6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts @@ -0,0 +1,109 @@ +/* +* @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'; + +/** +* Returns a boolean indicating whether an element passes a test. +* +* @returns boolean indicating whether an ndarray element passes a test +*/ +type Nullary = ( this: U ) => boolean; + +/** +* Returns a boolean indicating whether an element passes a test. +* +* @param value - current array element +* @returns boolean indicating whether an ndarray element passes a test +*/ +type Unary = ( this: U, value: T ) => boolean; + +/** +* Returns a boolean indicating whether an element passes a test. +* +* @param value - current array element +* @param indices - current array element indices +* @returns boolean indicating whether an ndarray element passes a test +*/ +type Binary = ( this: U, value: T, indices: Array ) => boolean; + +/** +* Returns a boolean indicating whether an element passes a test. +* +* @param value - current array element +* @param indices - current array element indices +* @param arr - input array +* @returns boolean indicating whether an ndarray element passes a test +*/ +type Ternary = ( this: U, value: T, indices: Array, arr: typedndarray ) => boolean; + +/** +* Returns a boolean indicating whether an element passes a test. +* +* @param value - current array element +* @param indices - current array element indices +* @param arr - input array +* @returns boolean indicating whether an ndarray element passes a test +*/ +type Predicate = Nullary | Unary | Binary | Ternary; + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* +* @param arrays - array-like object containing an input ndarray +* @param predicate - predicate function +* @param thisArg - predicate function execution context +* @returns boolean indicating whether at least one element pass a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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' ); +* +* // Test elements: +* var out = anyBy( [ x ], predicate ); +* // returns true +*/ +declare function anyBy( arrays: ArrayLike>, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; + + +// EXPORTS // + +export = anyBy; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/test.ts new file mode 100644 index 000000000000..bc686c5c5b4c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/test.ts @@ -0,0 +1,99 @@ +/* +* @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 anyBy = require( './index' ); + +/** +* Predicate function. +* +* @param v - ndarray element +* @returns result +*/ +function clbk( v: any ): boolean { + return v > 0.0; +} + + +// TESTS // + +// The function returns a boolean... +{ + const x = zeros( [ 2, 2 ] ); + const arrays = [ x ]; + + anyBy( arrays, clbk ); // $ExpectType boolean + anyBy( arrays, clbk, {} ); // $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... +{ + anyBy( 5, clbk ); // $ExpectError + anyBy( true, clbk ); // $ExpectError + anyBy( false, clbk ); // $ExpectError + anyBy( null, clbk ); // $ExpectError + anyBy( undefined, clbk ); // $ExpectError + anyBy( {}, clbk ); // $ExpectError + anyBy( [ 1 ], clbk ); // $ExpectError + anyBy( ( x: number ): number => x, clbk ); // $ExpectError + + anyBy( 5, clbk, {} ); // $ExpectError + anyBy( true, clbk, {} ); // $ExpectError + anyBy( false, clbk, {} ); // $ExpectError + anyBy( null, clbk, {} ); // $ExpectError + anyBy( undefined, clbk, {} ); // $ExpectError + anyBy( {}, clbk, {} ); // $ExpectError + anyBy( [ 1 ], clbk, {} ); // $ExpectError + anyBy( ( x: number ): number => x, clbk, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a callback function... +{ + const x = zeros( [ 2, 2 ] ); + const arrays = [ x ]; + + anyBy( arrays, '10' ); // $ExpectError + anyBy( arrays, 5 ); // $ExpectError + anyBy( arrays, true ); // $ExpectError + anyBy( arrays, false ); // $ExpectError + anyBy( arrays, null ); // $ExpectError + anyBy( arrays, undefined ); // $ExpectError + anyBy( arrays, [] ); // $ExpectError + anyBy( arrays, {} ); // $ExpectError + + anyBy( arrays, '10', {} ); // $ExpectError + anyBy( arrays, 5, {} ); // $ExpectError + anyBy( arrays, true, {} ); // $ExpectError + anyBy( arrays, false, {} ); // $ExpectError + anyBy( arrays, null, {} ); // $ExpectError + anyBy( arrays, undefined, {} ); // $ExpectError + anyBy( arrays, [], {} ); // $ExpectError + anyBy( arrays, {}, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ] ); + const arrays = [ x ]; + + anyBy(); // $ExpectError + anyBy( arrays ); // $ExpectError + anyBy( arrays, clbk, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/any-by/examples/index.js new file mode 100644 index 000000000000..b3adf1c3c49d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/examples/index.js @@ -0,0 +1,42 @@ +/** +* @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/base/to-array' ); +var anyBy = require( './../lib' ); + +function clbk( value ) { + return value > 0; +} + +var x = { + 'dtype': 'generic', + 'data': discreteUniform( 10, -5, 5, { + '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 out = anyBy( [ x ], clbk ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js new file mode 100644 index 000000000000..338e044b324b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js @@ -0,0 +1,83 @@ +/** +* @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 one element in an ndarray pass a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = any0d( x, predicate ); +* // returns true +*/ +function any0d( x, predicate, thisArg ) { + if ( predicate.call( thisArg, x.data[ x.offset ], [], x.ref ) ) { + return true; + } + return false; +} + + +// EXPORTS // + +module.exports = any0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js new file mode 100644 index 000000000000..313ef75922e3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js @@ -0,0 +1,86 @@ +/** +* @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 one element in an ndarray pass a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = any0d( x, predicate ); +* // returns true +*/ +function any0d( x, predicate, thisArg ) { + if ( predicate.call( thisArg, x.accessors[ 0 ]( x.data, x.offset ), [], x.ref ) ) { // eslint-disable-line max-len + return true; + } + return false; +} + + +// EXPORTS // + +module.exports = any0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js new file mode 100644 index 000000000000..5f0403e2e6a3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/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 one element in an ndarray pass a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = any1d( x, predicate ); +* // returns true +*/ +function any1d( x, predicate, thisArg ) { + 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; + + // Iterate over the ndarray dimensions... + for ( i0 = 0; i0 < S0; i0++ ) { + if ( predicate.call( thisArg, xbuf[ ix ], [ i0 ], x.ref ) ) { + return true; + } + ix += dx0; + } + return false; +} + + +// EXPORTS // + +module.exports = any1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d_accessors.js new file mode 100644 index 000000000000..a1db0fe597da --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/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 one element in an ndarray pass a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = any1d( x, predicate ); +* // returns true +*/ +function any1d( x, predicate, thisArg ) { + 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 ]; + + // Iterate over the ndarray dimensions... + for ( i0 = 0; i0 < S0; i0++ ) { + if ( predicate.call( thisArg, get( xbuf, ix ), [ i0 ], x.ref) ) { + return true; + } + ix += dx0; + } + return false; +} + + +// EXPORTS // + +module.exports = any1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js new file mode 100644 index 000000000000..5adef058c8cd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js @@ -0,0 +1,136 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = any2d( x, predicate ); +* // returns true +*/ +function any2d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( predicate.call( thisArg, xbuf[ ix ], take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + return false; +} + + +// EXPORTS // + +module.exports = any2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js new file mode 100644 index 000000000000..c8c6edf13a7a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js @@ -0,0 +1,143 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = any2d( x, predicate ); +* // returns true +*/ +function any2d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // 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 ]; + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( predicate.call( thisArg, get( xbuf, ix ), take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + return false; +} + + +// EXPORTS // + +module.exports = any2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.js new file mode 100644 index 000000000000..0b93b909f19d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.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 loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedany2d( x, predicate ); +* // returns true +*/ +function blockedany2d( x, predicate, thisArg ) { + var bsize; + var xbuf; + var idx; + 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ j1+i1, j0+i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js new file mode 100644 index 000000000000..327f7b9f5ec3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_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. +*/ + +'use strict'; + +// MODULES // + +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedany2d( x, predicate ); +* // returns true +*/ +function blockedany2d( x, predicate, thisArg ) { + var bsize; + var xbuf; + var idx; + 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ j1+i1, j0+i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js new file mode 100644 index 000000000000..3b99842b6195 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js @@ -0,0 +1,146 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = any3d( x, predicate ); +* // returns true +*/ +function any3d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( predicate.call( thisArg, xbuf[ ix ], take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + return false; +} + + +// EXPORTS // + +module.exports = any3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js new file mode 100644 index 000000000000..bb7e01f88555 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js @@ -0,0 +1,153 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = any3d( x, predicate ); +* // returns true +*/ +function any3d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // 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 ]; + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( predicate.call( thisArg, get( xbuf, ix ), take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + return false; +} + + +// EXPORTS // + +module.exports = any3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js new file mode 100644 index 000000000000..9f9ce175d7d2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js @@ -0,0 +1,183 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedany3d( x, predicate ); +* // returns true +*/ +function blockedany3d( x, predicate, thisArg ) { + var bsize; + var xbuf; + var idx; + 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js new file mode 100644 index 000000000000..56b5ba100a57 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js @@ -0,0 +1,190 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedany3d( x, predicate ); +* // returns true +*/ +function blockedany3d( x, predicate, thisArg ) { + var bsize; + var xbuf; + var idx; + 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/index.js new file mode 100644 index 000000000000..a9e752ba264a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/index.js @@ -0,0 +1,69 @@ +/** +* @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 one element in an ndarray pass a test implemented by a predicate function. +* +* @module @stdlib/ndarray/base/any-by +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var anyBy = require( '@stdlib/ndarray/base/any-by' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = anyBy( [ x ], predicate ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/main.js new file mode 100644 index 000000000000..8c0137a6c1cb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/main.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'; + +// MODULES // + +var iterationOrder = require( '@stdlib/ndarray/base/iteration-order' ); +var ndarray2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var blockedaccessorany2d = require( './2d_blocked_accessors.js' ); +var blockedaccessorany3d = require( './3d_blocked_accessors.js' ); +var blockedany2d = require( './2d_blocked.js' ); +var blockedany3d = require( './3d_blocked.js' ); +var accessorany0d = require( './0d_accessors.js' ); +var accessorany1d = require( './1d_accessors.js' ); +var accessorany2d = require( './2d_accessors.js' ); +var accessorany3d = require( './3d_accessors.js' ); +var accessoranynd = require( './nd_accessors.js' ); +var any0d = require( './0d.js' ); +var any1d = require( './1d.js' ); +var any2d = require( './2d.js' ); +var any3d = require( './3d.js' ); +var anynd = require( './nd.js' ); + + +// VARIABLES // + +var ANY = [ + any0d, + any1d, + any2d, + any3d +]; +var ACCESSOR_ANY = [ + accessorany0d, + accessorany1d, + accessorany2d, + accessorany3d +]; +var BLOCKED_ANY = [ + blockedany2d, // 0 + blockedany3d +]; +var BLOCKED_ACCESSOR_ANY = [ + blockedaccessorany2d, // 0 + blockedaccessorany3d +]; +var MAX_DIMS = ANY.length - 1; + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* +* ## 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 one input array +* @param {Function} predicate - predicate function +* @param {thisArg} [thisArg] - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = anyBy( [ x ], predicate ); +* // returns true +*/ +function anyBy( arrays, predicate, thisArg ) { + var ndims; + var shx; + var x; + + // Unpack the ndarray and standardize ndarray meta data: + x = ndarray2object( arrays[ 0 ] ); + shx = x.shape; + ndims = shx.length; + + // Determine whether we can avoid iteration altogether... + if ( ndims === 0 ) { + if ( x.accessorProtocol ) { + return ACCESSOR_ANY[ ndims ]( x, predicate, thisArg ); + } + return ANY[ ndims ]( x, predicate, thisArg ); + } + // Check whether we were provided an empty ndarray... + if ( numel( shx ) === 0 ) { + return false; + } + // Determine whether we can avoid blocked iteration... + if ( ndims <= MAX_DIMS && iterationOrder( x.strides ) !== 0 ) { + // 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_ANY[ ndims ]( x, predicate, thisArg ); + } + return ANY[ ndims ]( x, predicate, thisArg ); + } + // Determine whether we can perform blocked iteration... + if ( ndims <= MAX_DIMS ) { + if ( x.accessorProtocol ) { + return BLOCKED_ACCESSOR_ANY[ ndims-2 ]( x, predicate, thisArg ); + } + return BLOCKED_ANY[ ndims-2 ]( x, predicate, thisArg ); + } + // 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 accessoranynd( x, predicate, thisArg ); + } + return anynd( x, predicate, thisArg ); +} + + +// EXPORTS // + +module.exports = anyBy; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd.js new file mode 100644 index 000000000000..d72984d8136f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd.js @@ -0,0 +1,127 @@ +/** +* @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' ); +var ind2sub = require( '@stdlib/ndarray/base/ind2sub' ); + + +// VARIABLES // + +var MODE = 'throw'; + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = anynd( x, predicate ); +* // returns true +*/ +function anynd( x, predicate, thisArg ) { + var xbuf; + var ordx; + var idx; + 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; + + // 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 ); + idx = ind2sub( sh, sx, 0, ordx, i, MODE ); // return subscripts from the perspective of the ndarray view + if ( predicate.call( thisArg, xbuf[ ix ], idx, x.ref ) ) { + return true; + } + } + return false; +} + + +// EXPORTS // + +module.exports = anynd; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd_accessors.js new file mode 100644 index 000000000000..0a9146f4f902 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd_accessors.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 numel = require( '@stdlib/ndarray/base/numel' ); +var vind2bind = require( '@stdlib/ndarray/base/vind2bind' ); +var ind2sub = require( '@stdlib/ndarray/base/ind2sub' ); + + +// VARIABLES // + +var MODE = 'throw'; + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = anynd( x, predicate ); +* // returns true +*/ +function anynd( x, predicate, thisArg ) { + var xbuf; + var ordx; + var idx; + 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 ]; + + // 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 ); + idx = ind2sub( sh, sx, 0, ordx, i, MODE ); // return subscripts from the perspective of the ndarray view + if ( predicate.call( thisArg, get( xbuf, ix ), idx, x.ref ) ) { + return true; + } + } + return false; +} + + +// EXPORTS // + +module.exports = anynd; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/package.json b/lib/node_modules/@stdlib/ndarray/base/any-by/package.json new file mode 100644 index 000000000000..a482bf2da862 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/ndarray/base/any-by", + "version": "0.0.0", + "description": "Test whether at least one element in an ndarray pass a test implemented by a predicate function.", + "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", + "any", + "anyby", + "some", + "someby", + "callback", + "utility", + "utils" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.0d.js new file mode 100644 index 000000000000..b27cc4740c93 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.0d.js @@ -0,0 +1,87 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least one element in a 0-dimensional ndarray passes a test implemented by a predicate function', function test( t ) { + var actual; + var x; + + x = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = scalar2ndarray( 1.0, { + 'dtype': 'float64' + }); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0.0; + } +}); + +tape( 'the function tests whether at least one element in a 0-dimensional ndarray passes a test implemented by a predicate function (accessors)', function test( t ) { + var actual; + var x; + + x = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' + }); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = scalar2ndarray( new Complex128( 1.0, 1.0 ), { + 'dtype': 'complex128' + }); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.1d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.1d.js new file mode 100644 index 000000000000..a23e6bb8eeab --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.1d.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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var ones = require( '@stdlib/array/ones' ); +var zeros = require( '@stdlib/array/zeros' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least one element in a 1-dimensional ndarray passes a test implemented by a predicate function', function test( t ) { + var actual; + var x; + + x = ndarray( 'float64', zeros( 8, 'float64' ), [ 4 ], [ 2 ], 1, 'row-major' ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( 'float64', ones( 8, 'float64' ), [ 4 ], [ 2 ], 1, 'row-major' ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 1-dimensional ndarray passes a test implemented by a predicate function (accessors)', function test( t ) { + var actual; + var xbuf; + var x; + + xbuf = zeros( 6*2, 'float64' ); + x = ndarray( 'complex128', new Complex128Array( xbuf ), [ 4 ], [ 1 ], 1, 'row-major' ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 6*2, 'float64' ); + x = ndarray( 'complex128', new Complex128Array( xbuf ), [ 4 ], [ 1 ], 1, 'row-major' ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var x; + + x = new ndarray( 'float64', zeros( 8, 'float64'), [ 4 ], [ 2 ], 0, 'row-major' ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0 ], + [ 1 ], + [ 2 ], + [ 3 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var x; + + xbuf = zeros( 6*2, 'float64' ); + x = ndarray( 'complex128', new Complex128Array( xbuf ), [ 4 ], [ 1 ], 1, 'row-major' ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0 ], + [ 1 ], + [ 2 ], + [ 3 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.2d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.2d.js new file mode 100644 index 000000000000..29ae4c44f069 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.2d.js @@ -0,0 +1,1285 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +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 anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0 ], + [ 0, 1 ], + [ 1, 0 ], + [ 1, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0 ], + [ 0, 1 ], + [ 1, 0 ], + [ 1, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0 ], + [ 1, 0 ], + [ 0, 1 ], + [ 1, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0 ], + [ 1, 0 ], + [ 0, 1 ], + [ 1, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 2-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.3d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.3d.js new file mode 100644 index 000000000000..23a7b9686e16 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.3d.js @@ -0,0 +1,1479 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +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 anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0 ], + [ 0, 0, 1 ], + [ 0, 1, 0 ], + [ 0, 1, 1 ], + [ 1, 0, 0 ], + [ 1, 0, 1 ], + [ 1, 1, 0 ], + [ 1, 1, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0 ], + [ 0, 0, 1 ], + [ 0, 1, 0 ], + [ 0, 1, 1 ], + [ 1, 0, 0 ], + [ 1, 0, 1 ], + [ 1, 1, 0 ], + [ 1, 1, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2, 2 ]; + st = [ -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0 ], + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 1, 1, 0 ], + [ 0, 0, 1 ], + [ 1, 0, 1 ], + [ 0, 1, 1 ], + [ 1, 1, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0 ], + [ 1, 0, 0 ], + [ 0, 1, 0 ], + [ 1, 1, 0 ], + [ 0, 0, 1 ], + [ 1, 0, 1 ], + [ 0, 1, 1 ], + [ 1, 1, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2, 2 ]; + st = [ -1, 2, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ 2, 2, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ -2, 2, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2, 2 ]; + st = [ -1, -2, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 3-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.js new file mode 100644 index 000000000000..322a3d33c3f8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.js @@ -0,0 +1,51 @@ +/** +* @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 ndarray = require( '@stdlib/ndarray/ctor' ); +var anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, '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; + + x = ndarray( 'float64', ones( 8, 'float64' ), [ 0 ], [ 1 ], 0, 'row-major' ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0.0; + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.nd.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.nd.js new file mode 100644 index 000000000000..5c67285d9cf5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.nd.js @@ -0,0 +1,1040 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +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 everyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof everyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = everyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, true, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 1.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = everyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, true, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -8, -8, -8, -8, -8, -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 16, 16, 16, 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 16, 16, 16, 8, -8, -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 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 ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -8, -8, -8, -8, -8, -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 16, 16, 16, 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -16, -16, -16, -16, -16, -8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = everyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, true, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 1.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = everyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, true, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -1, -1, -2, -2, 4, -4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, 2, 2, 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -2, -2, -2, -2, -2, -2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 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 ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -1, -1, -2, -2, 4, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, 2, 2, 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, 2, 2, 2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); From a49cb40837c5588caab1af9b92bee423d68c8bb1 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Tue, 15 Jul 2025 05:43:01 +0000 Subject: [PATCH 2/7] fix: nd test cases --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../ndarray/base/any-by/test/test.nd.js | 212 +++++++++--------- 1 file changed, 106 insertions(+), 106 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.nd.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.nd.js index 5c67285d9cf5..57537a0b7fde 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.nd.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.nd.js @@ -30,18 +30,18 @@ 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 everyBy = require( './../lib' ); +var anyBy = require( './../lib' ); // TESTS // tape( 'main export is a function', function test( t ) { t.ok( true, __filename ); - t.strictEqual( typeof everyBy, 'function', 'main export is a function'); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); t.end(); }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { var actual; var ord; var sh; @@ -58,12 +58,12 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -73,7 +73,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { var actual; var xbuf; var ord; @@ -92,13 +92,13 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe xbuf = zeros( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); xbuf = ones( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -128,7 +128,7 @@ tape( 'the function supports specifying the callback execution context (row-majo st = shape2strides( sh, ord ); o = strides2offset( sh, st ); - x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); indices = []; values = []; @@ -137,20 +137,20 @@ tape( 'the function supports specifying the callback execution context (row-majo ctx = { 'count': 0 }; - actual = everyBy( [ x ], clbk, ctx ); + actual = anyBy( [ x ], clbk, ctx ); - t.strictEqual( actual, true, 'returns expected value' ); + t.strictEqual( actual, false, 'returns expected value' ); t.strictEqual( ctx.count, 8, 'returns expected value' ); expected = [ - 1.0, - 1.0, - 1.0, - 1.0, - 1.0, - 1.0, - 1.0, - 1.0 + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 ]; t.deepEqual( values, expected, 'returns expected value' ); @@ -210,7 +210,7 @@ tape( 'the function supports specifying the callback execution context (row-majo st = shape2strides( sh, ord ); o = strides2offset( sh, st ); - xbuf = ones( numel( sh )*2, 'float64' ); + xbuf = zeros( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); indices = []; @@ -220,20 +220,20 @@ tape( 'the function supports specifying the callback execution context (row-majo ctx = { 'count': 0 }; - actual = everyBy( [ x ], clbk, ctx ); + actual = anyBy( [ x ], clbk, ctx ); - t.strictEqual( actual, true, 'returns expected value' ); + t.strictEqual( actual, false, 'returns expected value' ); t.strictEqual( ctx.count, 8, 'returns expected value' ); expected = [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] ]; t.deepEqual( values, expected, 'returns expected value' ); @@ -272,7 +272,7 @@ tape( 'the function supports specifying the callback execution context (row-majo } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { var actual; var ord; var sh; @@ -289,12 +289,12 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -304,7 +304,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { var actual; var ord; var sh; @@ -321,12 +321,12 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -336,7 +336,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { var actual; var ord; var sh; @@ -353,12 +353,12 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -368,7 +368,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { var actual; var ord; var sh; @@ -385,12 +385,12 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -400,7 +400,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { var actual; var xbuf; var ord; @@ -419,13 +419,13 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe xbuf = zeros( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); xbuf = ones( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -435,7 +435,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides, accessors)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides, accessors)', function test( t ) { var actual; var xbuf; var ord; @@ -454,13 +454,13 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe xbuf = zeros( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); xbuf = ones( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -470,7 +470,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { var actual; var xbuf; var ord; @@ -489,13 +489,13 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe xbuf = zeros( 8*4, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); xbuf = ones( 8*4, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -505,7 +505,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { var actual; var xbuf; var ord; @@ -524,13 +524,13 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe xbuf = zeros( 8*4, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); xbuf = ones( 8*4, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -540,7 +540,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { var actual; var ord; var sh; @@ -557,12 +557,12 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -572,7 +572,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { var actual; var xbuf; var ord; @@ -591,13 +591,13 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe xbuf = zeros( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); xbuf = ones( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -627,7 +627,7 @@ tape( 'the function supports specifying the callback execution context (column-m st = shape2strides( sh, ord ); o = strides2offset( sh, st ); - x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); indices = []; values = []; @@ -636,20 +636,20 @@ tape( 'the function supports specifying the callback execution context (column-m ctx = { 'count': 0 }; - actual = everyBy( [ x ], clbk, ctx ); + actual = anyBy( [ x ], clbk, ctx ); - t.strictEqual( actual, true, 'returns expected value' ); + t.strictEqual( actual, false, 'returns expected value' ); t.strictEqual( ctx.count, 8, 'returns expected value' ); expected = [ - 1.0, - 1.0, - 1.0, - 1.0, - 1.0, - 1.0, - 1.0, - 1.0 + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 ]; t.deepEqual( values, expected, 'returns expected value' ); @@ -709,7 +709,7 @@ tape( 'the function supports specifying the callback execution context (column-m st = shape2strides( sh, ord ); o = strides2offset( sh, st ); - xbuf = ones( numel( sh )*2, 'float64' ); + xbuf = zeros( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); indices = []; @@ -719,20 +719,20 @@ tape( 'the function supports specifying the callback execution context (column-m ctx = { 'count': 0 }; - actual = everyBy( [ x ], clbk, ctx ); + actual = anyBy( [ x ], clbk, ctx ); - t.strictEqual( actual, true, 'returns expected value' ); + t.strictEqual( actual, false, 'returns expected value' ); t.strictEqual( ctx.count, 8, 'returns expected value' ); expected = [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] ]; t.deepEqual( values, expected, 'returns expected value' ); @@ -771,7 +771,7 @@ tape( 'the function supports specifying the callback execution context (column-m } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { var actual; var ord; var sh; @@ -788,12 +788,12 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -803,7 +803,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { var actual; var ord; var sh; @@ -820,12 +820,12 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -835,7 +835,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { var actual; var ord; var sh; @@ -852,12 +852,12 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -867,7 +867,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { var actual; var ord; var sh; @@ -884,12 +884,12 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -899,7 +899,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { var actual; var xbuf; var ord; @@ -918,13 +918,13 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe xbuf = zeros( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); xbuf = ones( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -934,7 +934,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides, accessors)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides, accessors)', function test( t ) { var actual; var xbuf; var ord; @@ -953,13 +953,13 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe xbuf = zeros( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); xbuf = ones( numel( sh )*2, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -969,7 +969,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { var actual; var xbuf; var ord; @@ -988,13 +988,13 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe xbuf = zeros( 8*4, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); xbuf = ones( 8*4, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); @@ -1004,7 +1004,7 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe } }); -tape( 'the function tests whether every element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { +tape( 'the function tests whether at least one element in a n-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { var actual; var xbuf; var ord; @@ -1023,13 +1023,13 @@ tape( 'the function tests whether every element in a n-dimensional ndarray passe xbuf = zeros( 8*4, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); xbuf = ones( 8*4, 'float64' ); x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); - actual = everyBy( [ x ], clbk ); + actual = anyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); t.end(); From 4649560be7f2d9e46ea21b878a16555f0289037e Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 15 Jul 2025 11:35:10 -0700 Subject: [PATCH 3/7] feat: improve type specificity Signed-off-by: Athan --- .../ndarray/base/any-by/docs/types/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts index aeaa5b0525a6..537daae40a63 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts @@ -28,7 +28,7 @@ import { typedndarray } from '@stdlib/types/ndarray'; * * @returns boolean indicating whether an ndarray element passes a test */ -type Nullary = ( this: U ) => boolean; +type Nullary = ( this: ThisArg ) => boolean; /** * Returns a boolean indicating whether an element passes a test. @@ -36,7 +36,7 @@ type Nullary = ( this: U ) => boolean; * @param value - current array element * @returns boolean indicating whether an ndarray element passes a test */ -type Unary = ( this: U, value: T ) => boolean; +type Unary = ( this: ThisArg, value: T ) => boolean; /** * Returns a boolean indicating whether an element passes a test. @@ -45,7 +45,7 @@ type Unary = ( this: U, value: T ) => boolean; * @param indices - current array element indices * @returns boolean indicating whether an ndarray element passes a test */ -type Binary = ( this: U, value: T, indices: Array ) => boolean; +type Binary = ( this: ThisArg, value: T, indices: Array ) => boolean; /** * Returns a boolean indicating whether an element passes a test. @@ -55,7 +55,7 @@ type Binary = ( this: U, value: T, indices: Array ) => boolean; * @param arr - input array * @returns boolean indicating whether an ndarray element passes a test */ -type Ternary = ( this: U, value: T, indices: Array, arr: typedndarray ) => boolean; +type Ternary = ( this: ThisArg, value: T, indices: Array, arr: U ) => boolean; /** * Returns a boolean indicating whether an element passes a test. @@ -65,7 +65,7 @@ type Ternary = ( this: U, value: T, indices: Array, arr: typedndar * @param arr - input array * @returns boolean indicating whether an ndarray element passes a test */ -type Predicate = Nullary | Unary | Binary | Ternary; +type Predicate = Nullary | Unary | Binary | Ternary; /** * Tests whether at least one element in an ndarray pass a test implemented by a predicate function. @@ -101,7 +101,7 @@ type Predicate = Nullary | Unary | Binary | Ternary; * var out = anyBy( [ x ], predicate ); * // returns true */ -declare function anyBy( arrays: ArrayLike>, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; +declare function anyBy = typedndarray, ThisArg = unknown>( arrays: ArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; // EXPORTS // From 0aaef8c83a4e2a105b0a01848d4321b3e7f0487c Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Thu, 17 Jul 2025 20:47:09 +0000 Subject: [PATCH 4/7] docs: fix description --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/ndarray/base/any-by/README.md | 4 ++-- lib/node_modules/@stdlib/ndarray/base/any-by/docs/repl.txt | 4 ++-- .../@stdlib/ndarray/base/any-by/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/0d_accessors.js | 2 +- lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/1d_accessors.js | 2 +- lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/2d_accessors.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/2d_blocked.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js | 2 +- lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/3d_accessors.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/3d_blocked.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js | 2 +- lib/node_modules/@stdlib/ndarray/base/any-by/lib/index.js | 2 +- lib/node_modules/@stdlib/ndarray/base/any-by/lib/main.js | 2 +- lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/nd_accessors.js | 2 +- lib/node_modules/@stdlib/ndarray/base/any-by/package.json | 2 +- 20 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/README.md b/lib/node_modules/@stdlib/ndarray/base/any-by/README.md index ee3ac0da1aea..0fc284eef7c3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/README.md @@ -20,7 +20,7 @@ limitations under the License. # anyBy -> Test whether at least one element in an ndarray pass a test implemented by a predicate function. +> Test whether at least one element in an ndarray passes a test implemented by a predicate function.
@@ -38,7 +38,7 @@ var anyBy = require( '@stdlib/ndarray/base/any-by' ); #### anyBy( arrays, predicate\[, thisArg] ) -Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +Tests whether at least one element in an ndarray passes a test implemented by a predicate function. diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/repl.txt index 083e0eeb86b5..ea5c64ecce74 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( arrays, predicate[, thisArg] ) - Tests whether at least one element in an ndarray pass a test implemented by - a predicate function. + Tests whether at least one element in an ndarray passes a test implemented + by a predicate function. A provided "ndarray" should be an `object` with the following properties: diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts index 537daae40a63..5bb0f154b17b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/docs/types/index.d.ts @@ -68,7 +68,7 @@ type Ternary = ( this: ThisArg, value: T, indices: Array, type Predicate = Nullary | Unary | Binary | Ternary; /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @param arrays - array-like object containing an input ndarray * @param predicate - predicate function diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js index 338e044b324b..c904b672973a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js @@ -21,7 +21,7 @@ // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js index 313ef75922e3..a8674912f863 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js @@ -21,7 +21,7 @@ // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js index 5f0403e2e6a3..58177da655a3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js @@ -21,7 +21,7 @@ // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d_accessors.js index a1db0fe597da..b9dcf7f71b41 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d_accessors.js @@ -21,7 +21,7 @@ // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js index 5adef058c8cd..028c8f572f00 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js @@ -29,7 +29,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js index c8c6edf13a7a..adc81212d2c6 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js @@ -29,7 +29,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.js index 0b93b909f19d..9b66f45b2d62 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.js @@ -29,7 +29,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function via loop blocking. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js index 327f7b9f5ec3..a87e230edda4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js @@ -29,7 +29,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function via loop blocking. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js index 3b99842b6195..2525100ea301 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js @@ -29,7 +29,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js index bb7e01f88555..6381c09c7e43 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js @@ -29,7 +29,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js index 9f9ce175d7d2..318ee445d159 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function via loop blocking. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js index 56b5ba100a57..b88a5428c6c0 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function via loop blocking. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/index.js index a9e752ba264a..8fc40789a368 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Test whether at least one element in an ndarray pass a test implemented by a predicate function. +* Test whether at least one element in an ndarray passes a test implemented by a predicate function. * * @module @stdlib/ndarray/base/any-by * diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/main.js index 8c0137a6c1cb..09fc803b387b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/main.js @@ -67,7 +67,7 @@ var MAX_DIMS = ANY.length - 1; // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * ## Notes * diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd.js index d72984d8136f..b71e45f825dd 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd.js @@ -33,7 +33,7 @@ var MODE = 'throw'; // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd_accessors.js index 0a9146f4f902..35db35c0a6f1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/nd_accessors.js @@ -33,7 +33,7 @@ var MODE = 'throw'; // MAIN // /** -* Tests whether at least one element in an ndarray pass a test implemented by a predicate function. +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/package.json b/lib/node_modules/@stdlib/ndarray/base/any-by/package.json index a482bf2da862..ba0359db9103 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/package.json +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/ndarray/base/any-by", "version": "0.0.0", - "description": "Test whether at least one element in an ndarray pass a test implemented by a predicate function.", + "description": "Test whether at least one element in an ndarray passes a test implemented by a predicate function.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From 362f3e931d1efdb4ebf6e38062acd66ddc51b1e4 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Thu, 17 Jul 2025 21:27:44 +0000 Subject: [PATCH 5/7] feat: add kernels upto 10d --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/base/any-by/lib/0d.js | 2 +- .../ndarray/base/any-by/lib/0d_accessors.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/10d.js | 218 ++++++++++++ .../ndarray/base/any-by/lib/10d_accessors.js | 225 ++++++++++++ .../ndarray/base/any-by/lib/10d_blocked.js | 316 +++++++++++++++++ .../base/any-by/lib/10d_blocked_accessors.js | 323 ++++++++++++++++++ .../@stdlib/ndarray/base/any-by/lib/1d.js | 2 +- .../ndarray/base/any-by/lib/1d_accessors.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/2d.js | 2 +- .../ndarray/base/any-by/lib/2d_accessors.js | 2 +- .../ndarray/base/any-by/lib/2d_blocked.js | 2 +- .../base/any-by/lib/2d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/3d.js | 2 +- .../ndarray/base/any-by/lib/3d_accessors.js | 2 +- .../ndarray/base/any-by/lib/3d_blocked.js | 2 +- .../base/any-by/lib/3d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/any-by/lib/4d.js | 156 +++++++++ .../ndarray/base/any-by/lib/4d_accessors.js | 163 +++++++++ .../ndarray/base/any-by/lib/4d_blocked.js | 202 +++++++++++ .../base/any-by/lib/4d_blocked_accessors.js | 209 ++++++++++++ .../@stdlib/ndarray/base/any-by/lib/5d.js | 168 +++++++++ .../ndarray/base/any-by/lib/5d_accessors.js | 175 ++++++++++ .../ndarray/base/any-by/lib/5d_blocked.js | 221 ++++++++++++ .../base/any-by/lib/5d_blocked_accessors.js | 228 +++++++++++++ .../@stdlib/ndarray/base/any-by/lib/6d.js | 178 ++++++++++ .../ndarray/base/any-by/lib/6d_accessors.js | 185 ++++++++++ .../ndarray/base/any-by/lib/6d_blocked.js | 240 +++++++++++++ .../base/any-by/lib/6d_blocked_accessors.js | 247 ++++++++++++++ .../@stdlib/ndarray/base/any-by/lib/7d.js | 188 ++++++++++ .../ndarray/base/any-by/lib/7d_accessors.js | 195 +++++++++++ .../ndarray/base/any-by/lib/7d_blocked.js | 259 ++++++++++++++ .../base/any-by/lib/7d_blocked_accessors.js | 266 +++++++++++++++ .../@stdlib/ndarray/base/any-by/lib/8d.js | 198 +++++++++++ .../ndarray/base/any-by/lib/8d_accessors.js | 205 +++++++++++ .../ndarray/base/any-by/lib/8d_blocked.js | 278 +++++++++++++++ .../base/any-by/lib/8d_blocked_accessors.js | 285 ++++++++++++++++ .../@stdlib/ndarray/base/any-by/lib/9d.js | 208 +++++++++++ .../ndarray/base/any-by/lib/9d_accessors.js | 215 ++++++++++++ .../ndarray/base/any-by/lib/9d_blocked.js | 297 ++++++++++++++++ .../base/any-by/lib/9d_blocked_accessors.js | 304 +++++++++++++++++ 40 files changed, 6364 insertions(+), 12 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_blocked_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_blocked_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_blocked_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_blocked_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_blocked_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_blocked_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js index c904b672973a..1668bf95eb51 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d.js @@ -34,7 +34,7 @@ * @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js index a8674912f863..58f7888ed06c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/0d_accessors.js @@ -35,7 +35,7 @@ * @param {Array} x.accessors - data buffer accessors * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d.js new file mode 100644 index 000000000000..85338eeef3db --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d.js @@ -0,0 +1,218 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = any10d( x, predicate ); +* // returns true +*/ +function any10d( x, predicate, thisArg ) { // eslint-disable-line max-statements + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + 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 = any10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_accessors.js new file mode 100644 index 000000000000..b65bfc3df566 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_accessors.js @@ -0,0 +1,225 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = any10d( x, predicate ); +* // returns true +*/ +function any10d( x, predicate, thisArg ) { // eslint-disable-line max-statements + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // 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 ]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + 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 = any10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_blocked.js new file mode 100644 index 000000000000..1c38795a93aa --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_blocked.js @@ -0,0 +1,316 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedany10d( x, predicate ); +* // returns true +*/ +function blockedany10d( x, predicate, thisArg ) { // eslint-disable-line max-statements, max-lines-per-function + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ j9+i9, j8+i8, j7+i7, j6+i6, j5+i5, j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { + 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 = blockedany10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_blocked_accessors.js new file mode 100644 index 000000000000..01abace12352 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/10d_blocked_accessors.js @@ -0,0 +1,323 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedany10d( x, predicate ); +* // returns true +*/ +function blockedany10d( x, predicate, thisArg ) { // eslint-disable-line max-statements, max-lines-per-function + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ j9+i9, j8+i8, j7+i7, j6+i6, j5+i5, j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { + 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 = blockedany10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js index 58177da655a3..2d2d50652139 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d.js @@ -34,7 +34,7 @@ * @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d_accessors.js index b9dcf7f71b41..cba496dcafa3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/1d_accessors.js @@ -35,7 +35,7 @@ * @param {Array} x.accessors - data buffer accessors * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js index 028c8f572f00..8b9b390f78a7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d.js @@ -42,7 +42,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js index adc81212d2c6..62b7abd390d6 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_accessors.js @@ -43,7 +43,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @param {Array} x.accessors - data buffer accessors * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.js index 9b66f45b2d62..0ae27155e382 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked.js @@ -42,7 +42,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js index a87e230edda4..423dbafffbba 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/2d_blocked_accessors.js @@ -43,7 +43,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @param {Array} x.accessors - data buffer accessors * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js index 2525100ea301..a43a9ca02857 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d.js @@ -42,7 +42,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js index 6381c09c7e43..61ce23ff76a1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_accessors.js @@ -43,7 +43,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @param {Array} x.accessors - data buffer accessors * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js index 318ee445d159..c8dcbc7215e6 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked.js @@ -44,7 +44,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style) * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js index b88a5428c6c0..5fb0ac3d78a2 100644 --- a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/3d_blocked_accessors.js @@ -45,7 +45,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @param {Array} x.accessors - data buffer accessors * @param {Function} predicate - predicate function * @param {*} thisArg - predicate function execution context -* @returns {boolean} boolean indicating whether at least one element pass a test +* @returns {boolean} boolean indicating whether at least one element passes a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d.js new file mode 100644 index 000000000000..aa021645c250 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d.js @@ -0,0 +1,156 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = any4d( x, predicate ); +* // returns true +*/ +function any4d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + return false; +} + + +// EXPORTS // + +module.exports = any4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_accessors.js new file mode 100644 index 000000000000..e0b3a00742db --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_accessors.js @@ -0,0 +1,163 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = any4d( x, predicate ); +* // returns true +*/ +function any4d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // 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 ]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + return false; +} + + +// EXPORTS // + +module.exports = any4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_blocked.js new file mode 100644 index 000000000000..20c60eb22042 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_blocked.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 loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedany4d( x, predicate ); +* // returns true +*/ +function blockedany4d( x, predicate, thisArg ) { + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_blocked_accessors.js new file mode 100644 index 000000000000..247a4035530c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/4d_blocked_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 loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedany4d( x, predicate ); +* // returns true +*/ +function blockedany4d( x, predicate, thisArg ) { + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d.js new file mode 100644 index 000000000000..1dd8dd654f4d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d.js @@ -0,0 +1,168 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = any5d( x, predicate ); +* // returns true +*/ +function any5d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + return false; +} + + +// EXPORTS // + +module.exports = any5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_accessors.js new file mode 100644 index 000000000000..0bb1ddc9ce36 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_accessors.js @@ -0,0 +1,175 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = any5d( x, predicate ); +* // returns true +*/ +function any5d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // 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 ]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + return false; +} + + +// EXPORTS // + +module.exports = any5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_blocked.js new file mode 100644 index 000000000000..2550799b33f5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_blocked.js @@ -0,0 +1,221 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedany5d( x, predicate ); +* // returns true +*/ +function blockedany5d( x, predicate, thisArg ) { + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_blocked_accessors.js new file mode 100644 index 000000000000..95c0b4320927 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/5d_blocked_accessors.js @@ -0,0 +1,228 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedany5d( x, predicate ); +* // returns true +*/ +function blockedany5d( x, predicate, thisArg ) { + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d.js new file mode 100644 index 000000000000..2d0c4696d7be --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d.js @@ -0,0 +1,178 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = any6d( x, predicate ); +* // returns true +*/ +function any6d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + return false; +} + + +// EXPORTS // + +module.exports = any6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_accessors.js new file mode 100644 index 000000000000..2fc53807a610 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_accessors.js @@ -0,0 +1,185 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = any6d( x, predicate ); +* // returns true +*/ +function any6d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // 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 ]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + return false; +} + + +// EXPORTS // + +module.exports = any6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_blocked.js new file mode 100644 index 000000000000..1c751feaec72 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_blocked.js @@ -0,0 +1,240 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element pass a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedany6d( x, predicate ); +* // returns true +*/ +function blockedany6d( x, predicate, thisArg ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ j5+i5, j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_blocked_accessors.js new file mode 100644 index 000000000000..67282a118787 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/6d_blocked_accessors.js @@ -0,0 +1,247 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedany6d( x, predicate ); +* // returns true +*/ +function blockedany6d( x, predicate, thisArg ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ j5+i5, j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d.js new file mode 100644 index 000000000000..544be287e9f3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d.js @@ -0,0 +1,188 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = any7d( x, predicate ); +* // returns true +*/ +function any7d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + return false; +} + + +// EXPORTS // + +module.exports = any7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_accessors.js new file mode 100644 index 000000000000..0ff9da743608 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_accessors.js @@ -0,0 +1,195 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = any7d( x, predicate ); +* // returns true +*/ +function any7d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // 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 ]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + return false; +} + + +// EXPORTS // + +module.exports = any7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_blocked.js new file mode 100644 index 000000000000..6e3f36f49e68 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_blocked.js @@ -0,0 +1,259 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedany7d( x, predicate ); +* // returns true +*/ +function blockedany7d( x, predicate, thisArg ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ j6+i6, j5+i5, j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_blocked_accessors.js new file mode 100644 index 000000000000..7374f08fbf79 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/7d_blocked_accessors.js @@ -0,0 +1,266 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedany7d( x, predicate ); +* // returns true +*/ +function blockedany7d( x, predicate, thisArg ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ j6+i6, j5+i5, j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d.js new file mode 100644 index 000000000000..b8e7f7c9f473 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d.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 strides2order = require( '@stdlib/ndarray/base/strides2order' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = any8d( x, predicate ); +* // returns true +*/ +function any8d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + return false; +} + + +// EXPORTS // + +module.exports = any8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_accessors.js new file mode 100644 index 000000000000..473305e7d63d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_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 strides2order = require( '@stdlib/ndarray/base/strides2order' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = any8d( x, predicate ); +* // returns true +*/ +function any8d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // 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 ]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + return false; +} + + +// EXPORTS // + +module.exports = any8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_blocked.js new file mode 100644 index 000000000000..76821b211d4d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_blocked.js @@ -0,0 +1,278 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedany8d( x, predicate ); +* // returns true +*/ +function blockedany8d( x, predicate, thisArg ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ j7+i7, j6+i6, j5+i5, j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_blocked_accessors.js new file mode 100644 index 000000000000..1ff7a8d2b672 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/8d_blocked_accessors.js @@ -0,0 +1,285 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedany8d( x, predicate ); +* // returns true +*/ +function blockedany8d( x, predicate, thisArg ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ j7+i7, j6+i6, j5+i5, j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { + return true; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + } + } + } + } + } + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = blockedany8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d.js new file mode 100644 index 000000000000..c2e0cdebdfde --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d.js @@ -0,0 +1,208 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = any9d( x, predicate ); +* // returns true +*/ +function any9d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // Set a pointer to the first indexed element: + ix = x.offset; + + // Cache a reference to the input ndarray buffer: + xbuf = x.data; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + 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 = any9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_accessors.js new file mode 100644 index 000000000000..569e4199e966 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_accessors.js @@ -0,0 +1,215 @@ +/** +* @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' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var take = require( '@stdlib/array/base/take-indexed' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = any9d( x, predicate ); +* // returns true +*/ +function any9d( x, predicate, thisArg ) { + var xbuf; + var idx; + 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#, 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; + idx = zeroTo( sh.length ); + 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 + idx = reverse( idx ); + } + // 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 ]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + 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 = any9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_blocked.js new file mode 100644 index 000000000000..048aa5ca3a4f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_blocked.js @@ -0,0 +1,297 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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 the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedany9d( x, predicate ); +* // returns true +*/ +function blockedany9d( x, predicate, thisArg ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, xbuf[ ix ], take( [ j8+i8, j7+i7, j6+i6, j5+i5, j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { + 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 = blockedany9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_blocked_accessors.js new file mode 100644 index 000000000000..1ebcd893f652 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/lib/9d_blocked_accessors.js @@ -0,0 +1,304 @@ +/** +* @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' ); +var take = require( '@stdlib/array/base/take-indexed' ); +var reverse = require( '@stdlib/array/base/reverse' ); + + +// MAIN // + +/** +* Tests whether at least one element in an ndarray passes a test implemented by a predicate function via loop blocking. +* +* @private +* @param {Object} x - object containing ndarray meta data +* @param {ndarrayLike} x.ref - reference to the original ndarray-like object +* @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 {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether at least one element passes a test +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function predicate( value ) { +* return value > 0.0; +* } +* +* // 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, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'generic', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major', +* 'accessors': accessors( xbuf ).accessors +* }; +* +* // Test elements: +* var out = blockedany9d( x, predicate ); +* // returns true +*/ +function blockedany9d( x, predicate, thisArg ) { // eslint-disable-line max-statements + var bsize; + var xbuf; + var idx; + 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#, 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; + idx = reverse( o.idx ); + + // 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]; + + // 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 ( predicate.call( thisArg, get( xbuf, ix ), take( [ j8+i8, j7+i7, j6+i6, j5+i5, j4+i4, j3+i3, j2+i2, j1+i1, j0+i0 ], idx ), x.ref ) ) { + 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 = blockedany9d; From 34571b57f9a5afa3ee2839826a1309eee80d56b8 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Thu, 17 Jul 2025 21:56:31 +0000 Subject: [PATCH 6/7] test: add tests upto 10d --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../ndarray/base/any-by/test/test.10d.js | 2655 +++++++++++++++++ .../ndarray/base/any-by/test/test.4d.js | 1577 ++++++++++ .../ndarray/base/any-by/test/test.5d.js | 1771 +++++++++++ .../ndarray/base/any-by/test/test.6d.js | 1917 ++++++++++++ .../ndarray/base/any-by/test/test.7d.js | 2063 +++++++++++++ .../ndarray/base/any-by/test/test.8d.js | 2209 ++++++++++++++ .../ndarray/base/any-by/test/test.9d.js | 2435 +++++++++++++++ 7 files changed, 14627 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.10d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.4d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.5d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.6d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.7d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.8d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/test/test.9d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.10d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.10d.js new file mode 100644 index 000000000000..1ec324ea51d9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.10d.js @@ -0,0 +1,2655 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +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 anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -8, -8, -8, -8, -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 16, 16, 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 16, 16, 8, -8, -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ -8, 8, 4, 4, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ bsize*8, -4, -4, 4, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -4, 4, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, 2, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, bsize*4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2, 1, 1 ]; + st = [ + bsize*8, + -bsize*8, + -bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + 2, + 2, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, bsize*2, 1 ]; + st = [ + bsize*8, + -bsize*8, + -bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + 2, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, 1, bsize*2 ]; + st = [ + bsize*8, + -bsize*8, + -bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -8, -8, -8, -8, -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 16, 16, 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -16, -16, -16, -16, -8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ -8, 8, 4, 4, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 2, 1, 1, 1, 1, 1, 1 ]; + st = [ bsize*8, -4, -4, 2, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -4, 4, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, 2, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, bsize*4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2, 1, 1 ]; + st = [ + bsize*8, + -bsize*8, + -bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + 2, + 2, + 2 + ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, bsize*2, 1 ]; + st = [ + bsize*8, + -bsize*8, + -bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + 2, + 2 + ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, 1, bsize*2 ]; + st = [ + bsize*8, + -bsize*8, + -bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -1, -2, -2, 4, -4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, 2, 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -2, -2, -2, -2, -2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ + 2, + bsize*4, + -bsize*4, + bsize*8, + bsize*8, + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ + 2, + -4, + bsize*8, + bsize*8, + bsize*8, + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ + 2, + -4, + 4, + bsize*8, + bsize*8, + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1, 1, 1, 1, 1 ]; + st = [ + -2, + -4, + 4, + 4, + bsize*8, + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1, 1, 1 ]; + st = [ -2, -4, 4, 8, 8, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1, 1, 1 ]; + st = [ -2, -4, 4, 8, 8, 8, bsize*16, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1, 1, 1 ]; + st = [ -2, -4, 4, 8, 8, 8, 8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2, 1, 1 ]; + st = [ -2, -4, 4, 8, 8, 8, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, bsize*2, 1 ]; + st = [ -2, -4, 4, 8, 8, 8, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, 1, bsize*2 ]; + st = [ -2, -4, 4, 8, 8, 8, 8, 8, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -1, -2, -2, 4, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, 2, 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, 2, 2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ + -2, + -bsize*4, + bsize*4, + bsize*8, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*16, + bsize*16 + ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ + 2, + -4, + bsize*8, + bsize*8, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*16, + bsize*16 + ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ + 2, + 4, + -4, + bsize*8, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*16, + bsize*16 + ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1, 1, 1, 1, 1 ]; + st = [ + 2, + 4, + -4, + 4, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*16, + bsize*16 + ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1, 1, 1 ]; + st = [ 2, 4, -4, 8, 8, bsize*16, bsize*16, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1, 1, 1 ]; + st = [ 2, 4, -4, 8, 8, 8, bsize*16, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1, 1, 1 ]; + st = [ 2, 4, -4, 8, 8, 8, 8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2, 1, 1 ]; + st = [ 2, 4, -4, 8, 8, 8, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, bsize*2, 1 ]; + st = [ 2, 4, -4, 8, 8, 8, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 10-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, 1, bsize*2 ]; + st = [ 2, 4, -4, 8, 8, 8, 8, 8, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.4d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.4d.js new file mode 100644 index 000000000000..5f12223f783f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.4d.js @@ -0,0 +1,1577 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +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 anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0 ], + [ 0, 0, 1, 0 ], + [ 1, 0, 0, 0 ], + [ 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0 ], + [ 0, 0, 1, 0 ], + [ 1, 0, 0, 0 ], + [ 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1 ]; + st = [ bsize*4, -2, -2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + 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, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ -4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1 ]; + st = [ -4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1 ]; + st = [ bsize*4, -2, -2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1 ]; + st = [ bsize*4, -bsize*4, -2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0 ], + [ 1, 0, 0, 0 ], + [ 0, 0, 1, 0 ], + [ 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0 ], + [ 1, 0, 0, 0 ], + [ 0, 0, 1, 0 ], + [ 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ -1, 2, -2, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( 8, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1 ]; + st = [ -2, 4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1 ]; + st = [ -2, 4, 4, bsize*8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2 ]; + st = [ -2, 4, 4, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ -1, -2, 2, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 2, 4, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ -2, 4, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1 ]; + st = [ 2, -4, bsize*8, bsize*8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1 ]; + st = [ 2, -4, 4, bsize*8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 4-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2 ]; + st = [ 2, -4, 4, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.5d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.5d.js new file mode 100644 index 000000000000..741e598b48ff --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.5d.js @@ -0,0 +1,1771 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +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 anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 1 ], + [ 0, 0, 1, 0, 0 ], + [ 0, 0, 1, 0, 1 ], + [ 1, 0, 0, 0, 0 ], + [ 1, 0, 0, 0, 1 ], + [ 1, 0, 1, 0, 0 ], + [ 1, 0, 1, 0, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 1 ], + [ 0, 0, 1, 0, 0 ], + [ 0, 0, 1, 0, 1 ], + [ 1, 0, 0, 0, 0 ], + [ 1, 0, 0, 0, 1 ], + [ 1, 0, 1, 0, 0 ], + [ 1, 0, 1, 0, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ -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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ -8, 8, 4, 4, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 2, 1 ]; + st = [ bsize*8, -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0 ], + [ 1, 0, 0, 0, 0 ], + [ 0, 0, 1, 0, 0 ], + [ 1, 0, 1, 0, 0 ], + [ 0, 0, 0, 0, 1 ], + [ 1, 0, 0, 0, 1 ], + [ 0, 0, 1, 0, 1 ], + [ 1, 0, 1, 0, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0 ], + [ 1, 0, 0, 0, 0 ], + [ 0, 0, 1, 0, 0 ], + [ 1, 0, 1, 0, 0 ], + [ 0, 0, 0, 0, 1 ], + [ 1, 0, 0, 0, 1 ], + [ 0, 0, 1, 0, 1 ], + [ 1, 0, 1, 0, 1 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ -1, -2, -2, 4, 4 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 2, -4, 4, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 5-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.6d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.6d.js new file mode 100644 index 000000000000..3a7228063d15 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.6d.js @@ -0,0 +1,1917 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +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 anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 1, 0, 1, 0 ], + [ 1, 0, 0, 0, 0, 0 ], + [ 1, 0, 0, 0, 1, 0 ], + [ 1, 0, 1, 0, 0, 0 ], + [ 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 1, 0, 1, 0 ], + [ 1, 0, 0, 0, 0, 0 ], + [ 1, 0, 0, 0, 1, 0 ], + [ 1, 0, 1, 0, 0, 0 ], + [ 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ 8, -8, -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1 ]; + st = [ -8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1 ]; + st = [ bsize*8, -4, -4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1 ]; + st = [ bsize*8, -bsize*8, -4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ -8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1 ]; + st = [ -8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 2, 1, 1 ]; + st = [ bsize*8, -4, -4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1 ]; + st = [ bsize*8, -bsize*8, -4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0 ], + [ 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 1, 0, 0, 0 ], + [ 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0 ], + [ 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 1, 0, 1, 0 ], + [ 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0 ], + [ 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 1, 0, 0, 0 ], + [ 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0 ], + [ 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 1, 0, 1, 0 ], + [ 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -2, -2, 4, -4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ -2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1 ]; + st = [ 2, bsize*4, -bsize*4, bsize*8, bsize*8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1 ]; + st = [ 2, -4, bsize*8, bsize*8, bsize*8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1 ]; + st = [ 2, -4, 4, bsize*8, bsize*8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1 ]; + st = [ -2, -4, 4, 4, bsize*8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1 ]; + st = [ -2, -4, 4, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -2, -2, 4, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2, 1 ]; + st = [ 2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1 ]; + st = [ -2, -bsize*4, bsize*4, bsize*8, bsize*8, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1 ]; + st = [ 2, -4, bsize*8, bsize*8, bsize*8, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1 ]; + st = [ 2, 4, -4, bsize*8, bsize*8, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1 ]; + st = [ 2, 4, -4, 4, bsize*8, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1 ]; + st = [ 2, 4, -4, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 6-dimensional ndarray passes a test implemented by a predicate function (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; + + 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 ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.7d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.7d.js new file mode 100644 index 000000000000..685c58df6525 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.7d.js @@ -0,0 +1,2063 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +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 anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 2, 1, 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -8, -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 8, -8, -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1 ]; + st = [ -8, 8, 4, 4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1 ]; + st = [ bsize*8, -4, -4, 4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1 ]; + st = [ bsize*8, -bsize*8, -4, 4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 2, 1, 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -8, -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -16, -8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1 ]; + st = [ -8, 8, 4, 4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 2, 1, 1, 1 ]; + st = [ bsize*8, -4, -4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1 ]; + st = [ bsize*8, -bsize*8, -4, 4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 2, 1, 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -1, -2, -2, 4, -4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -2, -2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1 ]; + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1 ]; + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1 ]; + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1, 1 ]; + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1 ]; + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1 ]; + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2 ]; + st = [ -2, -4, 4, 8, 8, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 2, 1, 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -1, -2, -2, 4, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1 ]; + st = [ -2, -bsize*4, bsize*4, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1 ]; + st = [ 2, -4, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1 ]; + st = [ 2, 4, -4, bsize*8, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1, 1 ]; + st = [ 2, 4, -4, 4, bsize*8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1 ]; + st = [ 2, 4, -4, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1 ]; + st = [ 2, 4, -4, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 7-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2 ]; + st = [ 2, 4, -4, 8, 8, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.8d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.8d.js new file mode 100644 index 000000000000..49a81e1dc416 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.8d.js @@ -0,0 +1,2209 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +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 anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -8, -8, -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 8, -8, -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1 ]; + st = [ -8, 8, 4, 4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1, 1 ]; + st = [ bsize*8, -4, -4, 4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -4, 4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, bsize*4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, bsize*4, bsize*4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -8, -8, -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -16, -16, -8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1 ]; + st = [ -8, 8, 4, 4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 2, 1, 1, 1, 1 ]; + st = [ bsize*8, -4, -4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -4, 4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, bsize*4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -2, -2, 4, -4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -2, -2, -2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1 ]; + st = [ 2, bsize*4, -bsize*4, bsize*8, bsize*8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1, 1 ]; + st = [ 2, -4, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1 ]; + st = [ 2, -4, 4, bsize*8, bsize*8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1, 1, 1 ]; + st = [ -2, -4, 4, 4, bsize*8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1 ]; + st = [ -2, -4, 4, 8, 8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1 ]; + st = [ -2, -4, 4, 8, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1 ]; + st = [ -2, -4, 4, 8, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2 ]; + st = [ -2, -4, 4, 8, 8, 8, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -2, -2, 4, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1 ]; + st = [ -2, -bsize*4, bsize*4, bsize*8, bsize*8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1, 1 ]; + st = [ 2, -4, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1 ]; + st = [ 2, 4, -4, bsize*8, bsize*8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1, 1, 1 ]; + st = [ 2, 4, -4, 4, bsize*8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1 ]; + st = [ 2, 4, -4, 8, 8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1 ]; + st = [ 2, 4, -4, 8, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1 ]; + st = [ 2, 4, -4, 8, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 8-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2 ]; + st = [ 2, 4, -4, 8, 8, 8, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.9d.js b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.9d.js new file mode 100644 index 000000000000..c6f41fe37187 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/test/test.9d.js @@ -0,0 +1,2435 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +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 anyBy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyBy, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (row-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -8, -8, -8, -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 16, 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 16, 8, -8, -4, -4, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1, 1 ]; + st = [ -8, 8, 4, 4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1, 1, 1 ]; + st = [ bsize*8, -4, -4, 4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -4, 4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, bsize*4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2, 1 ]; + st = [ + bsize*8, + -bsize*8, + -bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + 2, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, bsize*2 ]; + st = [ + bsize*8, + -bsize*8, + -bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + 2 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (row-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -8, -8, -8, -4, -4, -2, -2, -1, -1 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 16, 16, 16, 8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -16, -16, -16, -8, 8, 4, 4, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1, 1 ]; + st = [ -8, 8, 4, 4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 2, 1, 1, 1, 1, 1 ]; + st = [ bsize*8, -4, -4, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -4, 4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, 2, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, 2, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, 2, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1, 1 ]; + st = [ bsize*8, -bsize*8, -bsize*4, bsize*4, bsize*4, bsize*4, 2, 2, 2 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2, 1 ]; + st = [ + bsize*8, + -bsize*8, + -bsize*4, + bsize*4, + bsize*4, + bsize*4, + bsize*4, + 2, + 2 + ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, bsize*2 ]; + st = [ + bsize*8, + -bsize*8, + -bsize*4, + bsize*4, + bsize*4, + bsize*4, + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( v ); + indices.push( idx ); + arrays.push( arr ); + return v !== 0.0; + } +}); + +tape( 'the function supports specifying the callback execution context (column-major, contiguous, accessors)', function test( t ) { + var expected; + var indices; + var values; + var arrays; + var actual; + var xbuf; + var ctx; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 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 ); + + indices = []; + values = []; + arrays = []; + + ctx = { + 'count': 0 + }; + actual = anyBy( [ x ], clbk, ctx ); + + t.strictEqual( actual, false, 'returns expected value' ); + t.strictEqual( ctx.count, 8, 'returns expected value' ); + + expected = [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ]; + t.deepEqual( values, expected, 'returns expected value' ); + + expected = [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 1, 0, 1, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 0, 0, 1, 0 ], + [ 0, 0, 0, 0, 0, 1, 0, 1, 0 ], + [ 0, 0, 0, 1, 0, 1, 0, 1, 0 ] + ]; + t.deepEqual( indices, expected, 'returns expected value' ); + + expected = [ + x, + x, + x, + x, + x, + x, + x, + x + ]; + t.deepEqual( arrays, expected, 'returns expected value' ); + + t.end(); + + function clbk( v, idx, arr ) { + this.count += 1; // eslint-disable-line no-invalid-this + values.push( [ real( v ), imag( v ) ] ); + indices.push( idx ); + arrays.push( arr ); + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -2, -2, 4, -4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh ), dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -2, -2, -2, -2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*4, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1, 1 ]; + st = [ + 2, + bsize*4, + -bsize*4, + bsize*8, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*16 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1, 1, 1 ]; + st = [ + 2, + -4, + bsize*8, + bsize*8, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*16 + ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1, 1 ]; + st = [ 2, -4, 4, bsize*8, bsize*8, bsize*16, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1, 1, 1, 1 ]; + st = [ -2, -4, 4, 4, bsize*8, bsize*16, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1, 1 ]; + st = [ -2, -4, 4, 8, 8, bsize*16, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1, 1 ]; + st = [ -2, -4, 4, 8, 8, 8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1, 1 ]; + st = [ -2, -4, 4, 8, 8, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2, 1 ]; + st = [ -2, -4, 4, 8, 8, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, bsize*2 ]; + st = [ -2, -4, 4, 8, 8, 8, 8, 8, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( dt, ones( numel( sh )*2, dt ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0; + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (column-major, contiguous, accessors)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 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 ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -2, -2, 4, 4, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*2, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, 2, 4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 1, 2, 1, 2, 1 ]; + st = [ 2, 2, 2, 2, -4, 4, 8, 8, 16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( 8*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 2, 1, 1, 1, 1 ]; + st = [ + -2, + -bsize*4, + bsize*4, + bsize*8, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*16 + ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 2, 1, 1, 1, 1 ]; + st = [ + 2, + -4, + bsize*8, + bsize*8, + bsize*8, + bsize*16, + bsize*16, + bsize*16, + bsize*16 + ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, bsize*2, 1, 2, 1, 1, 1, 1 ]; + st = [ 2, 4, -4, bsize*8, bsize*8, bsize*16, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 1, bsize*2, 2, 1, 1, 1, 1 ]; + st = [ 2, 4, -4, 4, bsize*8, bsize*16, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, bsize*2, 1, 1, 1, 1 ]; + st = [ 2, 4, -4, 8, 8, bsize*16, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, bsize*2, 1, 1, 1 ]; + st = [ 2, 4, -4, 8, 8, 8, bsize*16, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, bsize*2, 1, 1 ]; + st = [ 2, 4, -4, 8, 8, 8, 8, bsize*16, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, bsize*2, 1 ]; + st = [ 2, 4, -4, 8, 8, 8, 8, 8, bsize*16 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); + +tape( 'the function tests whether at least one element in a 9-dimensional ndarray passes a test implemented by a predicate function (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; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 1, 1, 1, bsize*2 ]; + st = [ 2, 4, -4, 8, 8, 8, 8, 8, 8 ]; + o = strides2offset( sh, st ); + + xbuf = zeros( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + xbuf = ones( numel( sh )*4, 'float64' ); + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + actual = anyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); + } +}); From 9227d0eaf1ae8455106d35fdcf0a14c9bdc8a8f6 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Fri, 18 Jul 2025 07:11:17 +0000 Subject: [PATCH 7/7] bench: add benchmarks upto 11d --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../benchmark.10d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.10d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.10d_columnmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.10d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.11d_columnmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.11d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark.4d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.4d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.4d_columnmajor.js | 143 ++++++++++++++++++ .../any-by/benchmark/benchmark.4d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark.5d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.5d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.5d_columnmajor.js | 143 ++++++++++++++++++ .../any-by/benchmark/benchmark.5d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark.6d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.6d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.6d_columnmajor.js | 143 ++++++++++++++++++ .../any-by/benchmark/benchmark.6d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark.7d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.7d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.7d_columnmajor.js | 143 ++++++++++++++++++ .../any-by/benchmark/benchmark.7d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark.8d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.8d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.8d_columnmajor.js | 143 ++++++++++++++++++ .../any-by/benchmark/benchmark.8d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark.9d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.9d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.9d_columnmajor.js | 143 ++++++++++++++++++ .../any-by/benchmark/benchmark.9d_rowmajor.js | 143 ++++++++++++++++++ 30 files changed, 4290 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.11d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.11d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_rowmajor.js diff --git a/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_blocked_columnmajor.js new file mode 100644 index 000000000000..8be1711b4b0c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_blocked_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/10d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.10d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_blocked_rowmajor.js new file mode 100644 index 000000000000..1a937a766b31 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_blocked_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/10d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.10d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_columnmajor.js new file mode 100644 index 000000000000..3049ccd5d455 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/10d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.10d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_rowmajor.js new file mode 100644 index 000000000000..390480358153 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.10d_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/10d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.11d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.11d_columnmajor.js new file mode 100644 index 000000000000..299180b49b3e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.11d_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/nd.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.11d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.11d_rowmajor.js new file mode 100644 index 000000000000..5b9a1535107c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.11d_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/nd.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.4d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_blocked_columnmajor.js new file mode 100644 index 000000000000..93454fc60741 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_blocked_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/4d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.4d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_blocked_rowmajor.js new file mode 100644 index 000000000000..07b8dd4c22a4 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_blocked_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/4d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.4d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_columnmajor.js new file mode 100644 index 000000000000..631cd65e9408 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/4d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.4d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_rowmajor.js new file mode 100644 index 000000000000..f4fc67689f83 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.4d_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/4d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.5d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_blocked_columnmajor.js new file mode 100644 index 000000000000..d372944806aa --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_blocked_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/5d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.5d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_blocked_rowmajor.js new file mode 100644 index 000000000000..7610f3ca1adf --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_blocked_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/5d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.5d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_columnmajor.js new file mode 100644 index 000000000000..39f3d620e4d1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/5d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.5d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_rowmajor.js new file mode 100644 index 000000000000..95ab2baa080a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.5d_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/5d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.6d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_blocked_columnmajor.js new file mode 100644 index 000000000000..3d22c15eb582 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_blocked_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/6d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.6d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_blocked_rowmajor.js new file mode 100644 index 000000000000..b96745afe87b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_blocked_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/6d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.6d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_columnmajor.js new file mode 100644 index 000000000000..c5f9f47efa2e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/6d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.6d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_rowmajor.js new file mode 100644 index 000000000000..e7c9121993ef --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.6d_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/6d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.7d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_blocked_columnmajor.js new file mode 100644 index 000000000000..8053363170bd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_blocked_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/7d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.7d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_blocked_rowmajor.js new file mode 100644 index 000000000000..cf21ae14068d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_blocked_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/7d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.7d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_columnmajor.js new file mode 100644 index 000000000000..9347636441c9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/7d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.7d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_rowmajor.js new file mode 100644 index 000000000000..bfe7ca9d008d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.7d_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/7d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.8d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_blocked_columnmajor.js new file mode 100644 index 000000000000..beace1cf14e9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_blocked_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/8d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.8d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_blocked_rowmajor.js new file mode 100644 index 000000000000..beace1cf14e9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_blocked_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/8d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.8d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_columnmajor.js new file mode 100644 index 000000000000..0f931cfcbd64 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/8d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.8d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_rowmajor.js new file mode 100644 index 000000000000..50a459a4073f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.8d_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/8d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.9d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_blocked_columnmajor.js new file mode 100644 index 000000000000..dba659a273cc --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_blocked_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/9d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.9d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_blocked_rowmajor.js new file mode 100644 index 000000000000..2bbd5355b5f8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_blocked_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/9d_blocked.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.9d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_columnmajor.js new file mode 100644 index 000000000000..583166eb6e8b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_columnmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/9d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'column-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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/any-by/benchmark/benchmark.9d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_rowmajor.js new file mode 100644 index 000000000000..14639131aef2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/any-by/benchmark/benchmark.9d_rowmajor.js @@ -0,0 +1,143 @@ +/** +* @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 anyBy = require( './../lib/9d.js' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var order = 'row-major'; + + +// FUNCTIONS // + +/** +* Callback function. +* +* @param {*} value - ndarray element +* @returns {boolean} result +*/ +function clbk( value ) { + return value < 0.0; +} + +/** +* 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 = anyBy( x, clbk ); + 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();