From 933e7a1ef9f02ac01ec856c5f9e6707cff8cf299 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Sun, 13 Apr 2025 10:41:26 +0000 Subject: [PATCH 01/25] feat: add every-by initial implementation --- 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/every-by/README.md | 207 ++++++++++++ .../benchmark/benchmark.1d_columnmajor.js | 132 ++++++++ .../benchmark/benchmark.1d_rowmajor.js | 132 ++++++++ .../benchmark.2d_blocked_columnmajor.js | 144 +++++++++ .../benchmark.2d_blocked_rowmajor.js | 144 +++++++++ .../benchmark/benchmark.2d_columnmajor.js | 144 +++++++++ .../benchmark/benchmark.2d_rowmajor.js | 144 +++++++++ .../benchmark.2d_rowmajor_accessors.js | 170 ++++++++++ ...benchmark.2d_rowmajor_accessors_complex.js | 172 ++++++++++ .../benchmark.3d_blocked_columnmajor.js | 144 +++++++++ .../benchmark.3d_blocked_rowmajor.js | 144 +++++++++ .../benchmark/benchmark.3d_columnmajor.js | 144 +++++++++ .../benchmark/benchmark.3d_rowmajor.js | 144 +++++++++ .../ndarray/base/every-by/docs/repl.txt | 72 +++++ .../base/every-by/docs/types/index.d.ts | 103 ++++++ .../ndarray/base/every-by/docs/types/test.ts | 126 ++++++++ .../ndarray/base/every-by/examples/index.js | 42 +++ .../@stdlib/ndarray/base/every-by/lib/0d.js | 83 +++++ .../ndarray/base/every-by/lib/0d_accessors.js | 86 +++++ .../ndarray/base/every-by/lib/0d_complex.js | 83 +++++ .../@stdlib/ndarray/base/every-by/lib/1d.js | 105 ++++++ .../ndarray/base/every-by/lib/1d_accessors.js | 112 +++++++ .../ndarray/base/every-by/lib/1d_complex.js | 105 ++++++ .../@stdlib/ndarray/base/every-by/lib/2d.js | 136 ++++++++ .../ndarray/base/every-by/lib/2d_accessors.js | 143 +++++++++ .../ndarray/base/every-by/lib/2d_blocked.js | 162 ++++++++++ .../base/every-by/lib/2d_blocked_accessors.js | 169 ++++++++++ .../base/every-by/lib/2d_blocked_complex.js | 161 ++++++++++ .../ndarray/base/every-by/lib/2d_complex.js | 136 ++++++++ .../@stdlib/ndarray/base/every-by/lib/3d.js | 146 +++++++++ .../ndarray/base/every-by/lib/3d_accessors.js | 153 +++++++++ .../ndarray/base/every-by/lib/3d_blocked.js | 183 +++++++++++ .../base/every-by/lib/3d_blocked_accessors.js | 190 +++++++++++ .../base/every-by/lib/3d_blocked_complex.js | 183 +++++++++++ .../ndarray/base/every-by/lib/3d_complex.js | 146 +++++++++ .../ndarray/base/every-by/lib/index.js | 69 ++++ .../@stdlib/ndarray/base/every-by/lib/main.js | 298 ++++++++++++++++++ .../@stdlib/ndarray/base/every-by/lib/nd.js | 127 ++++++++ .../ndarray/base/every-by/lib/nd_accessors.js | 134 ++++++++ .../ndarray/base/every-by/lib/nd_complex.js | 127 ++++++++ .../ndarray/base/every-by/package.json | 66 ++++ .../ndarray/base/every-by/test/test.0d.js | 109 +++++++ .../ndarray/base/every-by/test/test.js | 33 ++ 43 files changed, 5753 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.1d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.1d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_rowmajor_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_rowmajor_accessors_complex.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.3d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.3d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.3d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.3d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_complex.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_complex.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_complex.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_complex.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_complex.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_complex.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_complex.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/README.md b/lib/node_modules/@stdlib/ndarray/base/every-by/README.md new file mode 100644 index 000000000000..9b927d948659 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/README.md @@ -0,0 +1,207 @@ + + +# everyBy + +> Test whether every element in an ndarray is truthy according to a callback function. + +
+ +
+ + + +
+ +## Usage + +```javascript +var everyBy = require( '@stdlib/ndarray/base/every-by' ); +``` + +#### everyBy( arrays, clbk\[, thisArg] ) + +Tests whether every element in an ndarray is truthy according to a callback 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 = everyBy( [ x ], clbk ); +// returns true +``` + +The function accepts the following arguments: + +- **arrays**: array-like object containing an input ndarray. +- **clbk**: callback to apply. +- **thisArg**: callback 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 callback function is provided the following arguments: + +- **value**: current array element. +- **indices**: current array element indices. +- **arr**: the input ndarray. + +To set the callback 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 = everyBy( [ x ], clbk, ctx ); +// returns true + +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. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var everyBy = require( '@stdlib/ndarray/base/every-by' ); + +function clbk( value ) { + return value > 0; +} + +var x = { + 'dtype': 'generic', + 'data': discreteUniform( 12, -2, 10, { + 'dtype': 'generic' + }), + 'shape': [ 5, 2 ], + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) ); + +var out = everyBy( [ x ], clbk ); +console.log( out ); +``` + +
+ + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.1d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.1d_columnmajor.js new file mode 100644 index 000000000000..4709acc1b1cd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( [ 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/every-by/benchmark/benchmark.1d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.1d_rowmajor.js new file mode 100644 index 000000000000..9e21fb417aa5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( [ 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/every-by/benchmark/benchmark.2d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_blocked_columnmajor.js new file mode 100644 index 000000000000..5313bef691cb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.2d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_blocked_rowmajor.js new file mode 100644 index 000000000000..9ed58a1d962e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.2d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_columnmajor.js new file mode 100644 index 000000000000..9337de4706a6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.2d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_rowmajor.js new file mode 100644 index 000000000000..4707ba2c8c29 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.2d_rowmajor_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_rowmajor_accessors.js new file mode 100644 index 000000000000..8e7d4b04678c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.2d_rowmajor_accessors_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_rowmajor_accessors_complex.js new file mode 100644 index 000000000000..4ee980f32b72 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_rowmajor_accessors_complex.js @@ -0,0 +1,172 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ctors = require( '@stdlib/array/typed-complex-ctors' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var pkg = require( './../package.json' ).name; +var everyBy = require( './../lib/2d_accessors.js' ); + + +// VARIABLES // + +var types = [ 'complex64' ]; +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.get( idx ); +} + +/** +* Sets an array data buffer element. +* +* @private +* @param {Collection} buf - data buffer +* @param {NonNegativeInteger} idx - element index +* @param {*} value - value to set +*/ +function set( buf, idx, value ) { + buf.set( value, idx ); +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - ndarray data type +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype ) { + var xbuf; + var x; + + xbuf = discreteUniform( len*2, 1, 100 ); + x = { + 'dtype': xtype, + 'data': new ( ctors( xtype ) )( xbuf.buffer ), + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order, + 'accessorProtocol': true, + 'accessors': [ get, set ] + }; + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = everyBy( 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 = 5; // 10^max + + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t1 ); + bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.3d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.3d_blocked_columnmajor.js new file mode 100644 index 000000000000..009b77488d9d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.3d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.3d_blocked_rowmajor.js new file mode 100644 index 000000000000..e03d0f9c8d0c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.3d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.3d_columnmajor.js new file mode 100644 index 000000000000..5ff61d4e4203 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.3d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.3d_rowmajor.js new file mode 100644 index 000000000000..554138da4fe1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/repl.txt new file mode 100644 index 000000000000..db6a21030c32 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/repl.txt @@ -0,0 +1,72 @@ + +{{alias}}( arrays, clbk[, thisArg] ) + Tests whether every element in an ndarray is truthy according to a callback + 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 callback function is provided the following arguments: + + - value: current array element. + - indices: current array element indices. + - arr: the input ndarray. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing an input ndarray. + + clbk: Function + Callback function. + + thisArg: any (optional) + Callback execution context. + + Returns + ------- + out: boolean + Boolean indicating whether every element in an ndarray is truthy + according to a callback function. + + Examples + -------- + // Define ndarray data and meta data... + > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0, 1.0, 1.0 ] ); + > var dtype = 'float64'; + > var shape = [ 2, 2 ]; + > var sx = [ 2, 1 ]; + > var ox = 0; + > var order = 'row-major'; + + // Define a callback... + > function clbk( v ) { return v > 0.0; }; + + // Using an ndarray... + > var x = {{alias:@stdlib/ndarray/ctor}}( dtype, xbuf, shape, sx, ox, order ); + > {{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': dtype, + ... 'data': xbuf, + ... 'shape': shape, + ... 'strides': sx, + ... 'offset': ox, + ... 'order': order + ... }; + > {{alias}}( [ x ], clbk ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/index.d.ts new file mode 100644 index 000000000000..862ccf8eb7ae --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/index.d.ts @@ -0,0 +1,103 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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'; + +/** +* Callback invoked for each ndarray element. +*/ +type Nullary = ( this: U ) => void; + +/** +* Callback invoked for each ndarray element. +* +* @param value - current array element +*/ +type Unary = ( this: U, value: T ) => void; + +/** +* Callback invoked for each ndarray element. +* +* @param value - current array element +* @param indices - current array element indices +*/ +type Binary = ( this: U, value: T, indices: Array ) => void; + +/** +* Callback invoked for each ndarray element. +* +* @param value - current array element +* @param indices - current array element indices +* @param arr - input array +*/ +type Ternary = ( this: U, value: T, indices: Array, arr: typedndarray ) => void; + +/** +* Callback invoked for each ndarray element. +* +* @param value - current array element +* @param indices - current array element indices +* @param arr - input array +*/ +type Callback = Nullary | Unary | Binary | Ternary; + +/** +* Tests whether every element in an ndarray is truthy according to a callback function. +* +* @param arrays - array-like object containing an output ndarray +* @param clbk - callback function +* @param thisArg - callback execution context +* @returns result +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function clbk( value ) { +* return value > 0.0; +* } +* +* // Create data buffers: +* 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 output ndarray: +* var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); +* +* // Apply the callback function: +* var out = everyBy( [ x ], clbk ); +* // returns true +*/ +declare function everyBy( arrays: ArrayLike>, clbk: Callback, thisArg?: ThisParameterType> ): Boolean; + + +// EXPORTS // + +export = everyBy; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts new file mode 100644 index 000000000000..ffafc2561987 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts @@ -0,0 +1,126 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 { ndarray } from '@stdlib/types/ndarray'; +import everyBy = require( './index' ); + +/** +* Mock function to create an ndarray-like object. +* +* @returns ndarray-like object +*/ +function array(): ndarray { + const obj: ndarray = { + 'byteLength': 80, + 'BYTES_PER_ELEMENT': 8, + 'data': new Float64Array( 10 ), + 'dtype': 'float64', + 'flags': { + 'ROW_MAJOR_CONTIGUOUS': true, + 'COLUMN_MAJOR_CONTIGUOUS': false + }, + 'length': 10, + 'ndims': 1, + 'offset': 0, + 'order': 'row-major', + 'shape': [ 10 ], + 'strides': [ 1 ], + 'get': (): number => 0, + 'set': (): ndarray => obj + }; + return obj; +} + +/** +* Callback function. +* +* @param v - ndarray element +* @returns result +*/ +function clbk( v: any ): Boolean { + return v > 0.0; +} + + +// TESTS // + +// The function returns a `Boolean`... +{ + const x = array(); + const arrays = [ x ]; + + everyBy( arrays, clbk ); // $ExpectType Boolean + everyBy( 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... +{ + everyBy( 5, clbk ); // $ExpectError + everyBy( true, clbk ); // $ExpectError + everyBy( false, clbk ); // $ExpectError + everyBy( null, clbk ); // $ExpectError + everyBy( undefined, clbk ); // $ExpectError + everyBy( {}, clbk ); // $ExpectError + everyBy( [ 1 ], clbk ); // $ExpectError + everyBy( ( x: number ): number => x, clbk ); // $ExpectError + + everyBy( 5, clbk, {} ); // $ExpectError + everyBy( true, clbk, {} ); // $ExpectError + everyBy( false, clbk, {} ); // $ExpectError + everyBy( null, clbk, {} ); // $ExpectError + everyBy( undefined, clbk, {} ); // $ExpectError + everyBy( {}, clbk, {} ); // $ExpectError + everyBy( [ 1 ], clbk, {} ); // $ExpectError + everyBy( ( 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 = array(); + const arrays = [ x ]; + + everyBy( arrays, '10' ); // $ExpectError + everyBy( arrays, 5 ); // $ExpectError + everyBy( arrays, true ); // $ExpectError + everyBy( arrays, false ); // $ExpectError + everyBy( arrays, null ); // $ExpectError + everyBy( arrays, undefined ); // $ExpectError + everyBy( arrays, [] ); // $ExpectError + everyBy( arrays, {} ); // $ExpectError + + everyBy( arrays, '10', {} ); // $ExpectError + everyBy( arrays, 5, {} ); // $ExpectError + everyBy( arrays, true, {} ); // $ExpectError + everyBy( arrays, false, {} ); // $ExpectError + everyBy( arrays, null, {} ); // $ExpectError + everyBy( arrays, undefined, {} ); // $ExpectError + everyBy( arrays, [], {} ); // $ExpectError + everyBy( arrays, {}, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = array(); + const arrays = [ x ]; + + everyBy(); // $ExpectError + everyBy( arrays ); // $ExpectError + everyBy( arrays, clbk, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/every-by/examples/index.js new file mode 100644 index 000000000000..ee8a240e7353 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = require( './../lib' ); + +function clbk( value ) { + return value > 0; +} + +var x = { + 'dtype': 'generic', + 'data': discreteUniform( 12, -2, 10, { + 'dtype': 'generic' + }), + 'shape': [ 5, 2 ], + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) ); + +var out = everyBy( [ x ], clbk ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d.js new file mode 100644 index 000000000000..eac091aabb5d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // 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 = every0d( x, clbk ); +* // returns true +*/ +function every0d( x, clbk, thisArg ) { + if ( clbk.call( thisArg, x.data[ x.offset ], [], x.ref ) ) { + return true; + } + return false; +} + + +// EXPORTS // + +module.exports = every0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_accessors.js new file mode 100644 index 000000000000..2ad13156cea5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 = every0d( x, clbk ); +* // returns true +*/ +function every0d( x, clbk, thisArg ) { + if ( clbk.call( thisArg, x.accessors[ 0 ]( x.data, x.offset ), [], x.ref ) ) { // eslint-disable-line max-len + return true; + } + return false; +} + + +// EXPORTS // + +module.exports = every0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_complex.js new file mode 100644 index 000000000000..58af67f31908 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_complex.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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // Define the shape of the input array: +* var shape = []; +* +* // Define the array strides: +* var sx = [ 0 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = every0d( x, clbk ); +* // returns true +*/ +function every0d( x, clbk, thisArg ) { + if ( clbk.call( thisArg, x.data[ x.offset ], [], x.ref ) || clbk.call( thisArg, x.data[ x.offset + 1 ], [], x.ref ) ) { // eslint-disable-line max-len + return true; + } + return false; +} + + +// EXPORTS // + +module.exports = every0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js new file mode 100644 index 000000000000..294a40ceaa21 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // 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 = every1d( x, clbk ); +* // returns true +*/ +function every1d( x, clbk, 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 ( !clbk.call( thisArg, xbuf[ ix ], ix, x.ref ) ) { + return false; + } + ix += dx0; + } + return true; +} + + +// EXPORTS // + +module.exports = every1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_accessors.js new file mode 100644 index 000000000000..ad91f3e8ece9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 = [ 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 = every1d( x, clbk ); +* // returns true +*/ +function every1d( x, clbk, thisArg ) { + var xbuf; + var get; + var dx0; + var S0; + var ix; + var i0; + + // Note on variable naming convention: S#, dx#, dy#, 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 ( !clbk.call( thisArg, get( xbuf, ix ), ix, x.ref) ) { + return false; + } + ix += dx0; + } + return true; +} + + +// EXPORTS // + +module.exports = every1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_complex.js new file mode 100644 index 000000000000..8f4fa37bea7a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_complex.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Tests whether every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // 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': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = every1d( x, clbk ); +* // returns true +*/ +function every1d( x, clbk, 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 ( !( clbk.call( thisArg, xbuf[ ix ], ix, x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], ix, x.ref ) ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + return true; +} + + +// EXPORTS // + +module.exports = every1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d.js new file mode 100644 index 000000000000..432250cb5ad9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // 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 = every2d( x, clbk ); +* // returns true +*/ +function every2d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + return true; +} + + +// EXPORTS // + +module.exports = every2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_accessors.js new file mode 100644 index 000000000000..8fb2047b1e42 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 = [ 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 = every2d( x, clbk ); +* // returns true +*/ +function every2d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + return true; +} + + +// EXPORTS // + +module.exports = every2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked.js new file mode 100644 index 000000000000..719639841cf3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // 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 = blockedevery2d( x, clbk ); +* // returns true +*/ +function blockedevery2d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js new file mode 100644 index 000000000000..706b3c6e8391 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 = [ 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 = blockedevery2d( x, clbk ); +* // returns true +*/ +function blockedevery2d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_complex.js new file mode 100644 index 000000000000..6abecf9a4945 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_complex.js @@ -0,0 +1,161 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedevery2d( x, clbk ); +* // returns true +*/ +function blockedevery2d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !( clbk.call( thisArg, xbuf[ ix ], take( [ i1, i0 ], idx ), x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], take( [ i1, i0 ], idx ), x.ref ) ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_complex.js new file mode 100644 index 000000000000..07a0f90ad01e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_complex.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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = every2d( x, clbk ); +* // returns true +*/ +function every2d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !( clbk.call( thisArg, xbuf[ ix ], take( [ i1, i0 ], idx ), x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], take( [ i1, i0 ], idx ), x.ref ) ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + return true; +} + + +// EXPORTS // + +module.exports = every2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d.js new file mode 100644 index 000000000000..ffa3ceb9d01b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = 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 = every3d( x, clbk ); +* // returns true +*/ +function every3d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + return true; +} + + +// EXPORTS // + +module.exports = every3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_accessors.js new file mode 100644 index 000000000000..ef4ae71f8f0f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // 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 = every3d( x, clbk ); +* // returns true +*/ +function every3d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + return true; +} + + +// EXPORTS // + +module.exports = every3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked.js new file mode 100644 index 000000000000..76b8d3fae84f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = 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 = blockedevery3d( x, clbk ); +* // returns true +*/ +function blockedevery3d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js new file mode 100644 index 000000000000..a5b2a1419902 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // 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 = blockedevery3d( x, clbk ); +* // returns true +*/ +function blockedevery3d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_complex.js new file mode 100644 index 000000000000..a4acd4ffb927 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_complex.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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = blockedevery3d( x, clbk ); +* // returns true +*/ +function blockedevery3d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !( clbk.call( thisArg, xbuf[ ix ], take( [ i2, i1, i0 ], idx ), x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], take( [ i2, i1, i0 ], idx ), x.ref ) ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_complex.js new file mode 100644 index 000000000000..62e2ac0908b5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_complex.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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // Define the shape of the input array: +* var shape = [ 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = every3d( x, clbk ); +* // returns true +*/ +function every3d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !( clbk.call( thisArg, xbuf[ ix ], take( [ i2, i1, i0 ], idx ), x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], take( [ i2, i1, i0 ], idx ), x.ref ) ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + return true; +} + + +// EXPORTS // + +module.exports = every3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/index.js new file mode 100644 index 000000000000..8c14c77d65dc --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback function. +* +* @module @stdlib/ndarray/base/every-by +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var everyBy = require( '@stdlib/ndarray/base/every-by' ); +* +* 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 = 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 = everyBy( [ x ], clbk ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js new file mode 100644 index 000000000000..c2a07d3605d6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js @@ -0,0 +1,298 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isComplexArray = require( '@stdlib/array/base/assert/is-complex-typed-array' ); +var isBooleanArray = require( '@stdlib/array/base/assert/is-booleanarray' ); +var iterationOrder = require( '@stdlib/ndarray/base/iteration-order' ); +var minmaxViewBufferIndex = require( '@stdlib/ndarray/base/minmax-view-buffer-index' ); +var ndarray2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); +var reinterpretComplex = require( '@stdlib/strided/base/reinterpret-complex' ); +var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); +var gscal = require( '@stdlib/blas/base/gscal' ); +var blockedaccessorevery2d = require( './2d_blocked_accessors.js' ); +var blockedaccessorevery3d = require( './3d_blocked_accessors.js' ); +var blockedcomplexevery2d = require( './2d_blocked_complex.js' ); +var blockedcomplexevery3d = require( './3d_blocked_complex.js' ); +var blockedevery2d = require( './2d_blocked.js' ); +var blockedevery3d = require( './3d_blocked.js' ); +var accessorevery0d = require( './0d_accessors.js' ); +var accessorevery1d = require( './1d_accessors.js' ); +var accessorevery2d = require( './2d_accessors.js' ); +var accessorevery3d = require( './3d_accessors.js' ); +var accessoreverynd = require( './nd_accessors.js' ); +var complexevery0d = require( './0d_complex.js' ); +var complexevery1d = require( './1d_complex.js' ); +var complexevery2d = require( './2d_complex.js' ); +var complexevery3d = require( './3d_complex.js' ); +var complexeverynd = require( './nd_complex.js' ); +var every0d = require( './0d.js' ); +var every1d = require( './1d.js' ); +var every2d = require( './2d.js' ); +var every3d = require( './3d.js' ); +var everynd = require( './nd.js' ); + + +// VARIABLES // + +var EVERY = [ + every0d, + every1d, + every2d, + every3d +]; +var ACCESSOR_EVERY = [ + accessorevery0d, + accessorevery1d, + accessorevery2d, + accessorevery3d +]; +var COMPLEX_EVERY = [ + complexevery0d, + complexevery1d, + complexevery2d, + complexevery3d +]; +var BLOCKED_EVERY = [ + blockedevery2d, // 0 + blockedevery3d +]; +var BLOCKED_ACCESSOR_EVERY = [ + blockedaccessorevery2d, // 0 + blockedaccessorevery3d +]; +var BLOCKED_COMPLEX_EVERY = [ + blockedcomplexevery2d, // 0 + blockedcomplexevery3d +]; +var MAX_DIMS = EVERY.length - 1; + + +// MAIN // + +/** +* Tests whether every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {thisArg} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = 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 = everyBy( [ x ], clbk ); +* // returns true +*/ +function everyBy( arrays, clbk, thisArg ) { + var isCmplx; + var ndims; + var xmmv; + var shx; + var iox; + var len; + var sx; + var ox; + var ns; + var x; + var d; + var i; + + // Unpack the ndarray and standardize ndarray meta data: + x = ndarray2object( arrays[ 0 ] ); + shx = x.shape; + ndims = shx.length; + + // Check for known array types which can be reinterpreted for better iteration performance... + if ( isBooleanArray( x.data ) ) { + x.data = reinterpretBoolean( x.data, 0 ); + x.accessorProtocol = false; + } else if ( isComplexArray( x.data ) ) { + x.data = reinterpretComplex( x.data, 0 ); + x.accessorProtocol = false; + x.strides = gscal( ndims, 2, x.strides, 1 ); + x.offset *= 2; + isCmplx = true; + } + // Determine whether we can avoid iteration altogether... + if ( ndims === 0 ) { + if ( x.accessorProtocol ) { + return ACCESSOR_EVERY[ ndims ]( x, clbk, thisArg ); + } + if ( isCmplx ) { + return COMPLEX_EVERY[ ndims ]( x, clbk, thisArg ); + } + return EVERY[ ndims ]( x, clbk, thisArg ); + } + // Compute the number of elements and the number of singleton dimensions... + len = 1; // number of elements + ns = 0; // number of singleton dimensions + for ( i = 0; i < ndims; i++ ) { + d = shx[ i ]; + + // Note that, if one of the dimensions is `0`, the length will be `0`... + len *= d; + + // Check whether the current dimension is a singleton dimension... + if ( d === 1 ) { + ns += 1; + } + } + // Check whether we were provided an empty ndarray... + if ( len === 0 ) { + return true; + } + // Determine whether the ndarray is one-dimensional and thus readily translates to a one-dimensional strided array... + if ( ndims === 1 ) { + if ( x.accessorProtocol ) { + return ACCESSOR_EVERY[ ndims ]( x, clbk, thisArg ); + } + if ( isCmplx ) { + return COMPLEX_EVERY[ ndims ]( x, clbk, thisArg ); + } + return EVERY[ ndims ]( x, clbk, thisArg ); + } + sx = x.strides; + + // Determine whether the ndarray has only **one** non-singleton dimension (e.g., ndims=4, shape=[10,1,1,1]) so that we can treat an ndarray as being equivalent to a one-dimensional strided array... + if ( ns === ndims-1 ) { + // Get the index of the non-singleton dimension... + for ( i = 0; i < ndims; i++ ) { + if ( shx[ i ] !== 1 ) { + break; + } + } + x.shape = [ shx[i] ]; + x.strides = [ sx[i] ]; + if ( x.accessorProtocol ) { + return ACCESSOR_EVERY[ 1 ]( x, clbk, thisArg ); + } + if ( isCmplx ) { + return COMPLEX_EVERY[ 1 ]( x, clbk, thisArg ); + } + return EVERY[ 1 ]( x, clbk, thisArg ); + } + iox = iterationOrder( sx ); // +/-1 + + // Determine whether we can avoid blocked iteration... + if ( iox !== 0 ) { + // Determine the minimum and maximum linear indices which are accessible by the array view: + xmmv = minmaxViewBufferIndex( shx, sx, x.offset ); + + // Determine whether we can ignore shape (and strides) and treat the ndarray as a linear one-dimensional strided array... + if ( len === ( xmmv[1]-xmmv[0]+1 ) || ( isCmplx && len*2 === ( xmmv[1]-xmmv[0]+1 ) ) ) { // eslint-disable-line max-len + // Note: the above is equivalent to @stdlib/ndarray/base/assert/is-contiguous, but in-lined so we can retain computed values... + if ( iox === 1 ) { + ox = xmmv[ 0 ]; + } else { + ox = xmmv[ 1 ]; + } + x.shape = [ len ]; + x.strides = [ ( isCmplx ) ? iox*2 : iox ]; + x.offset = ox; + if ( x.accessorProtocol ) { + return ACCESSOR_EVERY[ 1 ]( x, clbk, thisArg ); + } + if ( isCmplx ) { + return COMPLEX_EVERY[ 1 ]( x, clbk, thisArg ); + } + return EVERY[ 1 ]( x, clbk, thisArg ); + } + // The ndarray is non-contiguous, so we cannot directly use one-dimensional array functionality... + + // Determine whether we can use simple nested loops... + if ( ndims <= MAX_DIMS ) { + // So long as iteration always moves in the same direction (i.e., no mixed sign strides), we can leverage cache-optimal (i.e., normal) nested loops without resorting to blocked iteration... + if ( x.accessorProtocol ) { + return ACCESSOR_EVERY[ ndims ]( x, clbk, thisArg ); + } + if ( isCmplx ) { + return COMPLEX_EVERY[ ndims ]( x, clbk, thisArg ); + } + return EVERY[ ndims ]( x, clbk, thisArg ); + } + // Fall-through to blocked iteration... + } + // At this point, we're either dealing with a non-contiguous n-dimensional array or a high dimensional n-dimensional array, so our only hope is that we can still perform blocked iteration... + + // Determine whether we can perform blocked iteration... + if ( ndims <= MAX_DIMS ) { + if ( x.accessorProtocol ) { + return BLOCKED_ACCESSOR_EVERY[ ndims-2 ]( x, clbk, thisArg ); + } + if ( isCmplx ) { + return BLOCKED_COMPLEX_EVERY[ ndims-2 ]( x, clbk, thisArg ); + } + return BLOCKED_EVERY[ ndims-2 ]( x, clbk, 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 accessoreverynd( x, clbk, thisArg ); + } + if ( isCmplx ) { + return complexeverynd( x, clbk, thisArg ); + } + return everynd( x, clbk, thisArg ); +} + + +// EXPORTS // + +module.exports = everyBy; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js new file mode 100644 index 000000000000..7581e861700f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // 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 = everynd( x, clbk ); +* // returns true +*/ +function everynd( x, clbk, 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 output ndarray data buffer: + xbuf = x.data; + + // Cache a reference to the stride array: + sx = x.strides; + + // Cache the index of the first indexed element: + ox = x.offset; + + // Cache the array order: + ordx = x.order; + + // 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 ( !clbk.call( thisArg, xbuf[ ix ], idx, x.ref ) ) { + return false; + } + } + return true; +} + + +// EXPORTS // + +module.exports = everynd; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_accessors.js new file mode 100644 index 000000000000..b0753eb9051e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 = everynd( x, clbk ); +* // returns true +*/ +function everynd( x, clbk, 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 output ndarray data buffer: + xbuf = x.data; + + // Cache a reference to the stride array: + sx = x.strides; + + // Cache the index of the first indexed element: + ox = x.offset; + + // Cache the array order: + ordx = x.order; + + // 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 ( !clbk.call( thisArg, get( xbuf, ix ), idx, x.ref ) ) { + return false; + } + } + return true; +} + + +// EXPORTS // + +module.exports = everynd; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_complex.js new file mode 100644 index 000000000000..abeb8ed9f970 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_complex.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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 ] ); +* +* // Define the shape of the input array: +* var shape = [ 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 2 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create the input ndarray-like object: +* var x = { +* 'ref': null, +* 'dtype': 'complex128', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* +* // Test elements: +* var out = everynd( x, clbk ); +* // returns true +*/ +function everynd( x, clbk, 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 output ndarray data buffer: + xbuf = x.data; + + // Cache a reference to the stride array: + sx = x.strides; + + // Cache the index of the first indexed element: + ox = x.offset; + + // Cache the array order: + ordx = x.order; + + // 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 ( !( clbk.call( thisArg, xbuf[ ix ], idx, x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], idx, x.ref ) ) ) { // eslint-disable-line max-len + return false; + } + } + return true; +} + + +// EXPORTS // + +module.exports = everynd; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/package.json b/lib/node_modules/@stdlib/ndarray/base/every-by/package.json new file mode 100644 index 000000000000..4271fb91f863 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/ndarray/base/every-by", + "version": "0.0.0", + "description": "Test whether every element in an ndarray is truthy according to a callback 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", + "every", + "everyby", + "callback", + "all", + "utility", + "utils", + "truthy" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js new file mode 100644 index 000000000000..e3fd66888384 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +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 0-dimensional ndarray is truthy according to a callback function', function test( t ) { + var actual; + var x; + + x = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = scalar2ndarray( 1.0, { + 'dtype': 'float64' + }); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0.0; + } +}); + +tape( 'the function tests whether every element in a 0-dimensional ndarray is truthy according to a callback function (accessors)', function test( t ) { + var actual; + var x; + + x = ndarray( 'float64', toAccessorArray( new Float64Array( [ 0.0 ] ) ), [], [ 0 ], 0, 'row-major' ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = ndarray( 'float64', toAccessorArray( new Float64Array( [ 1.0 ] ) ), [], [ 0 ], 0, 'row-major' ); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0.0; + } +}); + +tape( 'the function tests whether every element in a 0-dimensional ndarray is truthy according to a callback function (complex)', function test( t ) { + var actual; + var x; + + x = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' + }); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, false, 'returns expected value' ); + + x = scalar2ndarray( new Complex128( 1.0, 0.0 ), { + 'dtype': 'complex128' + }); + + actual = everyBy( [ x ], clbk ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); + + function clbk( v ) { + return v !== 0.0; + } +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.js b/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.js new file mode 100644 index 000000000000..bc474f3ac57c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 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(); +}); From 6f149f19eb2b7aec591d62d8263b036cf0fcdd88 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Sun, 13 Apr 2025 15:50:44 +0500 Subject: [PATCH 02/25] docs: fix copyright year Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> --- .../@stdlib/ndarray/base/every-by/docs/types/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts index ffafc2561987..f0b8fc91d196 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 113e5042df135bb88b463119aefd0fc1c3a0eae8 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Sun, 13 Apr 2025 15:55:11 +0500 Subject: [PATCH 03/25] docs: apply suggestions from code review Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> --- lib/node_modules/@stdlib/ndarray/base/every-by/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/README.md b/lib/node_modules/@stdlib/ndarray/base/every-by/README.md index 9b927d948659..8ae756dd5762 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/README.md @@ -79,7 +79,7 @@ var out = everyBy( [ x ], clbk ); The function accepts the following arguments: - **arrays**: array-like object containing an input ndarray. -- **clbk**: callback to apply. +- **clbk**: callback function. - **thisArg**: callback execution context (_optional_). The provided ndarray should be an `object` with the following properties: From fec0fee94e6705876a8991a9801c0f4fa895e111 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Mon, 14 Apr 2025 18:18:47 +0000 Subject: [PATCH 04/25] fix: remove cmplx kernels --- 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: 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 --- --- ...benchmark.2d_rowmajor_accessors_complex.js | 172 ---------------- .../ndarray/base/every-by/lib/0d_complex.js | 83 -------- .../ndarray/base/every-by/lib/1d_complex.js | 105 ---------- .../base/every-by/lib/2d_blocked_complex.js | 161 --------------- .../ndarray/base/every-by/lib/2d_complex.js | 136 ------------- .../base/every-by/lib/3d_blocked_complex.js | 183 ------------------ .../ndarray/base/every-by/lib/3d_complex.js | 146 -------------- .../ndarray/base/every-by/lib/nd_complex.js | 127 ------------ 8 files changed, 1113 deletions(-) delete mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_rowmajor_accessors_complex.js delete mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_complex.js delete mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_complex.js delete mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_complex.js delete mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_complex.js delete mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_complex.js delete mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_complex.js delete mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_complex.js diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_rowmajor_accessors_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_rowmajor_accessors_complex.js deleted file mode 100644 index 4ee980f32b72..000000000000 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.2d_rowmajor_accessors_complex.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pow = require( '@stdlib/math/base/special/pow' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var ctors = require( '@stdlib/array/typed-complex-ctors' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var pkg = require( './../package.json' ).name; -var everyBy = require( './../lib/2d_accessors.js' ); - - -// VARIABLES // - -var types = [ 'complex64' ]; -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.get( idx ); -} - -/** -* Sets an array data buffer element. -* -* @private -* @param {Collection} buf - data buffer -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function set( buf, idx, value ) { - buf.set( value, idx ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype ) { - var xbuf; - var x; - - xbuf = discreteUniform( len*2, 1, 100 ); - x = { - 'dtype': xtype, - 'data': new ( ctors( xtype ) )( xbuf.buffer ), - 'shape': shape, - 'strides': shape2strides( shape, order ), - 'offset': 0, - 'order': order, - 'accessorProtocol': true, - 'accessors': [ get, set ] - }; - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = everyBy( 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 = 5; // 10^max - - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1 ); - bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1 ); - bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1 ); - bench( pkg+'::accessors:ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+order+',xtype='+t1, f ); - } - } -} - -main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_complex.js deleted file mode 100644 index 58af67f31908..000000000000 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_complex.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result -* -* @example -* 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 ] ); -* -* // Define the shape of the input array: -* var shape = []; -* -* // Define the array strides: -* var sx = [ 0 ]; -* -* // Define the index offset: -* var ox = 0; -* -* // Create the input ndarray-like object: -* var x = { -* 'ref': null, -* 'dtype': 'complex128', -* 'data': xbuf, -* 'shape': shape, -* 'strides': sx, -* 'offset': ox, -* 'order': 'row-major' -* }; -* -* // Test elements: -* var out = every0d( x, clbk ); -* // returns true -*/ -function every0d( x, clbk, thisArg ) { - if ( clbk.call( thisArg, x.data[ x.offset ], [], x.ref ) || clbk.call( thisArg, x.data[ x.offset + 1 ], [], x.ref ) ) { // eslint-disable-line max-len - return true; - } - return false; -} - - -// EXPORTS // - -module.exports = every0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_complex.js deleted file mode 100644 index 8f4fa37bea7a..000000000000 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_complex.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result -* -* @example -* 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 ] ); -* -* // 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': 'complex128', -* 'data': xbuf, -* 'shape': shape, -* 'strides': sx, -* 'offset': ox, -* 'order': 'row-major' -* }; -* -* // Test elements: -* var out = every1d( x, clbk ); -* // returns true -*/ -function every1d( x, clbk, 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 ( !( clbk.call( thisArg, xbuf[ ix ], ix, x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], ix, x.ref ) ) ) { // eslint-disable-line max-len - return false; - } - ix += dx0; - } - return true; -} - - -// EXPORTS // - -module.exports = every1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_complex.js deleted file mode 100644 index 6abecf9a4945..000000000000 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_complex.js +++ /dev/null @@ -1,161 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result -* -* @example -* 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 ] ); -* -* // Define the shape of the input array: -* var shape = [ 2, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 2 ]; -* -* // Define the index offset: -* var ox = 0; -* -* // Create the input ndarray-like object: -* var x = { -* 'dtype': 'complex128', -* 'data': xbuf, -* 'shape': shape, -* 'strides': sx, -* 'offset': ox, -* 'order': 'row-major' -* }; -* -* // Test elements: -* var out = blockedevery2d( x, clbk ); -* // returns true -*/ -function blockedevery2d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... - - // Resolve the loop interchange order: - o = loopOrder( x.shape, x.strides ); - sh = o.sh; - sx = o.sx; - 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 ( !( clbk.call( thisArg, xbuf[ ix ], take( [ i1, i0 ], idx ), x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], take( [ i1, i0 ], idx ), x.ref ) ) ) { // eslint-disable-line max-len - return false; - } - ix += dx0; - } - ix += dx1; - } - } - } - return true; -} - - -// EXPORTS // - -module.exports = blockedevery2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_complex.js deleted file mode 100644 index 07a0f90ad01e..000000000000 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_complex.js +++ /dev/null @@ -1,136 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); -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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result -* -* @example -* 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 ] ); -* -* // Define the shape of the input array: -* var shape = [ 2, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 2 ]; -* -* // Define the index offset: -* var ox = 0; -* -* // Create the input ndarray-like object: -* var x = { -* 'ref': null, -* 'dtype': 'complex128', -* 'data': xbuf, -* 'shape': shape, -* 'strides': sx, -* 'offset': ox, -* 'order': 'row-major' -* }; -* -* // Test elements: -* var out = every2d( x, clbk ); -* // returns true -*/ -function every2d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... - - // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... - sh = x.shape; - sx = x.strides; - idx = zeroTo( sh.length ); - if ( isRowMajor( x.order ) ) { - // 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 ( !( clbk.call( thisArg, xbuf[ ix ], take( [ i1, i0 ], idx ), x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], take( [ i1, i0 ], idx ), x.ref ) ) ) { // eslint-disable-line max-len - return false; - } - ix += dx0; - } - ix += dx1; - } - return true; -} - - -// EXPORTS // - -module.exports = every2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_complex.js deleted file mode 100644 index a4acd4ffb927..000000000000 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_complex.js +++ /dev/null @@ -1,183 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result -* -* @example -* 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 ] ); -* -* // Define the shape of the input array: -* var shape = [ 1, 2, 2 ]; -* -* // Define the array strides: -* var sx = [ 8, 4, 2 ]; -* -* // Define the index offset: -* var ox = 0; -* -* // Create the input ndarray-like object: -* var x = { -* 'ref': null, -* 'dtype': 'complex128', -* 'data': xbuf, -* 'shape': shape, -* 'strides': sx, -* 'offset': ox, -* 'order': 'row-major' -* }; -* -* // Test elements: -* var out = blockedevery3d( x, clbk ); -* // returns true -*/ -function blockedevery3d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... - - // Resolve the loop interchange order: - o = loopOrder( x.shape, x.strides ); - sh = o.sh; - sx = o.sx; - 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 ( !( clbk.call( thisArg, xbuf[ ix ], take( [ i2, i1, i0 ], idx ), x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], take( [ i2, i1, i0 ], idx ), x.ref ) ) ) { // eslint-disable-line max-len - return false; - } - ix += dx0; - } - ix += dx1; - } - ix += dx2; - } - } - } - } - return true; -} - - -// EXPORTS // - -module.exports = blockedevery3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_complex.js deleted file mode 100644 index 62e2ac0908b5..000000000000 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_complex.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); -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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result -* -* @example -* 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 ] ); -* -* // Define the shape of the input array: -* var shape = [ 1, 2, 2 ]; -* -* // Define the array strides: -* var sx = [ 8, 4, 2 ]; -* -* // Define the index offset: -* var ox = 0; -* -* // Create the input ndarray-like object: -* var x = { -* 'ref': null, -* 'dtype': 'complex128', -* 'data': xbuf, -* 'shape': shape, -* 'strides': sx, -* 'offset': ox, -* 'order': 'row-major' -* }; -* -* // Test elements: -* var out = every3d( x, clbk ); -* // returns true -*/ -function every3d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... - - // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... - sh = x.shape; - sx = x.strides; - idx = zeroTo( sh.length ); - if ( isRowMajor( x.order ) ) { - // 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 ( !( clbk.call( thisArg, xbuf[ ix ], take( [ i2, i1, i0 ], idx ), x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], take( [ i2, i1, i0 ], idx ), x.ref ) ) ) { // eslint-disable-line max-len - return false; - } - ix += dx0; - } - ix += dx1; - } - ix += dx2; - } - return true; -} - - -// EXPORTS // - -module.exports = every3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_complex.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_complex.js deleted file mode 100644 index abeb8ed9f970..000000000000 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_complex.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 every element of a reinterpreted complex number ndarray is truthy according to a callback 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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result -* -* @example -* 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 ] ); -* -* // Define the shape of the input array: -* var shape = [ 2, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 2 ]; -* -* // Define the index offset: -* var ox = 0; -* -* // Create the input ndarray-like object: -* var x = { -* 'ref': null, -* 'dtype': 'complex128', -* 'data': xbuf, -* 'shape': shape, -* 'strides': sx, -* 'offset': ox, -* 'order': 'row-major' -* }; -* -* // Test elements: -* var out = everynd( x, clbk ); -* // returns true -*/ -function everynd( x, clbk, 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 output ndarray data buffer: - xbuf = x.data; - - // Cache a reference to the stride array: - sx = x.strides; - - // Cache the index of the first indexed element: - ox = x.offset; - - // Cache the array order: - ordx = x.order; - - // 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 ( !( clbk.call( thisArg, xbuf[ ix ], idx, x.ref ) || clbk.call( thisArg, xbuf[ ix+1 ], idx, x.ref ) ) ) { // eslint-disable-line max-len - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = everynd; From 52ebd2eff4e0f5015ec929c2a9701a5c55c63b56 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Mon, 14 Apr 2025 18:23:55 +0000 Subject: [PATCH 05/25] fix: remove redundant code --- 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/every-by/lib/main.js | 54 ------------------- 1 file changed, 54 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js index c2a07d3605d6..a712267da1b7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js @@ -20,18 +20,11 @@ // MODULES // -var isComplexArray = require( '@stdlib/array/base/assert/is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/array/base/assert/is-booleanarray' ); var iterationOrder = require( '@stdlib/ndarray/base/iteration-order' ); var minmaxViewBufferIndex = require( '@stdlib/ndarray/base/minmax-view-buffer-index' ); var ndarray2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); -var reinterpretComplex = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var gscal = require( '@stdlib/blas/base/gscal' ); var blockedaccessorevery2d = require( './2d_blocked_accessors.js' ); var blockedaccessorevery3d = require( './3d_blocked_accessors.js' ); -var blockedcomplexevery2d = require( './2d_blocked_complex.js' ); -var blockedcomplexevery3d = require( './3d_blocked_complex.js' ); var blockedevery2d = require( './2d_blocked.js' ); var blockedevery3d = require( './3d_blocked.js' ); var accessorevery0d = require( './0d_accessors.js' ); @@ -39,11 +32,6 @@ var accessorevery1d = require( './1d_accessors.js' ); var accessorevery2d = require( './2d_accessors.js' ); var accessorevery3d = require( './3d_accessors.js' ); var accessoreverynd = require( './nd_accessors.js' ); -var complexevery0d = require( './0d_complex.js' ); -var complexevery1d = require( './1d_complex.js' ); -var complexevery2d = require( './2d_complex.js' ); -var complexevery3d = require( './3d_complex.js' ); -var complexeverynd = require( './nd_complex.js' ); var every0d = require( './0d.js' ); var every1d = require( './1d.js' ); var every2d = require( './2d.js' ); @@ -65,12 +53,6 @@ var ACCESSOR_EVERY = [ accessorevery2d, accessorevery3d ]; -var COMPLEX_EVERY = [ - complexevery0d, - complexevery1d, - complexevery2d, - complexevery3d -]; var BLOCKED_EVERY = [ blockedevery2d, // 0 blockedevery3d @@ -79,10 +61,6 @@ var BLOCKED_ACCESSOR_EVERY = [ blockedaccessorevery2d, // 0 blockedaccessorevery3d ]; -var BLOCKED_COMPLEX_EVERY = [ - blockedcomplexevery2d, // 0 - blockedcomplexevery3d -]; var MAX_DIMS = EVERY.length - 1; @@ -160,25 +138,11 @@ function everyBy( arrays, clbk, thisArg ) { shx = x.shape; ndims = shx.length; - // Check for known array types which can be reinterpreted for better iteration performance... - if ( isBooleanArray( x.data ) ) { - x.data = reinterpretBoolean( x.data, 0 ); - x.accessorProtocol = false; - } else if ( isComplexArray( x.data ) ) { - x.data = reinterpretComplex( x.data, 0 ); - x.accessorProtocol = false; - x.strides = gscal( ndims, 2, x.strides, 1 ); - x.offset *= 2; - isCmplx = true; - } // Determine whether we can avoid iteration altogether... if ( ndims === 0 ) { if ( x.accessorProtocol ) { return ACCESSOR_EVERY[ ndims ]( x, clbk, thisArg ); } - if ( isCmplx ) { - return COMPLEX_EVERY[ ndims ]( x, clbk, thisArg ); - } return EVERY[ ndims ]( x, clbk, thisArg ); } // Compute the number of elements and the number of singleton dimensions... @@ -204,9 +168,6 @@ function everyBy( arrays, clbk, thisArg ) { if ( x.accessorProtocol ) { return ACCESSOR_EVERY[ ndims ]( x, clbk, thisArg ); } - if ( isCmplx ) { - return COMPLEX_EVERY[ ndims ]( x, clbk, thisArg ); - } return EVERY[ ndims ]( x, clbk, thisArg ); } sx = x.strides; @@ -224,9 +185,6 @@ function everyBy( arrays, clbk, thisArg ) { if ( x.accessorProtocol ) { return ACCESSOR_EVERY[ 1 ]( x, clbk, thisArg ); } - if ( isCmplx ) { - return COMPLEX_EVERY[ 1 ]( x, clbk, thisArg ); - } return EVERY[ 1 ]( x, clbk, thisArg ); } iox = iterationOrder( sx ); // +/-1 @@ -250,9 +208,6 @@ function everyBy( arrays, clbk, thisArg ) { if ( x.accessorProtocol ) { return ACCESSOR_EVERY[ 1 ]( x, clbk, thisArg ); } - if ( isCmplx ) { - return COMPLEX_EVERY[ 1 ]( x, clbk, thisArg ); - } return EVERY[ 1 ]( x, clbk, thisArg ); } // The ndarray is non-contiguous, so we cannot directly use one-dimensional array functionality... @@ -263,9 +218,6 @@ function everyBy( arrays, clbk, thisArg ) { if ( x.accessorProtocol ) { return ACCESSOR_EVERY[ ndims ]( x, clbk, thisArg ); } - if ( isCmplx ) { - return COMPLEX_EVERY[ ndims ]( x, clbk, thisArg ); - } return EVERY[ ndims ]( x, clbk, thisArg ); } // Fall-through to blocked iteration... @@ -277,18 +229,12 @@ function everyBy( arrays, clbk, thisArg ) { if ( x.accessorProtocol ) { return BLOCKED_ACCESSOR_EVERY[ ndims-2 ]( x, clbk, thisArg ); } - if ( isCmplx ) { - return BLOCKED_COMPLEX_EVERY[ ndims-2 ]( x, clbk, thisArg ); - } return BLOCKED_EVERY[ ndims-2 ]( x, clbk, 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 accessoreverynd( x, clbk, thisArg ); } - if ( isCmplx ) { - return complexeverynd( x, clbk, thisArg ); - } return everynd( x, clbk, thisArg ); } From 74965989f782d289d697c04664c8910e0dc5a370 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Mon, 14 Apr 2025 18:32:52 +0000 Subject: [PATCH 06/25] fix: cmplx test case --- 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 --- --- .../@stdlib/ndarray/base/every-by/test/test.0d.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js index e3fd66888384..8fa28ba3c3f3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js @@ -24,6 +24,8 @@ var tape = require( 'tape' ); var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); 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 ndarray = require( '@stdlib/ndarray/ctor' ); var everyBy = require( './../lib' ); @@ -94,7 +96,7 @@ tape( 'the function tests whether every element in a 0-dimensional ndarray is tr actual = everyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); - x = scalar2ndarray( new Complex128( 1.0, 0.0 ), { + x = scalar2ndarray( new Complex128( 1.0, 1.0 ), { 'dtype': 'complex128' }); @@ -104,6 +106,6 @@ tape( 'the function tests whether every element in a 0-dimensional ndarray is tr t.end(); function clbk( v ) { - return v !== 0.0; + return ( real( v ) !== 0.0 && imag( v ) !== 0.0 ); } }); From f0927155a831d3790fab9e7b7c2b0b292d3eacd4 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Mon, 14 Apr 2025 18:59:02 +0000 Subject: [PATCH 07/25] feat: add 4d kernels --- 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/every-by/lib/4d.js | 156 +++++++++++++ .../ndarray/base/every-by/lib/4d_accessors.js | 163 ++++++++++++++ .../ndarray/base/every-by/lib/4d_blocked.js | 202 +++++++++++++++++ .../base/every-by/lib/4d_blocked_accessors.js | 209 ++++++++++++++++++ 4 files changed, 730 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d.js new file mode 100644 index 000000000000..7b028d6ba6e5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = every4d( x, clbk ); +* // returns true +*/ +function every4d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + return true; +} + + +// EXPORTS // + +module.exports = every4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_accessors.js new file mode 100644 index 000000000000..22e2ea6dca16 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 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 = every4d( x, clbk ); +* // returns true +*/ +function every4d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + return true; +} + + +// EXPORTS // + +module.exports = every4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked.js new file mode 100644 index 000000000000..cb3f62a90fd5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = blockedevery4d( x, clbk ); +* // returns true +*/ +function blockedevery4d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js new file mode 100644 index 000000000000..59aaa2931c9a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 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 = blockedevery4d( x, clbk ); +* // returns true +*/ +function blockedevery4d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery4d; From b32596a6a5770b734e1776b1d600ea6831889209 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Mon, 14 Apr 2025 19:16:55 +0000 Subject: [PATCH 08/25] feat: add 5d kernels --- 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/every-by/lib/5d.js | 168 +++++++++++++ .../ndarray/base/every-by/lib/5d_accessors.js | 175 ++++++++++++++ .../ndarray/base/every-by/lib/5d_blocked.js | 221 +++++++++++++++++ .../base/every-by/lib/5d_blocked_accessors.js | 228 ++++++++++++++++++ 4 files changed, 792 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d.js new file mode 100644 index 000000000000..fe07fcaedfd8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = every5d( x, clbk ); +* // returns true +*/ +function every5d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + return true; +} + + +// EXPORTS // + +module.exports = every5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_accessors.js new file mode 100644 index 000000000000..c7f75236be94 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 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 = every5d( x, clbk ); +* // returns true +*/ +function every5d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + return true; +} + + +// EXPORTS // + +module.exports = every5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked.js new file mode 100644 index 000000000000..b7a2c20b3dff --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = blockedevery5d( x, clbk ); +* // returns true +*/ +function blockedevery5d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js new file mode 100644 index 000000000000..974d89b0ccf7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 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 = blockedevery5d( x, clbk ); +* // returns true +*/ +function blockedevery5d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery5d; From 44f28ae517546648311305ae15c0035e87c8215f Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Tue, 15 Apr 2025 16:30:30 +0000 Subject: [PATCH 09/25] feat: add 6d kernels --- 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/every-by/lib/6d.js | 178 +++++++++++++ .../ndarray/base/every-by/lib/6d_accessors.js | 185 +++++++++++++ .../ndarray/base/every-by/lib/6d_blocked.js | 240 +++++++++++++++++ .../base/every-by/lib/6d_blocked_accessors.js | 247 ++++++++++++++++++ 4 files changed, 850 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d.js new file mode 100644 index 000000000000..dc2110235fe1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = every6d( x, clbk ); +* // returns true +*/ +function every6d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + return true; +} + + +// EXPORTS // + +module.exports = every6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_accessors.js new file mode 100644 index 000000000000..4c08820cab2d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 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 = every6d( x, clbk ); +* // returns true +*/ +function every6d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + return true; +} + + +// EXPORTS // + +module.exports = every6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked.js new file mode 100644 index 000000000000..8b8923b5a5f8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = blockedevery6d( x, clbk ); +* // returns true +*/ +function blockedevery6d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js new file mode 100644 index 000000000000..a6e88171bd29 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 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 = blockedevery6d( x, clbk ); +* // returns true +*/ +function blockedevery6d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery6d; From 471ca3146a0a794d1a2a91ae80940c07ebc6a544 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Tue, 15 Apr 2025 16:58:59 +0000 Subject: [PATCH 10/25] feat: add 7d kernels --- 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/every-by/lib/7d.js | 188 +++++++++++++ .../ndarray/base/every-by/lib/7d_accessors.js | 195 +++++++++++++ .../ndarray/base/every-by/lib/7d_blocked.js | 259 +++++++++++++++++ .../base/every-by/lib/7d_blocked_accessors.js | 266 ++++++++++++++++++ 4 files changed, 908 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d.js new file mode 100644 index 000000000000..d71c9c3604ad --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = every7d( x, clbk ); +* // returns true +*/ +function every7d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + return true; +} + + +// EXPORTS // + +module.exports = every7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_accessors.js new file mode 100644 index 000000000000..839984dbefab --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 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 = every7d( x, clbk ); +* // returns true +*/ +function every7d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + return true; +} + + +// EXPORTS // + +module.exports = every7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked.js new file mode 100644 index 000000000000..4c51941d7b49 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = blockedevery7d( x, clbk ); +* // returns true +*/ +function blockedevery7d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + } + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js new file mode 100644 index 000000000000..a99d931b1b1e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 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 = blockedevery7d( x, clbk ); +* // returns true +*/ +function blockedevery7d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + } + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery7d; From e9c735e1d6c23a149e00356affc96cadbfe40395 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Tue, 15 Apr 2025 17:17:07 +0000 Subject: [PATCH 11/25] feat: add 8d kernels --- 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/every-by/lib/8d.js | 198 ++++++++++++ .../ndarray/base/every-by/lib/8d_accessors.js | 205 +++++++++++++ .../ndarray/base/every-by/lib/8d_blocked.js | 278 +++++++++++++++++ .../base/every-by/lib/8d_blocked_accessors.js | 285 ++++++++++++++++++ 4 files changed, 966 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d.js new file mode 100644 index 000000000000..59e65ddd5de5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = every8d( x, clbk ); +* // returns true +*/ +function every8d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + return true; +} + + +// EXPORTS // + +module.exports = every8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_accessors.js new file mode 100644 index 000000000000..9990d80b6369 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 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 = every8d( x, clbk ); +* // returns true +*/ +function every8d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + return true; +} + + +// EXPORTS // + +module.exports = every8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked.js new file mode 100644 index 000000000000..d21ae98e9aa6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = blockedevery8d( x, clbk ); +* // returns true +*/ +function blockedevery8d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + } + } + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js new file mode 100644 index 000000000000..6d0a02548cb9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 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 = blockedevery8d( x, clbk ); +* // returns true +*/ +function blockedevery8d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + } + } + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery8d; From 8274f8aee8296d765f16efed57e293cc8985103c Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Tue, 15 Apr 2025 17:40:07 +0000 Subject: [PATCH 12/25] feat: add 9d kernels --- 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/every-by/lib/9d.js | 208 ++++++++++++ .../ndarray/base/every-by/lib/9d_accessors.js | 215 +++++++++++++ .../ndarray/base/every-by/lib/9d_blocked.js | 297 +++++++++++++++++ .../base/every-by/lib/9d_blocked_accessors.js | 304 ++++++++++++++++++ 4 files changed, 1024 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d.js new file mode 100644 index 000000000000..b5a68bc84776 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = every9d( x, clbk ); +* // returns true +*/ +function every9d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + return true; +} + + +// EXPORTS // + +module.exports = every9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_accessors.js new file mode 100644 index 000000000000..c77d4a8061e7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 4, 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 = every9d( x, clbk ); +* // returns true +*/ +function every9d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + return true; +} + + +// EXPORTS // + +module.exports = every9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked.js new file mode 100644 index 000000000000..3e590dfa0093 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = blockedevery9d( x, clbk ); +* // returns true +*/ +function blockedevery9d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + } + } + } + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js new file mode 100644 index 000000000000..dc3b5824c07d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 4, 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 = blockedevery9d( x, clbk ); +* // returns true +*/ +function blockedevery9d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + } + } + } + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery9d; From 675ed2783825b1045bdf27073bda2fa2b59ce4ce Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Tue, 15 Apr 2025 17:57:34 +0000 Subject: [PATCH 13/25] feat: add 10d kernels --- 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/every-by/lib/10d.js | 218 ++++++++++++ .../base/every-by/lib/10d_accessors.js | 225 ++++++++++++ .../ndarray/base/every-by/lib/10d_blocked.js | 316 +++++++++++++++++ .../every-by/lib/10d_blocked_accessors.js | 323 ++++++++++++++++++ 4 files changed, 1082 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_accessors.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked_accessors.js diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d.js new file mode 100644 index 000000000000..77c917014af8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = every10d( x, clbk ); +* // returns true +*/ +function every10d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + ix += dx9; + } + return true; +} + + +// EXPORTS // + +module.exports = every10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_accessors.js new file mode 100644 index 000000000000..4a5a3ba34295 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create 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 = every10d( x, clbk ); +* // returns true +*/ +function every10d( x, clbk, 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#, dy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sh = x.shape; + sx = x.strides; + idx = zeroTo( sh.length ); + if ( isRowMajor( x.order ) ) { + // 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 ( !clbk.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 false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + ix += dx9; + } + return true; +} + + +// EXPORTS // + +module.exports = every10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked.js new file mode 100644 index 000000000000..9a6c462676b9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* 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 = [ 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 = blockedevery10d( x, clbk ); +* // returns true +*/ +function blockedevery10d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, xbuf[ ix ], take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + ix += dx9; + } + } + } + } + } + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked_accessors.js new file mode 100644 index 000000000000..c2252564eab9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 every element in an ndarray is truthy according to a callback 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} clbk - callback function +* @param {*} thisArg - callback execution context +* @returns {boolean} result +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var accessors = require( '@stdlib/array/base/accessors' ); +* +* function clbk( 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, 1, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create 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 = blockedevery10d( x, clbk ); +* // returns true +*/ +function blockedevery10d( x, clbk, 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#, dy#, i#, j# where # corresponds to the loop number, with `0` being the innermost loop... + + // Resolve the loop interchange order: + o = loopOrder( x.shape, x.strides ); + sh = o.sh; + sx = o.sx; + 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 ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + return false; + } + ix += dx0; + } + ix += dx1; + } + ix += dx2; + } + ix += dx3; + } + ix += dx4; + } + ix += dx5; + } + ix += dx6; + } + ix += dx7; + } + ix += dx8; + } + ix += dx9; + } + } + } + } + } + } + } + } + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = blockedevery10d; From e5235a3535f7df5812da6a7abfb5cc9d0bc23ac3 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Tue, 15 Apr 2025 18:10:38 +0000 Subject: [PATCH 14/25] chore: add missing imports --- 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/every-by/lib/main.js | 64 +++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js index a712267da1b7..c9ee2df91ac5 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js @@ -25,17 +25,45 @@ var minmaxViewBufferIndex = require( '@stdlib/ndarray/base/minmax-view-buffer-in var ndarray2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); var blockedaccessorevery2d = require( './2d_blocked_accessors.js' ); var blockedaccessorevery3d = require( './3d_blocked_accessors.js' ); +var blockedaccessorevery4d = require( './4d_blocked_accessors.js' ); +var blockedaccessorevery5d = require( './5d_blocked_accessors.js' ); +var blockedaccessorevery6d = require( './6d_blocked_accessors.js' ); +var blockedaccessorevery7d = require( './7d_blocked_accessors.js' ); +var blockedaccessorevery8d = require( './8d_blocked_accessors.js' ); +var blockedaccessorevery9d = require( './9d_blocked_accessors.js' ); +var blockedaccessorevery10d = require( './10d_blocked_accessors.js' ); var blockedevery2d = require( './2d_blocked.js' ); var blockedevery3d = require( './3d_blocked.js' ); +var blockedevery4d = require( './4d_blocked.js' ); +var blockedevery5d = require( './5d_blocked.js' ); +var blockedevery6d = require( './6d_blocked.js' ); +var blockedevery7d = require( './7d_blocked.js' ); +var blockedevery8d = require( './8d_blocked.js' ); +var blockedevery9d = require( './9d_blocked.js' ); +var blockedevery10d = require( './10d_blocked.js' ); var accessorevery0d = require( './0d_accessors.js' ); var accessorevery1d = require( './1d_accessors.js' ); var accessorevery2d = require( './2d_accessors.js' ); var accessorevery3d = require( './3d_accessors.js' ); +var accessorevery4d = require( './4d_accessors.js' ); +var accessorevery5d = require( './5d_accessors.js' ); +var accessorevery6d = require( './6d_accessors.js' ); +var accessorevery7d = require( './7d_accessors.js' ); +var accessorevery8d = require( './8d_accessors.js' ); +var accessorevery9d = require( './9d_accessors.js' ); +var accessorevery10d = require( './10d_accessors.js' ); var accessoreverynd = require( './nd_accessors.js' ); var every0d = require( './0d.js' ); var every1d = require( './1d.js' ); var every2d = require( './2d.js' ); var every3d = require( './3d.js' ); +var every4d = require( './4d.js' ); +var every5d = require( './5d.js' ); +var every6d = require( './6d.js' ); +var every7d = require( './7d.js' ); +var every8d = require( './8d.js' ); +var every9d = require( './9d.js' ); +var every10d = require( './10d.js' ); var everynd = require( './nd.js' ); @@ -45,21 +73,49 @@ var EVERY = [ every0d, every1d, every2d, - every3d + every3d, + every4d, + every5d, + every6d, + every7d, + every8d, + every9d, + every10d ]; var ACCESSOR_EVERY = [ accessorevery0d, accessorevery1d, accessorevery2d, - accessorevery3d + accessorevery3d, + accessorevery4d, + accessorevery5d, + accessorevery6d, + accessorevery7d, + accessorevery8d, + accessorevery9d, + accessorevery10d ]; var BLOCKED_EVERY = [ blockedevery2d, // 0 - blockedevery3d + blockedevery3d, + blockedevery4d, + blockedevery5d, + blockedevery6d, + blockedevery7d, + blockedevery8d, + blockedevery9d, + blockedevery10d // 8 ]; var BLOCKED_ACCESSOR_EVERY = [ blockedaccessorevery2d, // 0 - blockedaccessorevery3d + blockedaccessorevery3d, + blockedaccessorevery4d, + blockedaccessorevery5d, + blockedaccessorevery6d, + blockedaccessorevery7d, + blockedaccessorevery8d, + blockedaccessorevery9d, + blockedaccessorevery10d // 8 ]; var MAX_DIMS = EVERY.length - 1; From a9d961f4ec757dd810b2e108f5b10f752e169e0a Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Wed, 16 Apr 2025 13:54:19 +0000 Subject: [PATCH 15/25] bench: add benchmarks --- 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 ++++++++++++++++++ .../benchmark/benchmark.4d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark.5d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.5d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.5d_columnmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.5d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark.6d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.6d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.6d_columnmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.6d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark.7d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.7d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.7d_columnmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.7d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark.8d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.8d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.8d_columnmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.8d_rowmajor.js | 143 ++++++++++++++++++ .../benchmark.9d_blocked_columnmajor.js | 143 ++++++++++++++++++ .../benchmark.9d_blocked_rowmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.9d_columnmajor.js | 143 ++++++++++++++++++ .../benchmark/benchmark.9d_rowmajor.js | 143 ++++++++++++++++++ 30 files changed, 4290 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.10d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.10d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.10d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.10d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.11d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.11d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.4d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.4d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.4d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.4d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.5d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.5d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.5d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.5d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.6d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.6d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.6d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.6d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.7d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.7d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.7d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.7d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.8d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.8d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.8d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.8d_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.9d_blocked_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.9d_blocked_rowmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.9d_columnmajor.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.9d_rowmajor.js diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.10d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.10d_blocked_columnmajor.js new file mode 100644 index 000000000000..73b05f3e1c42 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.10d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.10d_blocked_rowmajor.js new file mode 100644 index 000000000000..a6c573e5b93d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.10d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.10d_columnmajor.js new file mode 100644 index 000000000000..a76e94976182 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.10d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.10d_rowmajor.js new file mode 100644 index 000000000000..1604f5997b46 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.11d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.11d_columnmajor.js new file mode 100644 index 000000000000..f75902f26a97 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.11d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.11d_rowmajor.js new file mode 100644 index 000000000000..280612db94dc --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.4d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.4d_blocked_columnmajor.js new file mode 100644 index 000000000000..b44bb8d8761c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.4d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.4d_blocked_rowmajor.js new file mode 100644 index 000000000000..2b67635745d6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.4d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.4d_columnmajor.js new file mode 100644 index 000000000000..dd5a8725c2e3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.4d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.4d_rowmajor.js new file mode 100644 index 000000000000..90016f711d56 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.5d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.5d_blocked_columnmajor.js new file mode 100644 index 000000000000..28dead7365d2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.5d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.5d_blocked_rowmajor.js new file mode 100644 index 000000000000..7d8af328e41b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.5d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.5d_columnmajor.js new file mode 100644 index 000000000000..7b8634c11254 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.5d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.5d_rowmajor.js new file mode 100644 index 000000000000..bc1b7548730e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.6d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.6d_blocked_columnmajor.js new file mode 100644 index 000000000000..9a2ac5d111b6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.6d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.6d_blocked_rowmajor.js new file mode 100644 index 000000000000..ad4c65fe94c7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.6d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.6d_columnmajor.js new file mode 100644 index 000000000000..3518b7b49152 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.6d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.6d_rowmajor.js new file mode 100644 index 000000000000..0445b2746c9c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.7d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.7d_blocked_columnmajor.js new file mode 100644 index 000000000000..35c77426e8ec --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.7d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.7d_blocked_rowmajor.js new file mode 100644 index 000000000000..12f8f98197b7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.7d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.7d_columnmajor.js new file mode 100644 index 000000000000..98252d709722 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.7d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.7d_rowmajor.js new file mode 100644 index 000000000000..ae612e3d6cb1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.8d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.8d_blocked_columnmajor.js new file mode 100644 index 000000000000..4710a6230959 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.8d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.8d_blocked_rowmajor.js new file mode 100644 index 000000000000..4710a6230959 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.8d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.8d_columnmajor.js new file mode 100644 index 000000000000..ebd3ac2598fd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.8d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.8d_rowmajor.js new file mode 100644 index 000000000000..1007ebbd6ecd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.9d_blocked_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.9d_blocked_columnmajor.js new file mode 100644 index 000000000000..a2dfa877ff0f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.9d_blocked_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.9d_blocked_rowmajor.js new file mode 100644 index 000000000000..c511e1720792 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.9d_columnmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.9d_columnmajor.js new file mode 100644 index 000000000000..51b5ba34bb9c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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/every-by/benchmark/benchmark.9d_rowmajor.js b/lib/node_modules/@stdlib/ndarray/base/every-by/benchmark/benchmark.9d_rowmajor.js new file mode 100644 index 000000000000..345867ee93b9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/every-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 everyBy = 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 = everyBy( 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(); From 4c9b9c10f6c41e7f66b60e4bbedd68ca7d1ed91f Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 02:53:15 -0700 Subject: [PATCH 16/25] fix: use correct indices --- 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 --- --- lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js | 2 +- .../@stdlib/ndarray/base/every-by/lib/1d_accessors.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js index 294a40ceaa21..e19eaaa01ec1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js @@ -91,7 +91,7 @@ function every1d( x, clbk, thisArg ) { // Iterate over the ndarray dimensions... for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], ix, x.ref ) ) { + if ( !clbk.call( thisArg, xbuf[ ix ], [ i0 ], x.ref ) ) { return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_accessors.js index ad91f3e8ece9..c679e5d47a1f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_accessors.js @@ -52,7 +52,7 @@ * var shape = [ 4 ]; * * // Define the array strides: -* var sx = [ 1 ]; +* var sx = [ 2 ]; * * // Define the index offset: * var ox = 0; @@ -98,7 +98,7 @@ function every1d( x, clbk, thisArg ) { // Iterate over the ndarray dimensions... for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), ix, x.ref) ) { + if ( !clbk.call( thisArg, get( xbuf, ix ), [ i0 ], x.ref) ) { return false; } ix += dx0; From 55b013a0cb676c09b7a63a0a3dd68b28a8164eb3 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 03:09:36 -0700 Subject: [PATCH 17/25] docs: update examples --- 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/every-by/lib/2d_accessors.js | 2 +- .../@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/every-by/lib/3d_accessors.js | 2 +- .../@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js | 2 +- .../@stdlib/ndarray/base/every-by/lib/4d_accessors.js | 4 ++-- .../@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js | 4 ++-- .../@stdlib/ndarray/base/every-by/lib/5d_accessors.js | 4 ++-- .../@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js | 4 ++-- .../@stdlib/ndarray/base/every-by/lib/6d_accessors.js | 4 ++-- .../@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js | 4 ++-- .../@stdlib/ndarray/base/every-by/lib/7d_accessors.js | 4 ++-- .../@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js | 4 ++-- .../@stdlib/ndarray/base/every-by/lib/8d_accessors.js | 4 ++-- .../@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js | 4 ++-- .../@stdlib/ndarray/base/every-by/lib/9d_accessors.js | 4 ++-- .../@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js | 4 ++-- lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js | 2 +- .../@stdlib/ndarray/base/every-by/lib/nd_accessors.js | 2 +- 18 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_accessors.js index 8fb2047b1e42..caef5d041b9a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_accessors.js @@ -60,7 +60,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); * var shape = [ 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 1 ]; +* var sx = [ 4, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js index 706b3c6e8391..be897a9d7467 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js @@ -60,7 +60,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); * var shape = [ 2, 2 ]; * * // Define the array strides: -* var sx = [ 2, 1 ]; +* var sx = [ 4, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_accessors.js index ef4ae71f8f0f..5c59934f8b66 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_accessors.js @@ -57,7 +57,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); * 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 ]; +* var shape = [ 2, 2, 2 ]; * * // Define the array strides: * var sx = [ 4, 2, 1 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js index a5b2a1419902..dc813b0526ca 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js @@ -59,7 +59,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); * 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 ]; +* var shape = [ 2, 2, 2 ]; * * // Define the array strides: * var sx = [ 4, 2, 1 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_accessors.js index 22e2ea6dca16..b2fc16a4b0a5 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_accessors.js @@ -57,10 +57,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * 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 ]; +* var shape = [ 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 2, 1 ]; +* var sx = [ 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js index 59aaa2931c9a..a63246308a5f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js @@ -59,10 +59,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * 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 ]; +* var shape = [ 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 2, 1 ]; +* var sx = [ 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_accessors.js index c7f75236be94..d2dd1cf83a90 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_accessors.js @@ -59,10 +59,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * 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 ]; +* var shape = [ 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js index 974d89b0ccf7..90f5f1d4805d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js @@ -59,10 +59,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * 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 ]; +* var shape = [ 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_accessors.js index 4c08820cab2d..1abfb7e52325 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_accessors.js @@ -59,10 +59,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * 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 ]; +* var shape = [ 1, 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js index a6e88171bd29..19ad98e05c17 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js @@ -59,10 +59,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * 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 ]; +* var shape = [ 1, 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_accessors.js index 839984dbefab..e3c717ea0f19 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_accessors.js @@ -59,10 +59,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * 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 ]; +* var shape = [ 1, 1, 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js index a99d931b1b1e..49f993a4b209 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js @@ -59,10 +59,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * 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 ]; +* var shape = [ 1, 1, 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_accessors.js index 9990d80b6369..28b8d3f5fd1d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_accessors.js @@ -59,10 +59,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * 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 ]; +* var shape = [ 1, 1, 1, 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 8, 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js index 6d0a02548cb9..963388372ac3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js @@ -59,10 +59,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * 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 ]; +* var shape = [ 1, 1, 1, 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 8, 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_accessors.js index c77d4a8061e7..4c24909d6a7b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_accessors.js @@ -59,10 +59,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * 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 ]; +* var shape = [ 1, 1, 1, 1, 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js index dc3b5824c07d..774d0d114a78 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js @@ -59,10 +59,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * 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 ]; +* var shape = [ 1, 1, 1, 1, 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js index 7581e861700f..310461eff9d2 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js @@ -98,7 +98,7 @@ function everynd( x, clbk, thisArg ) { // Compute the total number of elements over which to iterate: len = numel( sh ); - // Cache a reference to the output ndarray data buffer: + // Cache a reference to the input ndarray data buffer: xbuf = x.data; // Cache a reference to the stride array: diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_accessors.js index b0753eb9051e..8190b57f8c2a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_accessors.js @@ -102,7 +102,7 @@ function everynd( x, clbk, thisArg ) { // Compute the total number of elements over which to iterate: len = numel( sh ); - // Cache a reference to the output ndarray data buffer: + // Cache a reference to the input ndarray data buffer: xbuf = x.data; // Cache a reference to the stride array: From 11c3ab2b88fd35df69c9ff82cf87ed0e0360fb79 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 03:10:54 -0700 Subject: [PATCH 18/25] docs: update examples --- 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/every-by/lib/10d_accessors.js | 4 ++-- .../ndarray/base/every-by/lib/10d_blocked_accessors.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_accessors.js index 4a5a3ba34295..f456b7a12da3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_accessors.js @@ -59,10 +59,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); * * // Define the shape of the input array: -* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked_accessors.js index c2252564eab9..3503c4a1bf6c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked_accessors.js @@ -59,10 +59,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * var xbuf = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); * * // Define the shape of the input array: -* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ]; +* var sx = [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; * * // Define the index offset: * var ox = 0; From 803764c7e68e839e514fab3b7353da2d381fee6b Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 03:19:24 -0700 Subject: [PATCH 19/25] fix: avoid flattening due to user callback --- 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/every-by/lib/main.js | 69 ++----------------- 1 file changed, 6 insertions(+), 63 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js index c9ee2df91ac5..28b1ec0f5589 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js @@ -21,8 +21,8 @@ // MODULES // var iterationOrder = require( '@stdlib/ndarray/base/iteration-order' ); -var minmaxViewBufferIndex = require( '@stdlib/ndarray/base/minmax-view-buffer-index' ); var ndarray2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); +var numel = require( '@stdlib/ndarray/base/numel' ); var blockedaccessorevery2d = require( './2d_blocked_accessors.js' ); var blockedaccessorevery3d = require( './3d_blocked_accessors.js' ); var blockedaccessorevery4d = require( './4d_blocked_accessors.js' ); @@ -138,7 +138,7 @@ var MAX_DIMS = EVERY.length - 1; * * @param {ArrayLikeObject} arrays - array-like object containing one input array * @param {Function} clbk - callback function -* @param {thisArg} thisArg - callback execution context +* @param {thisArg} [thisArg] - callback execution context * @returns {boolean} result * * @example @@ -176,18 +176,11 @@ var MAX_DIMS = EVERY.length - 1; * // returns true */ function everyBy( arrays, clbk, thisArg ) { - var isCmplx; var ndims; - var xmmv; var shx; var iox; var len; - var sx; - var ox; - var ns; var x; - var d; - var i; // Unpack the ndarray and standardize ndarray meta data: x = ndarray2object( arrays[ 0 ] ); @@ -201,20 +194,9 @@ function everyBy( arrays, clbk, thisArg ) { } return EVERY[ ndims ]( x, clbk, thisArg ); } - // Compute the number of elements and the number of singleton dimensions... - len = 1; // number of elements - ns = 0; // number of singleton dimensions - for ( i = 0; i < ndims; i++ ) { - d = shx[ i ]; + // Compute the number of elements: + len = numel( shx ); - // Note that, if one of the dimensions is `0`, the length will be `0`... - len *= d; - - // Check whether the current dimension is a singleton dimension... - if ( d === 1 ) { - ns += 1; - } - } // Check whether we were provided an empty ndarray... if ( len === 0 ) { return true; @@ -226,48 +208,11 @@ function everyBy( arrays, clbk, thisArg ) { } return EVERY[ ndims ]( x, clbk, thisArg ); } - sx = x.strides; - - // Determine whether the ndarray has only **one** non-singleton dimension (e.g., ndims=4, shape=[10,1,1,1]) so that we can treat an ndarray as being equivalent to a one-dimensional strided array... - if ( ns === ndims-1 ) { - // Get the index of the non-singleton dimension... - for ( i = 0; i < ndims; i++ ) { - if ( shx[ i ] !== 1 ) { - break; - } - } - x.shape = [ shx[i] ]; - x.strides = [ sx[i] ]; - if ( x.accessorProtocol ) { - return ACCESSOR_EVERY[ 1 ]( x, clbk, thisArg ); - } - return EVERY[ 1 ]( x, clbk, thisArg ); - } - iox = iterationOrder( sx ); // +/-1 + // Determine the iteration order: + iox = iterationOrder( x.strides ); // +/-1 // Determine whether we can avoid blocked iteration... if ( iox !== 0 ) { - // Determine the minimum and maximum linear indices which are accessible by the array view: - xmmv = minmaxViewBufferIndex( shx, sx, x.offset ); - - // Determine whether we can ignore shape (and strides) and treat the ndarray as a linear one-dimensional strided array... - if ( len === ( xmmv[1]-xmmv[0]+1 ) || ( isCmplx && len*2 === ( xmmv[1]-xmmv[0]+1 ) ) ) { // eslint-disable-line max-len - // Note: the above is equivalent to @stdlib/ndarray/base/assert/is-contiguous, but in-lined so we can retain computed values... - if ( iox === 1 ) { - ox = xmmv[ 0 ]; - } else { - ox = xmmv[ 1 ]; - } - x.shape = [ len ]; - x.strides = [ ( isCmplx ) ? iox*2 : iox ]; - x.offset = ox; - if ( x.accessorProtocol ) { - return ACCESSOR_EVERY[ 1 ]( x, clbk, thisArg ); - } - return EVERY[ 1 ]( x, clbk, thisArg ); - } - // The ndarray is non-contiguous, so we cannot directly use one-dimensional array functionality... - // Determine whether we can use simple nested loops... if ( ndims <= MAX_DIMS ) { // So long as iteration always moves in the same direction (i.e., no mixed sign strides), we can leverage cache-optimal (i.e., normal) nested loops without resorting to blocked iteration... @@ -278,8 +223,6 @@ function everyBy( arrays, clbk, thisArg ) { } // Fall-through to blocked iteration... } - // At this point, we're either dealing with a non-contiguous n-dimensional array or a high dimensional n-dimensional array, so our only hope is that we can still perform blocked iteration... - // Determine whether we can perform blocked iteration... if ( ndims <= MAX_DIMS ) { if ( x.accessorProtocol ) { From 1c1d819110a2240e3ab36020ab0d3ab6fb02a005 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 03:20:57 -0700 Subject: [PATCH 20/25] test: fix dtype --- 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 --- --- .../@stdlib/ndarray/base/every-by/test/test.0d.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js index 8fa28ba3c3f3..5e10b6378261 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js @@ -68,12 +68,12 @@ tape( 'the function tests whether every element in a 0-dimensional ndarray is tr var actual; var x; - x = ndarray( 'float64', toAccessorArray( new Float64Array( [ 0.0 ] ) ), [], [ 0 ], 0, 'row-major' ); + x = ndarray( 'generic', toAccessorArray( new Float64Array( [ 0.0 ] ) ), [], [ 0 ], 0, 'row-major' ); actual = everyBy( [ x ], clbk ); t.strictEqual( actual, false, 'returns expected value' ); - x = ndarray( 'float64', toAccessorArray( new Float64Array( [ 1.0 ] ) ), [], [ 0 ], 0, 'row-major' ); + x = ndarray( 'generic', toAccessorArray( new Float64Array( [ 1.0 ] ) ), [], [ 0 ], 0, 'row-major' ); actual = everyBy( [ x ], clbk ); t.strictEqual( actual, true, 'returns expected value' ); From 750540dee8172018d6d3917ea2e7fb0012f5aabd Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 03:23:02 -0700 Subject: [PATCH 21/25] docs: update example --- 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: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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 --- --- lib/node_modules/@stdlib/ndarray/base/every-by/README.md | 2 +- .../@stdlib/ndarray/base/every-by/examples/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/README.md b/lib/node_modules/@stdlib/ndarray/base/every-by/README.md index 8ae756dd5762..0a8b7b46c8a0 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/README.md @@ -174,7 +174,7 @@ function clbk( value ) { var x = { 'dtype': 'generic', - 'data': discreteUniform( 12, -2, 10, { + 'data': discreteUniform( 10, -2, 10, { 'dtype': 'generic' }), 'shape': [ 5, 2 ], diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/every-by/examples/index.js index ee8a240e7353..023c45364d74 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/examples/index.js @@ -28,7 +28,7 @@ function clbk( value ) { var x = { 'dtype': 'generic', - 'data': discreteUniform( 12, -2, 10, { + 'data': discreteUniform( 10, -2, 10, { 'dtype': 'generic' }), 'shape': [ 5, 2 ], From 2c9bdf906ddb45121dbb979395f427c8e60b777c Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 03:24:32 -0700 Subject: [PATCH 22/25] docs: update example --- 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: passed - 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: 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/every-by/docs/repl.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/repl.txt index db6a21030c32..bb8d8899e6c4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/repl.txt @@ -40,29 +40,29 @@ -------- // Define ndarray data and meta data... > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0, 1.0, 1.0 ] ); - > var dtype = 'float64'; - > var shape = [ 2, 2 ]; + > var dt = 'float64'; + > var sh = [ 2, 2 ]; > var sx = [ 2, 1 ]; > var ox = 0; - > var order = 'row-major'; + > var ord = 'row-major'; // Define a callback... > function clbk( v ) { return v > 0.0; }; // Using an ndarray... - > var x = {{alias:@stdlib/ndarray/ctor}}( dtype, xbuf, shape, sx, ox, order ); + > 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': dtype, + ... 'dtype': dt, ... 'data': xbuf, - ... 'shape': shape, + ... 'shape': sh, ... 'strides': sx, ... 'offset': ox, - ... 'order': order + ... 'order': ord ... }; > {{alias}}( [ x ], clbk ) false From d1ff8b29e48a69b1a15261b0c50b5de9e490a24d Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 03:45:08 -0700 Subject: [PATCH 23/25] refactor: rename `clbk` to `predicate` to use more descriptive term --- 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: 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: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/base/every-by/README.md | 15 +++--- .../ndarray/base/every-by/docs/repl.txt | 20 ++++---- .../base/every-by/docs/types/index.d.ts | 46 +++++++++++-------- .../ndarray/base/every-by/docs/types/test.ts | 45 ++++-------------- .../@stdlib/ndarray/base/every-by/lib/0d.js | 16 +++---- .../ndarray/base/every-by/lib/0d_accessors.js | 16 +++---- .../@stdlib/ndarray/base/every-by/lib/10d.js | 16 +++---- .../base/every-by/lib/10d_accessors.js | 16 +++---- .../ndarray/base/every-by/lib/10d_blocked.js | 16 +++---- .../every-by/lib/10d_blocked_accessors.js | 16 +++---- .../@stdlib/ndarray/base/every-by/lib/1d.js | 16 +++---- .../ndarray/base/every-by/lib/1d_accessors.js | 16 +++---- .../@stdlib/ndarray/base/every-by/lib/2d.js | 16 +++---- .../ndarray/base/every-by/lib/2d_accessors.js | 16 +++---- .../ndarray/base/every-by/lib/2d_blocked.js | 16 +++---- .../base/every-by/lib/2d_blocked_accessors.js | 16 +++---- .../@stdlib/ndarray/base/every-by/lib/3d.js | 16 +++---- .../ndarray/base/every-by/lib/3d_accessors.js | 16 +++---- .../ndarray/base/every-by/lib/3d_blocked.js | 16 +++---- .../base/every-by/lib/3d_blocked_accessors.js | 16 +++---- .../@stdlib/ndarray/base/every-by/lib/4d.js | 16 +++---- .../ndarray/base/every-by/lib/4d_accessors.js | 16 +++---- .../ndarray/base/every-by/lib/4d_blocked.js | 16 +++---- .../base/every-by/lib/4d_blocked_accessors.js | 16 +++---- .../@stdlib/ndarray/base/every-by/lib/5d.js | 16 +++---- .../ndarray/base/every-by/lib/5d_accessors.js | 16 +++---- .../ndarray/base/every-by/lib/5d_blocked.js | 16 +++---- .../base/every-by/lib/5d_blocked_accessors.js | 16 +++---- .../@stdlib/ndarray/base/every-by/lib/6d.js | 16 +++---- .../ndarray/base/every-by/lib/6d_accessors.js | 16 +++---- .../ndarray/base/every-by/lib/6d_blocked.js | 16 +++---- .../base/every-by/lib/6d_blocked_accessors.js | 16 +++---- .../@stdlib/ndarray/base/every-by/lib/7d.js | 16 +++---- .../ndarray/base/every-by/lib/7d_accessors.js | 16 +++---- .../ndarray/base/every-by/lib/7d_blocked.js | 16 +++---- .../base/every-by/lib/7d_blocked_accessors.js | 16 +++---- .../@stdlib/ndarray/base/every-by/lib/8d.js | 16 +++---- .../ndarray/base/every-by/lib/8d_accessors.js | 16 +++---- .../ndarray/base/every-by/lib/8d_blocked.js | 16 +++---- .../base/every-by/lib/8d_blocked_accessors.js | 16 +++---- .../@stdlib/ndarray/base/every-by/lib/9d.js | 16 +++---- .../ndarray/base/every-by/lib/9d_accessors.js | 16 +++---- .../ndarray/base/every-by/lib/9d_blocked.js | 16 +++---- .../base/every-by/lib/9d_blocked_accessors.js | 16 +++---- .../ndarray/base/every-by/lib/index.js | 6 +-- .../@stdlib/ndarray/base/every-by/lib/main.js | 34 +++++++------- .../@stdlib/ndarray/base/every-by/lib/nd.js | 16 +++---- .../ndarray/base/every-by/lib/nd_accessors.js | 16 +++---- .../ndarray/base/every-by/package.json | 2 +- .../ndarray/base/every-by/test/test.0d.js | 6 +-- 50 files changed, 414 insertions(+), 432 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/README.md b/lib/node_modules/@stdlib/ndarray/base/every-by/README.md index 0a8b7b46c8a0..4e0cc5ad5975 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/README.md @@ -20,7 +20,7 @@ limitations under the License. # everyBy -> Test whether every element in an ndarray is truthy according to a callback function. +> Test whether all elements in an ndarray pass a test implemented by a predicate function.
@@ -36,9 +36,9 @@ limitations under the License. var everyBy = require( '@stdlib/ndarray/base/every-by' ); ``` -#### everyBy( arrays, clbk\[, thisArg] ) +#### everyBy( arrays, predicate\[, thisArg] ) -Tests whether every element in an ndarray is truthy according to a callback function. +Tests whether all elements in an ndarray pass a test implemented by a predicate function. @@ -79,8 +79,8 @@ var out = everyBy( [ x ], clbk ); The function accepts the following arguments: - **arrays**: array-like object containing an input ndarray. -- **clbk**: callback function. -- **thisArg**: callback execution context (_optional_). +- **predicate**: predicate function. +- **thisArg**: predicate function execution context (_optional_). The provided ndarray should be an `object` with the following properties: @@ -91,13 +91,13 @@ The provided ndarray should be an `object` with the following properties: - **offset**: index offset. - **order**: specifies whether an ndarray is row-major (C-style) or column major (Fortran-style). -The callback function is provided the following arguments: +The predicate function is provided the following arguments: - **value**: current array element. - **indices**: current array element indices. - **arr**: the input ndarray. -To set the callback function execution context, provide a `thisArg`. +To set the predicate function execution context, provide a `thisArg`. @@ -152,6 +152,7 @@ var count = ctx.count; ## 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 `true`.
diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/repl.txt index bb8d8899e6c4..cf10fa57c711 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/repl.txt @@ -1,7 +1,7 @@ -{{alias}}( arrays, clbk[, thisArg] ) - Tests whether every element in an ndarray is truthy according to a callback - function. +{{alias}}( arrays, predicate[, thisArg] ) + Tests whether all elements in an ndarray pass a test implemented by a + predicate function. A provided "ndarray" should be an `object` with the following properties: @@ -13,28 +13,30 @@ - order: specifies whether an ndarray is row-major (C-style) or column-major (Fortran-style). - The callback function is provided the following arguments: + 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 `true`. + Parameters ---------- arrays: ArrayLikeObject Array-like object containing an input ndarray. - clbk: Function - Callback function. + predicate: Function + Predicate function. thisArg: any (optional) - Callback execution context. + Predicate function execution context. Returns ------- out: boolean - Boolean indicating whether every element in an ndarray is truthy - according to a callback function. + Boolean indicating whether all elements in an ndarray pass a test + implemented by a predicate function. Examples -------- diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/index.d.ts index 862ccf8eb7ae..53257bf98818 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/index.d.ts @@ -24,55 +24,61 @@ import { ArrayLike } from '@stdlib/types/array'; import { typedndarray } from '@stdlib/types/ndarray'; /** -* Callback invoked for each ndarray element. +* Returns a boolean indicating whether an element passes a test. +* +* @returns boolean indicating whether an ndarray element passes a test */ -type Nullary = ( this: U ) => void; +type Nullary = ( this: U ) => boolean; /** -* Callback invoked for each ndarray element. +* 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 ) => void; +type Unary = ( this: U, value: T ) => boolean; /** -* Callback invoked for each ndarray element. +* 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 ) => void; +type Binary = ( this: U, value: T, indices: Array ) => boolean; /** -* Callback invoked for each ndarray element. +* 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 ) => void; +type Ternary = ( this: U, value: T, indices: Array, arr: typedndarray ) => boolean; /** -* Callback invoked for each ndarray element. +* 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 Callback = Nullary | Unary | Binary | Ternary; +type Predicate = Nullary | Unary | Binary | Ternary; /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * -* @param arrays - array-like object containing an output ndarray -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns result +* @param arrays - array-like object containing an input ndarray +* @param predicate - predicate function +* @param thisArg - predicate function execution context +* @returns boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -88,14 +94,14 @@ type Callback = Nullary | Unary | Binary | Ternary; * // Define the index offset: * var ox = 1; * -* // Create the output ndarray: +* // Create the input ndarray: * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); * -* // Apply the callback function: -* var out = everyBy( [ x ], clbk ); +* // Test elements: +* var out = everyBy( [ x ], predicate ); * // returns true */ -declare function everyBy( arrays: ArrayLike>, clbk: Callback, thisArg?: ThisParameterType> ): Boolean; +declare function everyBy( arrays: ArrayLike>, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; // EXPORTS // diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts index f0b8fc91d196..45d402aad679 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/docs/types/test.ts @@ -18,56 +18,29 @@ /// -import { ndarray } from '@stdlib/types/ndarray'; +import zeros = require( '@stdlib/ndarray/zeros' ); import everyBy = require( './index' ); /** -* Mock function to create an ndarray-like object. -* -* @returns ndarray-like object -*/ -function array(): ndarray { - const obj: ndarray = { - 'byteLength': 80, - 'BYTES_PER_ELEMENT': 8, - 'data': new Float64Array( 10 ), - 'dtype': 'float64', - 'flags': { - 'ROW_MAJOR_CONTIGUOUS': true, - 'COLUMN_MAJOR_CONTIGUOUS': false - }, - 'length': 10, - 'ndims': 1, - 'offset': 0, - 'order': 'row-major', - 'shape': [ 10 ], - 'strides': [ 1 ], - 'get': (): number => 0, - 'set': (): ndarray => obj - }; - return obj; -} - -/** -* Callback function. +* Predicate function. * * @param v - ndarray element * @returns result */ -function clbk( v: any ): Boolean { +function clbk( v: any ): boolean { return v > 0.0; } // TESTS // -// The function returns a `Boolean`... +// The function returns a boolean... { - const x = array(); + const x = zeros( [ 2, 2 ] ); const arrays = [ x ]; - everyBy( arrays, clbk ); // $ExpectType Boolean - everyBy( arrays, clbk, {} ); // $ExpectType Boolean + everyBy( arrays, clbk ); // $ExpectType boolean + everyBy( 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... @@ -93,7 +66,7 @@ function clbk( v: any ): Boolean { // The compiler throws an error if the function is provided a second argument which is not a callback function... { - const x = array(); + const x = zeros( [ 2, 2 ] ); const arrays = [ x ]; everyBy( arrays, '10' ); // $ExpectError @@ -117,7 +90,7 @@ function clbk( v: any ): Boolean { // The compiler throws an error if the function is provided an unsupported number of arguments... { - const x = array(); + const x = zeros( [ 2, 2 ] ); const arrays = [ x ]; everyBy(); // $ExpectError diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d.js index eac091aabb5d..630c7de74969 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d.js @@ -21,7 +21,7 @@ // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -32,14 +32,14 @@ * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -67,11 +67,11 @@ * }; * * // Test elements: -* var out = every0d( x, clbk ); +* var out = every0d( x, predicate ); * // returns true */ -function every0d( x, clbk, thisArg ) { - if ( clbk.call( thisArg, x.data[ x.offset ], [], x.ref ) ) { +function every0d( x, predicate, thisArg ) { + if ( predicate.call( thisArg, x.data[ x.offset ], [], x.ref ) ) { return true; } return false; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_accessors.js index 2ad13156cea5..ef17e2144044 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/0d_accessors.js @@ -21,7 +21,7 @@ // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -33,15 +33,15 @@ * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -70,11 +70,11 @@ * }; * * // Test elements: -* var out = every0d( x, clbk ); +* var out = every0d( x, predicate ); * // returns true */ -function every0d( x, clbk, thisArg ) { - if ( clbk.call( thisArg, x.accessors[ 0 ]( x.data, x.offset ), [], x.ref ) ) { // eslint-disable-line max-len +function every0d( 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; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d.js index 77c917014af8..69e0f5e2e9a4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every10d( x, clbk ); +* var out = every10d( x, predicate ); * // returns true */ -function every10d( x, clbk, thisArg ) { // eslint-disable-line max-statements +function every10d( x, predicate, thisArg ) { // eslint-disable-line max-statements var xbuf; var idx; var dx0; @@ -186,7 +186,7 @@ function every10d( x, clbk, thisArg ) { // eslint-disable-line max-statements for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + 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 false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_accessors.js index f456b7a12da3..3bd00015e62a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_accessors.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every10d( x, clbk ); +* var out = every10d( x, predicate ); * // returns true */ -function every10d( x, clbk, thisArg ) { // eslint-disable-line max-statements +function every10d( x, predicate, thisArg ) { // eslint-disable-line max-statements var xbuf; var idx; var get; @@ -193,7 +193,7 @@ function every10d( x, clbk, thisArg ) { // eslint-disable-line max-statements for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + 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 false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked.js index 9a6c462676b9..0994bed3ab90 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery10d( x, clbk ); +* var out = blockedevery10d( x, predicate ); * // returns true */ -function blockedevery10d( x, clbk, thisArg ) { // eslint-disable-line max-statements, max-lines-per-function +function blockedevery10d( x, predicate, thisArg ) { // eslint-disable-line max-statements, max-lines-per-function var bsize; var xbuf; var idx; @@ -274,7 +274,7 @@ function blockedevery10d( x, clbk, thisArg ) { // eslint-disable-line max-statem for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked_accessors.js index 3503c4a1bf6c..56336ec26084 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/10d_blocked_accessors.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery10d( x, clbk ); +* var out = blockedevery10d( x, predicate ); * // returns true */ -function blockedevery10d( x, clbk, thisArg ) { // eslint-disable-line max-statements, max-lines-per-function +function blockedevery10d( x, predicate, thisArg ) { // eslint-disable-line max-statements, max-lines-per-function var bsize; var xbuf; var idx; @@ -281,7 +281,7 @@ function blockedevery10d( x, clbk, thisArg ) { // eslint-disable-line max-statem for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i9, i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js index e19eaaa01ec1..f4e5a12c20f9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d.js @@ -21,7 +21,7 @@ // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -32,14 +32,14 @@ * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -67,10 +67,10 @@ * }; * * // Test elements: -* var out = every1d( x, clbk ); +* var out = every1d( x, predicate ); * // returns true */ -function every1d( x, clbk, thisArg ) { +function every1d( x, predicate, thisArg ) { var xbuf; var dx0; var S0; @@ -91,7 +91,7 @@ function every1d( x, clbk, thisArg ) { // Iterate over the ndarray dimensions... for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], [ i0 ], x.ref ) ) { + if ( !predicate.call( thisArg, xbuf[ ix ], [ i0 ], x.ref ) ) { return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_accessors.js index c679e5d47a1f..31b3168b4551 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/1d_accessors.js @@ -21,7 +21,7 @@ // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -33,15 +33,15 @@ * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -70,10 +70,10 @@ * }; * * // Test elements: -* var out = every1d( x, clbk ); +* var out = every1d( x, predicate ); * // returns true */ -function every1d( x, clbk, thisArg ) { +function every1d( x, predicate, thisArg ) { var xbuf; var get; var dx0; @@ -98,7 +98,7 @@ function every1d( x, clbk, thisArg ) { // Iterate over the ndarray dimensions... for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), [ i0 ], x.ref) ) { + if ( !predicate.call( thisArg, get( xbuf, ix ), [ i0 ], x.ref) ) { return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d.js index 432250cb5ad9..4404c5176adc 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d.js @@ -29,7 +29,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -40,14 +40,14 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -75,10 +75,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every2d( x, clbk ); +* var out = every2d( x, predicate ); * // returns true */ -function every2d( x, clbk, thisArg ) { +function every2d( x, predicate, thisArg ) { var xbuf; var idx; var dx0; @@ -120,7 +120,7 @@ function every2d( x, clbk, thisArg ) { // Iterate over the ndarray dimensions... for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_accessors.js index caef5d041b9a..707aec505df5 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_accessors.js @@ -29,7 +29,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -41,15 +41,15 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -78,10 +78,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every2d( x, clbk ); +* var out = every2d( x, predicate ); * // returns true */ -function every2d( x, clbk, thisArg ) { +function every2d( x, predicate, thisArg ) { var xbuf; var idx; var get; @@ -127,7 +127,7 @@ function every2d( x, clbk, thisArg ) { // Iterate over the ndarray dimensions... for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked.js index 719639841cf3..509749d1f60e 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked.js @@ -29,7 +29,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -40,14 +40,14 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -75,10 +75,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery2d( x, clbk ); +* var out = blockedevery2d( x, predicate ); * // returns true */ -function blockedevery2d( x, clbk, thisArg ) { +function blockedevery2d( x, predicate, thisArg ) { var bsize; var xbuf; var idx; @@ -144,7 +144,7 @@ function blockedevery2d( x, clbk, thisArg ) { // Iterate over the ndarray dimensions... for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js index be897a9d7467..97e01114777c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/2d_blocked_accessors.js @@ -29,7 +29,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -41,15 +41,15 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -78,10 +78,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery2d( x, clbk ); +* var out = blockedevery2d( x, predicate ); * // returns true */ -function blockedevery2d( x, clbk, thisArg ) { +function blockedevery2d( x, predicate, thisArg ) { var bsize; var xbuf; var idx; @@ -151,7 +151,7 @@ function blockedevery2d( x, clbk, thisArg ) { // Iterate over the ndarray dimensions... for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d.js index ffa3ceb9d01b..11bab9f243a3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d.js @@ -29,7 +29,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -40,14 +40,14 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -75,10 +75,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every3d( x, clbk ); +* var out = every3d( x, predicate ); * // returns true */ -function every3d( x, clbk, thisArg ) { +function every3d( x, predicate, thisArg ) { var xbuf; var idx; var dx0; @@ -128,7 +128,7 @@ function every3d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_accessors.js index 5c59934f8b66..be902c7debbc 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_accessors.js @@ -29,7 +29,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -41,15 +41,15 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -78,10 +78,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every3d( x, clbk ); +* var out = every3d( x, predicate ); * // returns true */ -function every3d( x, clbk, thisArg ) { +function every3d( x, predicate, thisArg ) { var xbuf; var idx; var get; @@ -135,7 +135,7 @@ function every3d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked.js index 76b8d3fae84f..7dd413604684 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery3d( x, clbk ); +* var out = blockedevery3d( x, predicate ); * // returns true */ -function blockedevery3d( x, clbk, thisArg ) { +function blockedevery3d( x, predicate, thisArg ) { var bsize; var xbuf; var idx; @@ -162,7 +162,7 @@ function blockedevery3d( x, clbk, thisArg ) { for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js index dc813b0526ca..d089c70985d0 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/3d_blocked_accessors.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery3d( x, clbk ); +* var out = blockedevery3d( x, predicate ); * // returns true */ -function blockedevery3d( x, clbk, thisArg ) { +function blockedevery3d( x, predicate, thisArg ) { var bsize; var xbuf; var idx; @@ -169,7 +169,7 @@ function blockedevery3d( x, clbk, thisArg ) { for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d.js index 7b028d6ba6e5..f5803f27d68c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d.js @@ -29,7 +29,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -40,14 +40,14 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -75,10 +75,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every4d( x, clbk ); +* var out = every4d( x, predicate ); * // returns true */ -function every4d( x, clbk, thisArg ) { +function every4d( x, predicate, thisArg ) { var xbuf; var idx; var dx0; @@ -136,7 +136,7 @@ function every4d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_accessors.js index b2fc16a4b0a5..11c79f3766d7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_accessors.js @@ -29,7 +29,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -41,15 +41,15 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -78,10 +78,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every4d( x, clbk ); +* var out = every4d( x, predicate ); * // returns true */ -function every4d( x, clbk, thisArg ) { +function every4d( x, predicate, thisArg ) { var xbuf; var idx; var get; @@ -143,7 +143,7 @@ function every4d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked.js index cb3f62a90fd5..7e19c07d7dbd 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery4d( x, clbk ); +* var out = blockedevery4d( x, predicate ); * // returns true */ -function blockedevery4d( x, clbk, thisArg ) { +function blockedevery4d( x, predicate, thisArg ) { var bsize; var xbuf; var idx; @@ -178,7 +178,7 @@ function blockedevery4d( x, clbk, thisArg ) { for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js index a63246308a5f..4bb4a2e549bc 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/4d_blocked_accessors.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery4d( x, clbk ); +* var out = blockedevery4d( x, predicate ); * // returns true */ -function blockedevery4d( x, clbk, thisArg ) { +function blockedevery4d( x, predicate, thisArg ) { var bsize; var xbuf; var idx; @@ -185,7 +185,7 @@ function blockedevery4d( x, clbk, thisArg ) { for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d.js index fe07fcaedfd8..1c32b520a5ab 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every5d( x, clbk ); +* var out = every5d( x, predicate ); * // returns true */ -function every5d( x, clbk, thisArg ) { +function every5d( x, predicate, thisArg ) { var xbuf; var idx; var dx0; @@ -146,7 +146,7 @@ function every5d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_accessors.js index d2dd1cf83a90..a760bff23c9d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_accessors.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every5d( x, clbk ); +* var out = every5d( x, predicate ); * // returns true */ -function every5d( x, clbk, thisArg ) { +function every5d( x, predicate, thisArg ) { var xbuf; var idx; var get; @@ -153,7 +153,7 @@ function every5d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked.js index b7a2c20b3dff..935936730aed 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery5d( x, clbk ); +* var out = blockedevery5d( x, predicate ); * // returns true */ -function blockedevery5d( x, clbk, thisArg ) { +function blockedevery5d( x, predicate, thisArg ) { var bsize; var xbuf; var idx; @@ -194,7 +194,7 @@ function blockedevery5d( x, clbk, thisArg ) { for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js index 90f5f1d4805d..32038fbe6240 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/5d_blocked_accessors.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery5d( x, clbk ); +* var out = blockedevery5d( x, predicate ); * // returns true */ -function blockedevery5d( x, clbk, thisArg ) { +function blockedevery5d( x, predicate, thisArg ) { var bsize; var xbuf; var idx; @@ -201,7 +201,7 @@ function blockedevery5d( x, clbk, thisArg ) { for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d.js index dc2110235fe1..2f22f6b0cdcf 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every6d( x, clbk ); +* var out = every6d( x, predicate ); * // returns true */ -function every6d( x, clbk, thisArg ) { +function every6d( x, predicate, thisArg ) { var xbuf; var idx; var dx0; @@ -154,7 +154,7 @@ function every6d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_accessors.js index 1abfb7e52325..6e104352cab5 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_accessors.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every6d( x, clbk ); +* var out = every6d( x, predicate ); * // returns true */ -function every6d( x, clbk, thisArg ) { +function every6d( x, predicate, thisArg ) { var xbuf; var idx; var get; @@ -161,7 +161,7 @@ function every6d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked.js index 8b8923b5a5f8..bf1a216b5c4a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery6d( x, clbk ); +* var out = blockedevery6d( x, predicate ); * // returns true */ -function blockedevery6d( x, clbk, thisArg ) { // eslint-disable-line max-statements +function blockedevery6d( x, predicate, thisArg ) { // eslint-disable-line max-statements var bsize; var xbuf; var idx; @@ -210,7 +210,7 @@ function blockedevery6d( x, clbk, thisArg ) { // eslint-disable-line max-stateme for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js index 19ad98e05c17..a7a1921c936c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/6d_blocked_accessors.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery6d( x, clbk ); +* var out = blockedevery6d( x, predicate ); * // returns true */ -function blockedevery6d( x, clbk, thisArg ) { // eslint-disable-line max-statements +function blockedevery6d( x, predicate, thisArg ) { // eslint-disable-line max-statements var bsize; var xbuf; var idx; @@ -217,7 +217,7 @@ function blockedevery6d( x, clbk, thisArg ) { // eslint-disable-line max-stateme for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d.js index d71c9c3604ad..5cfa953579fd 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every7d( x, clbk ); +* var out = every7d( x, predicate ); * // returns true */ -function every7d( x, clbk, thisArg ) { +function every7d( x, predicate, thisArg ) { var xbuf; var idx; var dx0; @@ -162,7 +162,7 @@ function every7d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_accessors.js index e3c717ea0f19..9a432e230339 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_accessors.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every7d( x, clbk ); +* var out = every7d( x, predicate ); * // returns true */ -function every7d( x, clbk, thisArg ) { +function every7d( x, predicate, thisArg ) { var xbuf; var idx; var get; @@ -169,7 +169,7 @@ function every7d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked.js index 4c51941d7b49..8af64afe38cc 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery7d( x, clbk ); +* var out = blockedevery7d( x, predicate ); * // returns true */ -function blockedevery7d( x, clbk, thisArg ) { // eslint-disable-line max-statements +function blockedevery7d( x, predicate, thisArg ) { // eslint-disable-line max-statements var bsize; var xbuf; var idx; @@ -226,7 +226,7 @@ function blockedevery7d( x, clbk, thisArg ) { // eslint-disable-line max-stateme for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js index 49f993a4b209..e78b31c06aa2 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/7d_blocked_accessors.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery7d( x, clbk ); +* var out = blockedevery7d( x, predicate ); * // returns true */ -function blockedevery7d( x, clbk, thisArg ) { // eslint-disable-line max-statements +function blockedevery7d( x, predicate, thisArg ) { // eslint-disable-line max-statements var bsize; var xbuf; var idx; @@ -233,7 +233,7 @@ function blockedevery7d( x, clbk, thisArg ) { // eslint-disable-line max-stateme for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d.js index 59e65ddd5de5..6f9eb7434cc2 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every8d( x, clbk ); +* var out = every8d( x, predicate ); * // returns true */ -function every8d( x, clbk, thisArg ) { +function every8d( x, predicate, thisArg ) { var xbuf; var idx; var dx0; @@ -170,7 +170,7 @@ function every8d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_accessors.js index 28b8d3f5fd1d..ff0563ce968a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_accessors.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every8d( x, clbk ); +* var out = every8d( x, predicate ); * // returns true */ -function every8d( x, clbk, thisArg ) { +function every8d( x, predicate, thisArg ) { var xbuf; var idx; var get; @@ -177,7 +177,7 @@ function every8d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + 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 false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked.js index d21ae98e9aa6..ddbdc1473bec 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery8d( x, clbk ); +* var out = blockedevery8d( x, predicate ); * // returns true */ -function blockedevery8d( x, clbk, thisArg ) { // eslint-disable-line max-statements +function blockedevery8d( x, predicate, thisArg ) { // eslint-disable-line max-statements var bsize; var xbuf; var idx; @@ -242,7 +242,7 @@ function blockedevery8d( x, clbk, thisArg ) { // eslint-disable-line max-stateme for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js index 963388372ac3..98f0f8258ead 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/8d_blocked_accessors.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery8d( x, clbk ); +* var out = blockedevery8d( x, predicate ); * // returns true */ -function blockedevery8d( x, clbk, thisArg ) { // eslint-disable-line max-statements +function blockedevery8d( x, predicate, thisArg ) { // eslint-disable-line max-statements var bsize; var xbuf; var idx; @@ -249,7 +249,7 @@ function blockedevery8d( x, clbk, thisArg ) { // eslint-disable-line max-stateme for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d.js index b5a68bc84776..aadf595375d5 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every9d( x, clbk ); +* var out = every9d( x, predicate ); * // returns true */ -function every9d( x, clbk, thisArg ) { +function every9d( x, predicate, thisArg ) { var xbuf; var idx; var dx0; @@ -178,7 +178,7 @@ function every9d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + 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 false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_accessors.js index 4c24909d6a7b..eb64053c1daf 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_accessors.js @@ -31,7 +31,7 @@ var take = require( '@stdlib/array/base/take-indexed' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var take = require( '@stdlib/array/base/take-indexed' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var take = require( '@stdlib/array/base/take-indexed' ); * }; * * // Test elements: -* var out = every9d( x, clbk ); +* var out = every9d( x, predicate ); * // returns true */ -function every9d( x, clbk, thisArg ) { +function every9d( x, predicate, thisArg ) { var xbuf; var idx; var get; @@ -185,7 +185,7 @@ function every9d( x, clbk, thisArg ) { for ( i2 = 0; i2 < S2; i2++ ) { for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { // eslint-disable-line max-len + 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 false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked.js index 3e590dfa0093..28f6e0045143 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -42,14 +42,14 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -77,10 +77,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery9d( x, clbk ); +* var out = blockedevery9d( x, predicate ); * // returns true */ -function blockedevery9d( x, clbk, thisArg ) { // eslint-disable-line max-statements +function blockedevery9d( x, predicate, thisArg ) { // eslint-disable-line max-statements var bsize; var xbuf; var idx; @@ -258,7 +258,7 @@ function blockedevery9d( x, clbk, thisArg ) { // eslint-disable-line max-stateme for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, xbuf[ ix ], take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + if ( !predicate.call( thisArg, xbuf[ ix ], take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js index 774d0d114a78..a27b74c493b0 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/9d_blocked_accessors.js @@ -31,7 +31,7 @@ var reverse = require( '@stdlib/array/base/reverse' ); // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function via loop blocking. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function via loop blocking. * * @private * @param {Object} x - object containing ndarray meta data @@ -43,15 +43,15 @@ var reverse = require( '@stdlib/array/base/reverse' ); * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -80,10 +80,10 @@ var reverse = require( '@stdlib/array/base/reverse' ); * }; * * // Test elements: -* var out = blockedevery9d( x, clbk ); +* var out = blockedevery9d( x, predicate ); * // returns true */ -function blockedevery9d( x, clbk, thisArg ) { // eslint-disable-line max-statements +function blockedevery9d( x, predicate, thisArg ) { // eslint-disable-line max-statements var bsize; var xbuf; var idx; @@ -265,7 +265,7 @@ function blockedevery9d( x, clbk, thisArg ) { // eslint-disable-line max-stateme for ( i2 = 0; i2 < s2; i2++ ) { for ( i1 = 0; i1 < s1; i1++ ) { for ( i0 = 0; i0 < s0; i0++ ) { - if ( !clbk.call( thisArg, get( xbuf, ix ), take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { + if ( !predicate.call( thisArg, get( xbuf, ix ), take( [ i8, i7, i6, i5, i4, i3, i2, i1, i0 ], idx ), x.ref ) ) { return false; } ix += dx0; diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/index.js index 8c14c77d65dc..aa7856a4b56c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Test whether every element in an ndarray is truthy according to a callback function. +* Test whether all elements in an ndarray pass a test implemented by a predicate function. * * @module @stdlib/ndarray/base/every-by * @@ -27,7 +27,7 @@ * var Float64Array = require( '@stdlib/array/float64' ); * var everyBy = require( '@stdlib/ndarray/base/every-by' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -55,7 +55,7 @@ * }; * * // Test elements: -* var out = everyBy( [ x ], clbk ); +* var out = everyBy( [ x ], predicate ); * // returns true */ diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js index 28b1ec0f5589..d02018c04394 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js @@ -123,7 +123,7 @@ var MAX_DIMS = EVERY.length - 1; // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * ## Notes * @@ -137,14 +137,14 @@ var MAX_DIMS = EVERY.length - 1; * - **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} clbk - callback function -* @param {thisArg} [thisArg] - callback execution context -* @returns {boolean} result +* @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 clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -172,10 +172,10 @@ var MAX_DIMS = EVERY.length - 1; * }; * * // Test elements: -* var out = everyBy( [ x ], clbk ); +* var out = everyBy( [ x ], predicate ); * // returns true */ -function everyBy( arrays, clbk, thisArg ) { +function everyBy( arrays, predicate, thisArg ) { var ndims; var shx; var iox; @@ -190,9 +190,9 @@ function everyBy( arrays, clbk, thisArg ) { // Determine whether we can avoid iteration altogether... if ( ndims === 0 ) { if ( x.accessorProtocol ) { - return ACCESSOR_EVERY[ ndims ]( x, clbk, thisArg ); + return ACCESSOR_EVERY[ ndims ]( x, predicate, thisArg ); } - return EVERY[ ndims ]( x, clbk, thisArg ); + return EVERY[ ndims ]( x, predicate, thisArg ); } // Compute the number of elements: len = numel( shx ); @@ -204,9 +204,9 @@ function everyBy( arrays, clbk, thisArg ) { // Determine whether the ndarray is one-dimensional and thus readily translates to a one-dimensional strided array... if ( ndims === 1 ) { if ( x.accessorProtocol ) { - return ACCESSOR_EVERY[ ndims ]( x, clbk, thisArg ); + return ACCESSOR_EVERY[ ndims ]( x, predicate, thisArg ); } - return EVERY[ ndims ]( x, clbk, thisArg ); + return EVERY[ ndims ]( x, predicate, thisArg ); } // Determine the iteration order: iox = iterationOrder( x.strides ); // +/-1 @@ -217,24 +217,24 @@ function everyBy( arrays, clbk, thisArg ) { if ( ndims <= MAX_DIMS ) { // So long as iteration always moves in the same direction (i.e., no mixed sign strides), we can leverage cache-optimal (i.e., normal) nested loops without resorting to blocked iteration... if ( x.accessorProtocol ) { - return ACCESSOR_EVERY[ ndims ]( x, clbk, thisArg ); + return ACCESSOR_EVERY[ ndims ]( x, predicate, thisArg ); } - return EVERY[ ndims ]( x, clbk, thisArg ); + return EVERY[ ndims ]( x, predicate, thisArg ); } // Fall-through to blocked iteration... } // Determine whether we can perform blocked iteration... if ( ndims <= MAX_DIMS ) { if ( x.accessorProtocol ) { - return BLOCKED_ACCESSOR_EVERY[ ndims-2 ]( x, clbk, thisArg ); + return BLOCKED_ACCESSOR_EVERY[ ndims-2 ]( x, predicate, thisArg ); } - return BLOCKED_EVERY[ ndims-2 ]( x, clbk, thisArg ); + return BLOCKED_EVERY[ 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 accessoreverynd( x, clbk, thisArg ); + return accessoreverynd( x, predicate, thisArg ); } - return everynd( x, clbk, thisArg ); + return everynd( x, predicate, thisArg ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js index 310461eff9d2..f59735720c46 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd.js @@ -33,7 +33,7 @@ var MODE = 'throw'; // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -44,14 +44,14 @@ var MODE = 'throw'; * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -79,10 +79,10 @@ var MODE = 'throw'; * }; * * // Test elements: -* var out = everynd( x, clbk ); +* var out = everynd( x, predicate ); * // returns true */ -function everynd( x, clbk, thisArg ) { +function everynd( x, predicate, thisArg ) { var xbuf; var ordx; var idx; @@ -114,7 +114,7 @@ function everynd( x, clbk, thisArg ) { 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 ( !clbk.call( thisArg, xbuf[ ix ], idx, x.ref ) ) { + if ( !predicate.call( thisArg, xbuf[ ix ], idx, x.ref ) ) { return false; } } diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_accessors.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_accessors.js index 8190b57f8c2a..d17248ae9a52 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_accessors.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/nd_accessors.js @@ -33,7 +33,7 @@ var MODE = 'throw'; // MAIN // /** -* Tests whether every element in an ndarray is truthy according to a callback function. +* Tests whether all elements in an ndarray pass a test implemented by a predicate function. * * @private * @param {Object} x - object containing ndarray meta data @@ -45,15 +45,15 @@ var MODE = 'throw'; * @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} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {boolean} result +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test * * @example * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var accessors = require( '@stdlib/array/base/accessors' ); * -* function clbk( value ) { +* function predicate( value ) { * return value > 0.0; * } * @@ -82,10 +82,10 @@ var MODE = 'throw'; * }; * * // Test elements: -* var out = everynd( x, clbk ); +* var out = everynd( x, predicate ); * // returns true */ -function everynd( x, clbk, thisArg ) { +function everynd( x, predicate, thisArg ) { var xbuf; var ordx; var idx; @@ -121,7 +121,7 @@ function everynd( x, clbk, thisArg ) { 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 ( !clbk.call( thisArg, get( xbuf, ix ), idx, x.ref ) ) { + if ( !predicate.call( thisArg, get( xbuf, ix ), idx, x.ref ) ) { return false; } } diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/package.json b/lib/node_modules/@stdlib/ndarray/base/every-by/package.json index 4271fb91f863..142c860e3853 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/package.json +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/ndarray/base/every-by", "version": "0.0.0", - "description": "Test whether every element in an ndarray is truthy according to a callback function.", + "description": "Test whether all elements in an ndarray pass a test implemented by a predicate function.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js index 5e10b6378261..e89956f46ec8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/test/test.0d.js @@ -39,7 +39,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function tests whether every element in a 0-dimensional ndarray is truthy according to a callback function', function test( t ) { +tape( 'the function tests whether every element in a 0-dimensional ndarray passes a test implemented by a predicate function', function test( t ) { var actual; var x; @@ -64,7 +64,7 @@ tape( 'the function tests whether every element in a 0-dimensional ndarray is tr } }); -tape( 'the function tests whether every element in a 0-dimensional ndarray is truthy according to a callback function (accessors)', function test( t ) { +tape( 'the function tests whether every element in a 0-dimensional ndarray passes a test implemented by a predicate function (accessors)', function test( t ) { var actual; var x; @@ -85,7 +85,7 @@ tape( 'the function tests whether every element in a 0-dimensional ndarray is tr } }); -tape( 'the function tests whether every element in a 0-dimensional ndarray is truthy according to a callback function (complex)', function test( t ) { +tape( 'the function tests whether every element in a 0-dimensional ndarray passes a test implemented by a predicate function (complex)', function test( t ) { var actual; var x; From dcbe15bcd6b82b3cef66f02d09cd71530e1613f5 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 03:57:34 -0700 Subject: [PATCH 24/25] refactor: inline expression rather than create intermediate variable --- 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 --- --- lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js index d02018c04394..5bab637f0bc1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js @@ -179,7 +179,6 @@ function everyBy( arrays, predicate, thisArg ) { var ndims; var shx; var iox; - var len; var x; // Unpack the ndarray and standardize ndarray meta data: @@ -194,11 +193,8 @@ function everyBy( arrays, predicate, thisArg ) { } return EVERY[ ndims ]( x, predicate, thisArg ); } - // Compute the number of elements: - len = numel( shx ); - // Check whether we were provided an empty ndarray... - if ( len === 0 ) { + if ( numel( shx ) === 0 ) { return true; } // Determine whether the ndarray is one-dimensional and thus readily translates to a one-dimensional strided array... From 4980a8fbb06d817d578abb5dff3b26c00bb9660e Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 04:00:11 -0700 Subject: [PATCH 25/25] refactor: reduce branching --- 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/every-by/lib/main.js | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js index 5bab637f0bc1..88bac59ff626 100644 --- a/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js @@ -178,7 +178,6 @@ var MAX_DIMS = EVERY.length - 1; function everyBy( arrays, predicate, thisArg ) { var ndims; var shx; - var iox; var x; // Unpack the ndarray and standardize ndarray meta data: @@ -197,28 +196,14 @@ function everyBy( arrays, predicate, thisArg ) { if ( numel( shx ) === 0 ) { return true; } - // Determine whether the ndarray is one-dimensional and thus readily translates to a one-dimensional strided array... - if ( ndims === 1 ) { + // 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_EVERY[ ndims ]( x, predicate, thisArg ); } return EVERY[ ndims ]( x, predicate, thisArg ); } - // Determine the iteration order: - iox = iterationOrder( x.strides ); // +/-1 - - // Determine whether we can avoid blocked iteration... - if ( iox !== 0 ) { - // Determine whether we can use simple nested loops... - if ( ndims <= MAX_DIMS ) { - // So long as iteration always moves in the same direction (i.e., no mixed sign strides), we can leverage cache-optimal (i.e., normal) nested loops without resorting to blocked iteration... - if ( x.accessorProtocol ) { - return ACCESSOR_EVERY[ ndims ]( x, predicate, thisArg ); - } - return EVERY[ ndims ]( x, predicate, thisArg ); - } - // Fall-through to blocked iteration... - } // Determine whether we can perform blocked iteration... if ( ndims <= MAX_DIMS ) { if ( x.accessorProtocol ) {