From 0ec97844380a9c87d6e9d42c18edb4eeec6caffc Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 1 Oct 2026 15:29:09 +0500 Subject: [PATCH 1/7] feat: add ndarray/base/kernels/generic/quaternary/unblocked --- .../generic/quaternary/unblocked/README.md | 245 ++++++++++ .../unblocked/benchmark/benchmark.1d.js | 170 +++++++ .../unblocked/benchmark/benchmark.2d.js | 200 ++++++++ .../quaternary/unblocked/docs/repl.txt | 26 + .../quaternary/unblocked/examples/index.js | 88 ++++ .../generic/quaternary/unblocked/lib/0d.js | 151 ++++++ .../generic/quaternary/unblocked/lib/10d.js | 460 ++++++++++++++++++ .../generic/quaternary/unblocked/lib/1d.js | 201 ++++++++ .../generic/quaternary/unblocked/lib/2d.js | 250 ++++++++++ .../generic/quaternary/unblocked/lib/3d.js | 278 +++++++++++ .../generic/quaternary/unblocked/lib/4d.js | 304 ++++++++++++ .../generic/quaternary/unblocked/lib/5d.js | 330 +++++++++++++ .../generic/quaternary/unblocked/lib/6d.js | 356 ++++++++++++++ .../generic/quaternary/unblocked/lib/7d.js | 382 +++++++++++++++ .../generic/quaternary/unblocked/lib/8d.js | 408 ++++++++++++++++ .../generic/quaternary/unblocked/lib/9d.js | 434 +++++++++++++++++ .../generic/quaternary/unblocked/lib/index.js | 137 ++++++ .../generic/quaternary/unblocked/lib/main.js | 147 ++++++ .../generic/quaternary/unblocked/package.json | 62 +++ .../generic/quaternary/unblocked/test/test.js | 150 ++++++ 20 files changed, 4779 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.2d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/0d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/10d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/1d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/2d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/3d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/4d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/5d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/6d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/7d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/8d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/9d.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/README.md b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/README.md new file mode 100644 index 000000000000..daf74ad87636 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/README.md @@ -0,0 +1,245 @@ + + +# kernel + +> Return a kernel for applying a quaternary callback to elements in four input ndarrays and assigning results to elements in an output ndarray. + +
+ +
+ + + +
+ +## Usage + +```javascript +var kernel = require( '@stdlib/ndarray/base/kernels/generic/quaternary/unblocked' ); +``` + +#### kernel( ndims ) + +Returns a kernel for applying a quaternary callback to elements in four input ndarrays and assigning results to elements in an output ndarray. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +function add4( a, b, c, d ) { + return a + b + c + d; +} + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the shape of the input and output arrays: +var shape = [ 3, 2 ]; + +// Define the array strides: +var sx = [ 2, 1 ]; +var sy = [ 2, 1 ]; +var sz = [ 2, 1 ]; +var sw = [ 2, 1 ]; +var su = [ 2, 1 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': sx, + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': sy, + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': sz, + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': sw, + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': su, + 'offset': 0, + 'order': 'row-major' +}; + +// Resolve a kernel: +var f = kernel( 2 ); + +// Apply the quaternary function: +f( x, y, z, w, u, true, add4 ); + +var v = u.data; +// returns [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] +``` + +The function accepts the following arguments: + +- **ndims**: number of dimensions. + +If the function is provided an `ndims` value greater than the maximum number of supported dimensions, the function returns `null`. + +```javascript +var f = kernel( 100000 ); +// returns null +``` + +
+ + + +
+ +## Notes + +- Each returned kernel expects the following arguments: + + - **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). + - **y**: second input ndarray descriptor. + - **z**: third input ndarray descriptor. + - **w**: fourth input ndarray descriptor. + - **u**: output ndarray descriptor. + - **isRowMajor**: boolean indicating whether the arrays are in row-major order (required for kernels with two or more dimensions). + - **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var kernel = require( '@stdlib/ndarray/base/kernels/generic/quaternary/unblocked' ); + +function add4( a, b, c, d ) { + return a + b + c + d; +} + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var shape = [ 3, 2 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Resolve a kernel: +var f = kernel( 2 ); + +// Apply the quaternary function: +f( x, y, z, w, u, true, add4 ); + +console.log( ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ) ); +// => [ [ 7.0, 8.0 ], [ 9.0, 10.0 ], [ 11.0, 12.0 ] ] +``` + +
+ + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js new file mode 100644 index 000000000000..01a9f8929a97 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js @@ -0,0 +1,170 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var filledarray = require( '@stdlib/array/filled' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var orders = require( '@stdlib/ndarray/orders' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var kernel = require( './../lib' ); + + +// VARIABLES // + +var TYPES = [ + 'float64' +]; +var ORDERS = orders(); + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - input ndarray data type +* @param {string} utype - output ndarray data type +* @param {string} order - memory layout +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype, utype, order ) { + var x; + var y; + var z; + var w; + var u; + var f; + + x = { + 'dtype': xtype, + 'data': discreteUniform( len, -100, 100, { 'dtype': xtype } ), + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': xtype, + 'data': discreteUniform( len, -100, 100, { 'dtype': xtype } ), + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + z = { + 'dtype': xtype, + 'data': discreteUniform( len, -100, 100, { 'dtype': xtype } ), + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + w = { + 'dtype': xtype, + 'data': discreteUniform( len, -100, 100, { 'dtype': xtype } ), + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + u = { + 'dtype': utype, + 'data': filledarray( 0.0, len, utype ), + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + f = kernel( shape.length ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f( x, y, z, w, u, add4 ); + if ( isnan( u.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( u.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var ord; + var sh; + var t1; + var t2; + var f; + var i; + var j; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < ORDERS.length; k++ ) { + ord = ORDERS[ k ]; + for ( j = 0; j < TYPES.length; j++ ) { + t1 = TYPES[ j ]; + t2 = TYPES[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len ]; + f = createBenchmark( len, sh, t1, t2, ord ); + bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,uorder=%s,xtype=%s,utype=%s', pkg, sh.length, len, sh.join(','), ord, ord, t1, t2 ), f ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.2d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.2d.js new file mode 100644 index 000000000000..173910830b47 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.2d.js @@ -0,0 +1,200 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +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 filledarray = require( '@stdlib/array/filled' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var orders = require( '@stdlib/ndarray/orders' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var kernel = require( './../lib' ); + + +// VARIABLES // + +var TYPES = [ + 'float64' +]; +var ORDERS = orders(); + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - input ndarray data type +* @param {string} utype - output ndarray data type +* @param {string} order - memory layout +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype, utype, order ) { + var isrm; + var x; + var y; + var z; + var w; + var u; + var f; + + isrm = isRowMajor( order ); + + x = discreteUniform( len, -100, 100, { + 'dtype': xtype + }); + y = discreteUniform( len, -100, 100, { + 'dtype': xtype + }); + z = discreteUniform( len, -100, 100, { + 'dtype': xtype + }); + w = discreteUniform( len, -100, 100, { + 'dtype': xtype + }); + u = filledarray( 0.0, len, utype ); + + x = { + 'dtype': xtype, + 'data': x, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + y = { + 'dtype': xtype, + 'data': y, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + z = { + 'dtype': xtype, + 'data': z, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + w = { + 'dtype': xtype, + 'data': w, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + u = { + 'dtype': utype, + 'data': u, + 'shape': shape, + 'strides': shape2strides( shape, order ), + 'offset': 0, + 'order': order + }; + f = kernel( shape.length ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f( x, y, z, w, u, isrm, add4 ); + if ( isnan( u.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( u.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var ord; + var sh; + var t1; + var t2; + var f; + var i; + var j; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < ORDERS.length; k++ ) { + ord = ORDERS[ k ]; + for ( j = 0; j < TYPES.length; j++ ) { + t1 = TYPES[ j ]; + t2 = TYPES[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t1, t2, ord ); + bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,uorder=%s,xtype=%s,utype=%s', pkg, sh.length, len, sh.join(','), ord, ord, t1, t2 ), f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t1, t2, ord ); + bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,uorder=%s,xtype=%s,utype=%s', pkg, sh.length, len, sh.join(','), ord, ord, t1, t2 ), f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t1, t2, ord ); + bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,uorder=%s,xtype=%s,utype=%s', pkg, sh.length, len, sh.join(','), ord, ord, t1, t2 ), f ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt new file mode 100644 index 000000000000..aee4812d3e84 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt @@ -0,0 +1,26 @@ + +{{alias}}( ndims ) + Returns a kernel for applying a quaternary callback to elements in four + input ndarrays and assigning results to elements in an output ndarray. + + If `ndims` is greater than the maximum supported number of dimensions, + the function returns `null`. + + Parameters + ---------- + ndims: integer + Number of dimensions. + + Returns + ------- + fcn: Function|null + Kernel function. + + Examples + -------- + > var f = {{alias}}( 2 ) + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/examples/index.js new file mode 100644 index 000000000000..83c4ac32821e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/examples/index.js @@ -0,0 +1,88 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var kernel = require( './../lib' ); + +function add4( a, b, c, d ) { + return a + b + c + d; +} + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Define the array shapes: +var shape = [ 3, 2 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Resolve a kernel: +var f = kernel( 2 ); + +// Apply the quaternary function: +f( x, y, z, w, u, true, add4 ); + +console.log( ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ) ); +// => [ [ 7.0, 8.0 ], [ 9.0, 10.0 ], [ 11.0, 12.0 ] ] diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/0d.js new file mode 100644 index 000000000000..afd67a473533 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/0d.js @@ -0,0 +1,151 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Applies a quaternary callback to elements in zero-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {*} 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 {Object} y - object containing input ndarray meta data +* @param {*} y.dtype - data type +* @param {Collection} y.data - data buffer +* @param {NonNegativeIntegerArray} y.shape - dimensions +* @param {IntegerArray} y.strides - stride lengths +* @param {NonNegativeInteger} y.offset - index offset +* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} z - object containing input ndarray meta data +* @param {*} z.dtype - data type +* @param {Collection} z.data - data buffer +* @param {NonNegativeIntegerArray} z.shape - dimensions +* @param {IntegerArray} z.strides - stride lengths +* @param {NonNegativeInteger} z.offset - index offset +* @param {string} z.order - specifies whether `z` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} w - object containing input ndarray meta data +* @param {*} w.dtype - data type +* @param {Collection} w.data - data buffer +* @param {NonNegativeIntegerArray} w.shape - dimensions +* @param {IntegerArray} w.strides - stride lengths +* @param {NonNegativeInteger} w.offset - index offset +* @param {string} w.order - specifies whether `w` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} u - object containing output ndarray meta data +* @param {*} u.dtype - data type +* @param {Collection} u.data - data buffer +* @param {NonNegativeIntegerArray} u.shape - dimensions +* @param {IntegerArray} u.strides - stride lengths +* @param {NonNegativeInteger} u.offset - index offset +* @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {Callback} fcn - quaternary callback +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function fcn( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0 ] ); +* var ybuf = new Float64Array( [ 2.0 ] ); +* var zbuf = new Float64Array( [ 3.0 ] ); +* var wbuf = new Float64Array( [ 4.0 ] ); +* var ubuf = new Float64Array( [ 0.0 ] ); +* +* // Define the shape of the input and output arrays: +* var shape = []; +* +* // Define the array strides: +* var sx = [ 0 ]; +* var sy = [ 0 ]; +* var sz = [ 0 ]; +* var sw = [ 0 ]; +* var su = [ 0 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* var ow = 0; +* var ou = 0; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': ow, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': ou, +* 'order': 'row-major' +* }; +* +* // Apply the quaternary function: +* quaternary0d( x, y, z, w, u, fcn ); +* +* console.log( u.data ); +* // => [ 10.0 ] +*/ +function quaternary0d( x, y, z, w, u, fcn ) { + u.data[ u.offset ] = fcn( x.data[ x.offset ], y.data[ y.offset ], z.data[ z.offset ], w.data[ w.offset ] ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = quaternary0d; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/10d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/10d.js new file mode 100644 index 000000000000..0b20819cc841 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/10d.js @@ -0,0 +1,460 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-statements, max-depth, max-lines-per-function */ + +'use strict'; + +// MAIN // + +/** +* Applies a quaternary callback to elements in ten-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {*} 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 {Object} y - object containing input ndarray meta data +* @param {*} y.dtype - data type +* @param {Collection} y.data - data buffer +* @param {NonNegativeIntegerArray} y.shape - dimensions +* @param {IntegerArray} y.strides - stride lengths +* @param {NonNegativeInteger} y.offset - index offset +* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} z - object containing input ndarray meta data +* @param {*} z.dtype - data type +* @param {Collection} z.data - data buffer +* @param {NonNegativeIntegerArray} z.shape - dimensions +* @param {IntegerArray} z.strides - stride lengths +* @param {NonNegativeInteger} z.offset - index offset +* @param {string} z.order - specifies whether `z` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} w - object containing input ndarray meta data +* @param {*} w.dtype - data type +* @param {Collection} w.data - data buffer +* @param {NonNegativeIntegerArray} w.shape - dimensions +* @param {IntegerArray} w.strides - stride lengths +* @param {NonNegativeInteger} w.offset - index offset +* @param {string} w.order - specifies whether `w` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} u - object containing output ndarray meta data +* @param {*} u.dtype - data type +* @param {Collection} u.data - data buffer +* @param {NonNegativeIntegerArray} u.shape - dimensions +* @param {IntegerArray} u.strides - stride lengths +* @param {NonNegativeInteger} u.offset - index offset +* @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order +* @param {Callback} fcn - quaternary callback +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function fcn( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( 8 ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var sy = [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var sz = [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var sw = [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var su = [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* var ow = 0; +* var ou = 0; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': ow, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': ou, +* 'order': 'row-major' +* }; +* +* // Apply the quaternary function: +* quaternary10d( x, y, z, w, u, true, fcn ); +* +* console.log( u.data ); +* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +*/ +function quaternary10d( x, y, z, w, u, isRowMajor, fcn ) { + var xbuf; + var ybuf; + var zbuf; + var wbuf; + var ubuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dx9; + var dy0; + var dy1; + var dy2; + var dy3; + var dy4; + var dy5; + var dy6; + var dy7; + var dy8; + var dy9; + var dz0; + var dz1; + var dz2; + var dz3; + var dz4; + var dz5; + var dz6; + var dz7; + var dz8; + var dz9; + var dw0; + var dw1; + var dw2; + var dw3; + var dw4; + var dw5; + var dw6; + var dw7; + var dw8; + var dw9; + var du0; + var du1; + var du2; + var du3; + var du4; + var du5; + var du6; + var du7; + var du8; + var du9; + 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 sy; + var sz; + var sw; + var su; + var ix; + var iy; + var iz; + var iw; + var iu; + 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#, dz#, dw#, du#, 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; + sy = y.strides; + sz = z.strides; + sw = w.strides; + su = u.strides; + if ( isRowMajor ) { + // 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 + dy0 = sy[ 9 ]; + dy1 = sy[ 8 ] - ( S0*sy[9] ); + dy2 = sy[ 7 ] - ( S1*sy[8] ); + dy3 = sy[ 6 ] - ( S2*sy[7] ); + dy4 = sy[ 5 ] - ( S3*sy[6] ); + dy5 = sy[ 4 ] - ( S4*sy[5] ); + dy6 = sy[ 3 ] - ( S5*sy[4] ); + dy7 = sy[ 2 ] - ( S6*sy[3] ); + dy8 = sy[ 1 ] - ( S7*sy[2] ); + dy9 = sy[ 0 ] - ( S8*sy[1] ); + dz0 = sz[ 9 ]; + dz1 = sz[ 8 ] - ( S0*sz[9] ); + dz2 = sz[ 7 ] - ( S1*sz[8] ); + dz3 = sz[ 6 ] - ( S2*sz[7] ); + dz4 = sz[ 5 ] - ( S3*sz[6] ); + dz5 = sz[ 4 ] - ( S4*sz[5] ); + dz6 = sz[ 3 ] - ( S5*sz[4] ); + dz7 = sz[ 2 ] - ( S6*sz[3] ); + dz8 = sz[ 1 ] - ( S7*sz[2] ); + dz9 = sz[ 0 ] - ( S8*sz[1] ); + dw0 = sw[ 9 ]; + dw1 = sw[ 8 ] - ( S0*sw[9] ); + dw2 = sw[ 7 ] - ( S1*sw[8] ); + dw3 = sw[ 6 ] - ( S2*sw[7] ); + dw4 = sw[ 5 ] - ( S3*sw[6] ); + dw5 = sw[ 4 ] - ( S4*sw[5] ); + dw6 = sw[ 3 ] - ( S5*sw[4] ); + dw7 = sw[ 2 ] - ( S6*sw[3] ); + dw8 = sw[ 1 ] - ( S7*sw[2] ); + dw9 = sw[ 0 ] - ( S8*sw[1] ); + du0 = su[ 9 ]; + du1 = su[ 8 ] - ( S0*su[9] ); + du2 = su[ 7 ] - ( S1*su[8] ); + du3 = su[ 6 ] - ( S2*su[7] ); + du4 = su[ 5 ] - ( S3*su[6] ); + du5 = su[ 4 ] - ( S4*su[5] ); + du6 = su[ 3 ] - ( S5*su[4] ); + du7 = su[ 2 ] - ( S6*su[3] ); + du8 = su[ 1 ] - ( S7*su[2] ); + du9 = su[ 0 ] - ( S8*su[1] ); + } 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 + dy0 = sy[ 0 ]; + dy1 = sy[ 1 ] - ( S0*sy[0] ); + dy2 = sy[ 2 ] - ( S1*sy[1] ); + dy3 = sy[ 3 ] - ( S2*sy[2] ); + dy4 = sy[ 4 ] - ( S3*sy[3] ); + dy5 = sy[ 5 ] - ( S4*sy[4] ); + dy6 = sy[ 6 ] - ( S5*sy[5] ); + dy7 = sy[ 7 ] - ( S6*sy[6] ); + dy8 = sy[ 8 ] - ( S7*sy[7] ); + dy9 = sy[ 9 ] - ( S8*sy[8] ); + dz0 = sz[ 0 ]; + dz1 = sz[ 1 ] - ( S0*sz[0] ); + dz2 = sz[ 2 ] - ( S1*sz[1] ); + dz3 = sz[ 3 ] - ( S2*sz[2] ); + dz4 = sz[ 4 ] - ( S3*sz[3] ); + dz5 = sz[ 5 ] - ( S4*sz[4] ); + dz6 = sz[ 6 ] - ( S5*sz[5] ); + dz7 = sz[ 7 ] - ( S6*sz[6] ); + dz8 = sz[ 8 ] - ( S7*sz[7] ); + dz9 = sz[ 9 ] - ( S8*sz[8] ); + dw0 = sw[ 0 ]; + dw1 = sw[ 1 ] - ( S0*sw[0] ); + dw2 = sw[ 2 ] - ( S1*sw[1] ); + dw3 = sw[ 3 ] - ( S2*sw[2] ); + dw4 = sw[ 4 ] - ( S3*sw[3] ); + dw5 = sw[ 5 ] - ( S4*sw[4] ); + dw6 = sw[ 6 ] - ( S5*sw[5] ); + dw7 = sw[ 7 ] - ( S6*sw[6] ); + dw8 = sw[ 8 ] - ( S7*sw[7] ); + dw9 = sw[ 9 ] - ( S8*sw[8] ); + du0 = su[ 0 ]; + du1 = su[ 1 ] - ( S0*su[0] ); + du2 = su[ 2 ] - ( S1*su[1] ); + du3 = su[ 3 ] - ( S2*su[2] ); + du4 = su[ 4 ] - ( S3*su[3] ); + du5 = su[ 5 ] - ( S4*su[4] ); + du6 = su[ 6 ] - ( S5*su[5] ); + du7 = su[ 7 ] - ( S6*su[6] ); + du8 = su[ 8 ] - ( S7*su[7] ); + du9 = su[ 9 ] - ( S8*su[8] ); + } + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + iy = y.offset; + iz = z.offset; + iw = w.offset; + iu = u.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + ybuf = y.data; + zbuf = z.data; + wbuf = w.data; + ubuf = u.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++ ) { + ubuf[ iu ] = fcn( xbuf[ ix ], ybuf[ iy ], zbuf[ iz ], wbuf[ iw ] ); // eslint-disable-line max-len + ix += dx0; + iy += dy0; + iz += dz0; + iw += dw0; + iu += du0; + } + ix += dx1; + iy += dy1; + iz += dz1; + iw += dw1; + iu += du1; + } + ix += dx2; + iy += dy2; + iz += dz2; + iw += dw2; + iu += du2; + } + ix += dx3; + iy += dy3; + iz += dz3; + iw += dw3; + iu += du3; + } + ix += dx4; + iy += dy4; + iz += dz4; + iw += dw4; + iu += du4; + } + ix += dx5; + iy += dy5; + iz += dz5; + iw += dw5; + iu += du5; + } + ix += dx6; + iy += dy6; + iz += dz6; + iw += dw6; + iu += du6; + } + ix += dx7; + iy += dy7; + iz += dz7; + iw += dw7; + iu += du7; + } + ix += dx8; + iy += dy8; + iz += dz8; + iw += dw8; + iu += du8; + } + ix += dx9; + iy += dy9; + iz += dz9; + iw += dw9; + iu += du9; + } +} + + +// EXPORTS // + +module.exports = quaternary10d; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/1d.js new file mode 100644 index 000000000000..e556fced5cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/1d.js @@ -0,0 +1,201 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Applies a quaternary callback to elements in one-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {*} 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 {Object} y - object containing input ndarray meta data +* @param {*} y.dtype - data type +* @param {Collection} y.data - data buffer +* @param {NonNegativeIntegerArray} y.shape - dimensions +* @param {IntegerArray} y.strides - stride lengths +* @param {NonNegativeInteger} y.offset - index offset +* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} z - object containing input ndarray meta data +* @param {*} z.dtype - data type +* @param {Collection} z.data - data buffer +* @param {NonNegativeIntegerArray} z.shape - dimensions +* @param {IntegerArray} z.strides - stride lengths +* @param {NonNegativeInteger} z.offset - index offset +* @param {string} z.order - specifies whether `z` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} w - object containing input ndarray meta data +* @param {*} w.dtype - data type +* @param {Collection} w.data - data buffer +* @param {NonNegativeIntegerArray} w.shape - dimensions +* @param {IntegerArray} w.strides - stride lengths +* @param {NonNegativeInteger} w.offset - index offset +* @param {string} w.order - specifies whether `w` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} u - object containing output ndarray meta data +* @param {*} u.dtype - data type +* @param {Collection} u.data - data buffer +* @param {NonNegativeIntegerArray} u.shape - dimensions +* @param {IntegerArray} u.strides - stride lengths +* @param {NonNegativeInteger} u.offset - index offset +* @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {Callback} fcn - quaternary callback +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function fcn( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 5 ]; +* +* // Define the array strides: +* var sx = [ 1 ]; +* var sy = [ 1 ]; +* var sz = [ 1 ]; +* var sw = [ 1 ]; +* var su = [ 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* var ow = 0; +* var ou = 0; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': ow, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': ou, +* 'order': 'row-major' +* }; +* +* // Apply the quaternary function: +* quaternary1d( x, y, z, w, u, fcn ); +* +* console.log( u.data ); +* // => [ 7.0, 8.0, 9.0, 10.0, 11.0 ] +*/ +function quaternary1d( x, y, z, w, u, fcn ) { + var xbuf; + var ybuf; + var zbuf; + var wbuf; + var ubuf; + var dx; + var dy; + var dz; + var dw; + var du; + var S0; + var ix; + var iy; + var iz; + var iw; + var iu; + var i; + + // Note on variable naming convention: S#, 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 ]; + dx = x.strides[ 0 ]; + dy = y.strides[ 0 ]; + dz = z.strides[ 0 ]; + dw = w.strides[ 0 ]; + du = u.strides[ 0 ]; + + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + iy = y.offset; + iz = z.offset; + iw = w.offset; + iu = u.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + ybuf = y.data; + zbuf = z.data; + wbuf = w.data; + ubuf = u.data; + + // Iterate over the ndarray dimensions... + for ( i = 0; i < S0; i++ ) { + ubuf[ iu ] = fcn( xbuf[ ix ], ybuf[ iy ], zbuf[ iz ], wbuf[ iw ] ); + ix += dx; + iy += dy; + iz += dz; + iw += dw; + iu += du; + } +} + + +// EXPORTS // + +module.exports = quaternary1d; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/2d.js new file mode 100644 index 000000000000..14a6cf584e30 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/2d.js @@ -0,0 +1,250 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Applies a quaternary callback to elements in two-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {*} 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 {Object} y - object containing input ndarray meta data +* @param {*} y.dtype - data type +* @param {Collection} y.data - data buffer +* @param {NonNegativeIntegerArray} y.shape - dimensions +* @param {IntegerArray} y.strides - stride lengths +* @param {NonNegativeInteger} y.offset - index offset +* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} z - object containing input ndarray meta data +* @param {*} z.dtype - data type +* @param {Collection} z.data - data buffer +* @param {NonNegativeIntegerArray} z.shape - dimensions +* @param {IntegerArray} z.strides - stride lengths +* @param {NonNegativeInteger} z.offset - index offset +* @param {string} z.order - specifies whether `z` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} w - object containing input ndarray meta data +* @param {*} w.dtype - data type +* @param {Collection} w.data - data buffer +* @param {NonNegativeIntegerArray} w.shape - dimensions +* @param {IntegerArray} w.strides - stride lengths +* @param {NonNegativeInteger} w.offset - index offset +* @param {string} w.order - specifies whether `w` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} u - object containing output ndarray meta data +* @param {*} u.dtype - data type +* @param {Collection} u.data - data buffer +* @param {NonNegativeIntegerArray} u.shape - dimensions +* @param {IntegerArray} u.strides - stride lengths +* @param {NonNegativeInteger} u.offset - index offset +* @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order +* @param {Callback} fcn - quaternary callback +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function fcn( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( 6 ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 3, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 1 ]; +* var sy = [ 2, 1 ]; +* var sz = [ 2, 1 ]; +* var sw = [ 2, 1 ]; +* var su = [ 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* var ow = 0; +* var ou = 0; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': ow, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': ou, +* 'order': 'row-major' +* }; +* +* // Apply the quaternary function: +* quaternary2d( x, y, z, w, u, true, fcn ); +* +* console.log( u.data ); +* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] +*/ +function quaternary2d( x, y, z, w, u, isRowMajor, fcn ) { + var xbuf; + var ybuf; + var zbuf; + var wbuf; + var ubuf; + var dx0; + var dx1; + var dy0; + var dy1; + var dz0; + var dz1; + var dw0; + var dw1; + var du0; + var du1; + var sh; + var S0; + var S1; + var sx; + var sy; + var sz; + var sw; + var su; + var ix; + var iy; + var iz; + var iw; + var iu; + var i0; + var i1; + + // Note on variable naming convention: S#, dx#, dy#, dz#, dw#, du#, 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; + sy = y.strides; + sz = z.strides; + sw = w.strides; + su = u.strides; + if ( isRowMajor ) { + // 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 + dy0 = sy[ 1 ]; + dy1 = sy[ 0 ] - ( S0*sy[1] ); + dz0 = sz[ 1 ]; + dz1 = sz[ 0 ] - ( S0*sz[1] ); + dw0 = sw[ 1 ]; + dw1 = sw[ 0 ] - ( S0*sw[1] ); + du0 = su[ 1 ]; + du1 = su[ 0 ] - ( S0*su[1] ); + } 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 + dy0 = sy[ 0 ]; + dy1 = sy[ 1 ] - ( S0*sy[0] ); + dz0 = sz[ 0 ]; + dz1 = sz[ 1 ] - ( S0*sz[0] ); + dw0 = sw[ 0 ]; + dw1 = sw[ 1 ] - ( S0*sw[0] ); + du0 = su[ 0 ]; + du1 = su[ 1 ] - ( S0*su[0] ); + } + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + iy = y.offset; + iz = z.offset; + iw = w.offset; + iu = u.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + ybuf = y.data; + zbuf = z.data; + wbuf = w.data; + ubuf = u.data; + + // Iterate over the ndarray dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + ubuf[ iu ] = fcn( xbuf[ ix ], ybuf[ iy ], zbuf[ iz ], wbuf[ iw ] ); + ix += dx0; + iy += dy0; + iz += dz0; + iw += dw0; + iu += du0; + } + ix += dx1; + iy += dy1; + iz += dz1; + iw += dw1; + iu += du1; + } +} + + +// EXPORTS // + +module.exports = quaternary2d; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/3d.js new file mode 100644 index 000000000000..814dc598af0d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/3d.js @@ -0,0 +1,278 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-statements */ + +'use strict'; + +// MAIN // + +/** +* Applies a quaternary callback to elements in three-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {*} 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 {Object} y - object containing input ndarray meta data +* @param {*} y.dtype - data type +* @param {Collection} y.data - data buffer +* @param {NonNegativeIntegerArray} y.shape - dimensions +* @param {IntegerArray} y.strides - stride lengths +* @param {NonNegativeInteger} y.offset - index offset +* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} z - object containing input ndarray meta data +* @param {*} z.dtype - data type +* @param {Collection} z.data - data buffer +* @param {NonNegativeIntegerArray} z.shape - dimensions +* @param {IntegerArray} z.strides - stride lengths +* @param {NonNegativeInteger} z.offset - index offset +* @param {string} z.order - specifies whether `z` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} w - object containing input ndarray meta data +* @param {*} w.dtype - data type +* @param {Collection} w.data - data buffer +* @param {NonNegativeIntegerArray} w.shape - dimensions +* @param {IntegerArray} w.strides - stride lengths +* @param {NonNegativeInteger} w.offset - index offset +* @param {string} w.order - specifies whether `w` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} u - object containing output ndarray meta data +* @param {*} u.dtype - data type +* @param {Collection} u.data - data buffer +* @param {NonNegativeIntegerArray} u.shape - dimensions +* @param {IntegerArray} u.strides - stride lengths +* @param {NonNegativeInteger} u.offset - index offset +* @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order +* @param {Callback} fcn - quaternary callback +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function fcn( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // 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 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( 12 ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 3, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 4, 2, 1 ]; +* var sy = [ 4, 2, 1 ]; +* var sz = [ 4, 2, 1 ]; +* var sw = [ 4, 2, 1 ]; +* var su = [ 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* var ow = 0; +* var ou = 0; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': ow, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': ou, +* 'order': 'row-major' +* }; +* +* // Apply the quaternary function: +* quaternary3d( x, y, z, w, u, true, fcn ); +* +* console.log( u.data ); +* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0 ] +*/ +function quaternary3d( x, y, z, w, u, isRowMajor, fcn ) { + var xbuf; + var ybuf; + var zbuf; + var wbuf; + var ubuf; + var dx0; + var dx1; + var dx2; + var dy0; + var dy1; + var dy2; + var dz0; + var dz1; + var dz2; + var dw0; + var dw1; + var dw2; + var du0; + var du1; + var du2; + var sh; + var S0; + var S1; + var S2; + var sx; + var sy; + var sz; + var sw; + var su; + var ix; + var iy; + var iz; + var iw; + var iu; + var i0; + var i1; + var i2; + + // Note on variable naming convention: S#, dx#, dy#, dz#, dw#, du#, 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; + sy = y.strides; + sz = z.strides; + sw = w.strides; + su = u.strides; + if ( isRowMajor ) { + // 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 + dy0 = sy[ 2 ]; + dy1 = sy[ 1 ] - ( S0*sy[2] ); + dy2 = sy[ 0 ] - ( S1*sy[1] ); + dz0 = sz[ 2 ]; + dz1 = sz[ 1 ] - ( S0*sz[2] ); + dz2 = sz[ 0 ] - ( S1*sz[1] ); + dw0 = sw[ 2 ]; + dw1 = sw[ 1 ] - ( S0*sw[2] ); + dw2 = sw[ 0 ] - ( S1*sw[1] ); + du0 = su[ 2 ]; + du1 = su[ 1 ] - ( S0*su[2] ); + du2 = su[ 0 ] - ( S1*su[1] ); + } 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 + dy0 = sy[ 0 ]; + dy1 = sy[ 1 ] - ( S0*sy[0] ); + dy2 = sy[ 2 ] - ( S1*sy[1] ); + dz0 = sz[ 0 ]; + dz1 = sz[ 1 ] - ( S0*sz[0] ); + dz2 = sz[ 2 ] - ( S1*sz[1] ); + dw0 = sw[ 0 ]; + dw1 = sw[ 1 ] - ( S0*sw[0] ); + dw2 = sw[ 2 ] - ( S1*sw[1] ); + du0 = su[ 0 ]; + du1 = su[ 1 ] - ( S0*su[0] ); + du2 = su[ 2 ] - ( S1*su[1] ); + } + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + iy = y.offset; + iz = z.offset; + iw = w.offset; + iu = u.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + ybuf = y.data; + zbuf = z.data; + wbuf = w.data; + ubuf = u.data; + + // Iterate over the ndarray dimensions... + for ( i2 = 0; i2 < S2; i2++ ) { + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + ubuf[ iu ] = fcn( xbuf[ ix ], ybuf[ iy ], zbuf[ iz ], wbuf[ iw ] ); // eslint-disable-line max-len + ix += dx0; + iy += dy0; + iz += dz0; + iw += dw0; + iu += du0; + } + ix += dx1; + iy += dy1; + iz += dz1; + iw += dw1; + iu += du1; + } + ix += dx2; + iy += dy2; + iz += dz2; + iw += dw2; + iu += du2; + } +} + + +// EXPORTS // + +module.exports = quaternary3d; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/4d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/4d.js new file mode 100644 index 000000000000..d9a523067ef0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/4d.js @@ -0,0 +1,304 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-statements */ + +'use strict'; + +// MAIN // + +/** +* Applies a quaternary callback to elements in four-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {*} 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 {Object} y - object containing input ndarray meta data +* @param {*} y.dtype - data type +* @param {Collection} y.data - data buffer +* @param {NonNegativeIntegerArray} y.shape - dimensions +* @param {IntegerArray} y.strides - stride lengths +* @param {NonNegativeInteger} y.offset - index offset +* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} z - object containing input ndarray meta data +* @param {*} z.dtype - data type +* @param {Collection} z.data - data buffer +* @param {NonNegativeIntegerArray} z.shape - dimensions +* @param {IntegerArray} z.strides - stride lengths +* @param {NonNegativeInteger} z.offset - index offset +* @param {string} z.order - specifies whether `z` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} w - object containing input ndarray meta data +* @param {*} w.dtype - data type +* @param {Collection} w.data - data buffer +* @param {NonNegativeIntegerArray} w.shape - dimensions +* @param {IntegerArray} w.strides - stride lengths +* @param {NonNegativeInteger} w.offset - index offset +* @param {string} w.order - specifies whether `w` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} u - object containing output ndarray meta data +* @param {*} u.dtype - data type +* @param {Collection} u.data - data buffer +* @param {NonNegativeIntegerArray} u.shape - dimensions +* @param {IntegerArray} u.strides - stride lengths +* @param {NonNegativeInteger} u.offset - index offset +* @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order +* @param {Callback} fcn - quaternary callback +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function fcn( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // 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 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( 12 ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 1, 3, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 12, 4, 2, 1 ]; +* var sy = [ 12, 4, 2, 1 ]; +* var sz = [ 12, 4, 2, 1 ]; +* var sw = [ 12, 4, 2, 1 ]; +* var su = [ 12, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* var ow = 0; +* var ou = 0; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': ow, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': ou, +* 'order': 'row-major' +* }; +* +* // Apply the quaternary function: +* quaternary4d( x, y, z, w, u, true, fcn ); +* +* console.log( u.data ); +* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0 ] +*/ +function quaternary4d( x, y, z, w, u, isRowMajor, fcn ) { + var xbuf; + var ybuf; + var zbuf; + var wbuf; + var ubuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dy0; + var dy1; + var dy2; + var dy3; + var dz0; + var dz1; + var dz2; + var dz3; + var dw0; + var dw1; + var dw2; + var dw3; + var du0; + var du1; + var du2; + var du3; + var sh; + var S0; + var S1; + var S2; + var S3; + var sx; + var sy; + var sz; + var sw; + var su; + var ix; + var iy; + var iz; + var iw; + var iu; + var i0; + var i1; + var i2; + var i3; + + // Note on variable naming convention: S#, dx#, dy#, dz#, dw#, du#, 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; + sy = y.strides; + sz = z.strides; + sw = w.strides; + su = u.strides; + if ( isRowMajor ) { + // 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 + dy0 = sy[ 3 ]; + dy1 = sy[ 2 ] - ( S0*sy[3] ); + dy2 = sy[ 1 ] - ( S1*sy[2] ); + dy3 = sy[ 0 ] - ( S2*sy[1] ); + dz0 = sz[ 3 ]; + dz1 = sz[ 2 ] - ( S0*sz[3] ); + dz2 = sz[ 1 ] - ( S1*sz[2] ); + dz3 = sz[ 0 ] - ( S2*sz[1] ); + dw0 = sw[ 3 ]; + dw1 = sw[ 2 ] - ( S0*sw[3] ); + dw2 = sw[ 1 ] - ( S1*sw[2] ); + dw3 = sw[ 0 ] - ( S2*sw[1] ); + du0 = su[ 3 ]; + du1 = su[ 2 ] - ( S0*su[3] ); + du2 = su[ 1 ] - ( S1*su[2] ); + du3 = su[ 0 ] - ( S2*su[1] ); + } 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 + dy0 = sy[ 0 ]; + dy1 = sy[ 1 ] - ( S0*sy[0] ); + dy2 = sy[ 2 ] - ( S1*sy[1] ); + dy3 = sy[ 3 ] - ( S2*sy[2] ); + dz0 = sz[ 0 ]; + dz1 = sz[ 1 ] - ( S0*sz[0] ); + dz2 = sz[ 2 ] - ( S1*sz[1] ); + dz3 = sz[ 3 ] - ( S2*sz[2] ); + dw0 = sw[ 0 ]; + dw1 = sw[ 1 ] - ( S0*sw[0] ); + dw2 = sw[ 2 ] - ( S1*sw[1] ); + dw3 = sw[ 3 ] - ( S2*sw[2] ); + du0 = su[ 0 ]; + du1 = su[ 1 ] - ( S0*su[0] ); + du2 = su[ 2 ] - ( S1*su[1] ); + du3 = su[ 3 ] - ( S2*su[2] ); + } + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + iy = y.offset; + iz = z.offset; + iw = w.offset; + iu = u.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + ybuf = y.data; + zbuf = z.data; + wbuf = w.data; + ubuf = u.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++ ) { + ubuf[ iu ] = fcn( xbuf[ ix ], ybuf[ iy ], zbuf[ iz ], wbuf[ iw ] ); // eslint-disable-line max-len + ix += dx0; + iy += dy0; + iz += dz0; + iw += dw0; + iu += du0; + } + ix += dx1; + iy += dy1; + iz += dz1; + iw += dw1; + iu += du1; + } + ix += dx2; + iy += dy2; + iz += dz2; + iw += dw2; + iu += du2; + } + ix += dx3; + iy += dy3; + iz += dz3; + iw += dw3; + iu += du3; + } +} + + +// EXPORTS // + +module.exports = quaternary4d; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/5d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/5d.js new file mode 100644 index 000000000000..983cf598aeb5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/5d.js @@ -0,0 +1,330 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-statements */ + +'use strict'; + +// MAIN // + +/** +* Applies a quaternary callback to elements in five-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {*} 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 {Object} y - object containing input ndarray meta data +* @param {*} y.dtype - data type +* @param {Collection} y.data - data buffer +* @param {NonNegativeIntegerArray} y.shape - dimensions +* @param {IntegerArray} y.strides - stride lengths +* @param {NonNegativeInteger} y.offset - index offset +* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} z - object containing input ndarray meta data +* @param {*} z.dtype - data type +* @param {Collection} z.data - data buffer +* @param {NonNegativeIntegerArray} z.shape - dimensions +* @param {IntegerArray} z.strides - stride lengths +* @param {NonNegativeInteger} z.offset - index offset +* @param {string} z.order - specifies whether `z` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} w - object containing input ndarray meta data +* @param {*} w.dtype - data type +* @param {Collection} w.data - data buffer +* @param {NonNegativeIntegerArray} w.shape - dimensions +* @param {IntegerArray} w.strides - stride lengths +* @param {NonNegativeInteger} w.offset - index offset +* @param {string} w.order - specifies whether `w` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} u - object containing output ndarray meta data +* @param {*} u.dtype - data type +* @param {Collection} u.data - data buffer +* @param {NonNegativeIntegerArray} u.shape - dimensions +* @param {IntegerArray} u.strides - stride lengths +* @param {NonNegativeInteger} u.offset - index offset +* @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order +* @param {Callback} fcn - quaternary callback +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function fcn( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( 8 ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 1, 1, 2, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 4, 2, 1 ]; +* var sy = [ 8, 8, 4, 2, 1 ]; +* var sz = [ 8, 8, 4, 2, 1 ]; +* var sw = [ 8, 8, 4, 2, 1 ]; +* var su = [ 8, 8, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* var ow = 0; +* var ou = 0; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': ow, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': ou, +* 'order': 'row-major' +* }; +* +* // Apply the quaternary function: +* quaternary5d( x, y, z, w, u, true, fcn ); +* +* console.log( u.data ); +* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +*/ +function quaternary5d( x, y, z, w, u, isRowMajor, fcn ) { + var xbuf; + var ybuf; + var zbuf; + var wbuf; + var ubuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dy0; + var dy1; + var dy2; + var dy3; + var dy4; + var dz0; + var dz1; + var dz2; + var dz3; + var dz4; + var dw0; + var dw1; + var dw2; + var dw3; + var dw4; + var du0; + var du1; + var du2; + var du3; + var du4; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var sx; + var sy; + var sz; + var sw; + var su; + var ix; + var iy; + var iz; + var iw; + var iu; + var i0; + var i1; + var i2; + var i3; + var i4; + + // Note on variable naming convention: S#, dx#, dy#, dz#, dw#, du#, 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; + sy = y.strides; + sz = z.strides; + sw = w.strides; + su = u.strides; + if ( isRowMajor ) { + // 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 + dy0 = sy[ 4 ]; + dy1 = sy[ 3 ] - ( S0*sy[4] ); + dy2 = sy[ 2 ] - ( S1*sy[3] ); + dy3 = sy[ 1 ] - ( S2*sy[2] ); + dy4 = sy[ 0 ] - ( S3*sy[1] ); + dz0 = sz[ 4 ]; + dz1 = sz[ 3 ] - ( S0*sz[4] ); + dz2 = sz[ 2 ] - ( S1*sz[3] ); + dz3 = sz[ 1 ] - ( S2*sz[2] ); + dz4 = sz[ 0 ] - ( S3*sz[1] ); + dw0 = sw[ 4 ]; + dw1 = sw[ 3 ] - ( S0*sw[4] ); + dw2 = sw[ 2 ] - ( S1*sw[3] ); + dw3 = sw[ 1 ] - ( S2*sw[2] ); + dw4 = sw[ 0 ] - ( S3*sw[1] ); + du0 = su[ 4 ]; + du1 = su[ 3 ] - ( S0*su[4] ); + du2 = su[ 2 ] - ( S1*su[3] ); + du3 = su[ 1 ] - ( S2*su[2] ); + du4 = su[ 0 ] - ( S3*su[1] ); + } 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 + dy0 = sy[ 0 ]; + dy1 = sy[ 1 ] - ( S0*sy[0] ); + dy2 = sy[ 2 ] - ( S1*sy[1] ); + dy3 = sy[ 3 ] - ( S2*sy[2] ); + dy4 = sy[ 4 ] - ( S3*sy[3] ); + dz0 = sz[ 0 ]; + dz1 = sz[ 1 ] - ( S0*sz[0] ); + dz2 = sz[ 2 ] - ( S1*sz[1] ); + dz3 = sz[ 3 ] - ( S2*sz[2] ); + dz4 = sz[ 4 ] - ( S3*sz[3] ); + dw0 = sw[ 0 ]; + dw1 = sw[ 1 ] - ( S0*sw[0] ); + dw2 = sw[ 2 ] - ( S1*sw[1] ); + dw3 = sw[ 3 ] - ( S2*sw[2] ); + dw4 = sw[ 4 ] - ( S3*sw[3] ); + du0 = su[ 0 ]; + du1 = su[ 1 ] - ( S0*su[0] ); + du2 = su[ 2 ] - ( S1*su[1] ); + du3 = su[ 3 ] - ( S2*su[2] ); + du4 = su[ 4 ] - ( S3*su[3] ); + } + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + iy = y.offset; + iz = z.offset; + iw = w.offset; + iu = u.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + ybuf = y.data; + zbuf = z.data; + wbuf = w.data; + ubuf = u.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++ ) { + ubuf[ iu ] = fcn( xbuf[ ix ], ybuf[ iy ], zbuf[ iz ], wbuf[ iw ] ); // eslint-disable-line max-len + ix += dx0; + iy += dy0; + iz += dz0; + iw += dw0; + iu += du0; + } + ix += dx1; + iy += dy1; + iz += dz1; + iw += dw1; + iu += du1; + } + ix += dx2; + iy += dy2; + iz += dz2; + iw += dw2; + iu += du2; + } + ix += dx3; + iy += dy3; + iz += dz3; + iw += dw3; + iu += du3; + } + ix += dx4; + iy += dy4; + iz += dz4; + iw += dw4; + iu += du4; + } +} + + +// EXPORTS // + +module.exports = quaternary5d; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/6d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/6d.js new file mode 100644 index 000000000000..dcbb9b28b539 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/6d.js @@ -0,0 +1,356 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-statements, max-depth */ + +'use strict'; + +// MAIN // + +/** +* Applies a quaternary callback to elements in six-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {*} 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 {Object} y - object containing input ndarray meta data +* @param {*} y.dtype - data type +* @param {Collection} y.data - data buffer +* @param {NonNegativeIntegerArray} y.shape - dimensions +* @param {IntegerArray} y.strides - stride lengths +* @param {NonNegativeInteger} y.offset - index offset +* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} z - object containing input ndarray meta data +* @param {*} z.dtype - data type +* @param {Collection} z.data - data buffer +* @param {NonNegativeIntegerArray} z.shape - dimensions +* @param {IntegerArray} z.strides - stride lengths +* @param {NonNegativeInteger} z.offset - index offset +* @param {string} z.order - specifies whether `z` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} w - object containing input ndarray meta data +* @param {*} w.dtype - data type +* @param {Collection} w.data - data buffer +* @param {NonNegativeIntegerArray} w.shape - dimensions +* @param {IntegerArray} w.strides - stride lengths +* @param {NonNegativeInteger} w.offset - index offset +* @param {string} w.order - specifies whether `w` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} u - object containing output ndarray meta data +* @param {*} u.dtype - data type +* @param {Collection} u.data - data buffer +* @param {NonNegativeIntegerArray} u.shape - dimensions +* @param {IntegerArray} u.strides - stride lengths +* @param {NonNegativeInteger} u.offset - index offset +* @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order +* @param {Callback} fcn - quaternary callback +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function fcn( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( 8 ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 1, 1, 1, 2, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 4, 2, 1 ]; +* var sy = [ 8, 8, 8, 4, 2, 1 ]; +* var sz = [ 8, 8, 8, 4, 2, 1 ]; +* var sw = [ 8, 8, 8, 4, 2, 1 ]; +* var su = [ 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* var ow = 0; +* var ou = 0; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': ow, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': ou, +* 'order': 'row-major' +* }; +* +* // Apply the quaternary function: +* quaternary6d( x, y, z, w, u, true, fcn ); +* +* console.log( u.data ); +* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +*/ +function quaternary6d( x, y, z, w, u, isRowMajor, fcn ) { + var xbuf; + var ybuf; + var zbuf; + var wbuf; + var ubuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dy0; + var dy1; + var dy2; + var dy3; + var dy4; + var dy5; + var dz0; + var dz1; + var dz2; + var dz3; + var dz4; + var dz5; + var dw0; + var dw1; + var dw2; + var dw3; + var dw4; + var dw5; + var du0; + var du1; + var du2; + var du3; + var du4; + var du5; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var sx; + var sy; + var sz; + var sw; + var su; + var ix; + var iy; + var iz; + var iw; + var iu; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + + // Note on variable naming convention: S#, dx#, dy#, dz#, dw#, du#, 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; + sy = y.strides; + sz = z.strides; + sw = w.strides; + su = u.strides; + if ( isRowMajor ) { + // 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 + dy0 = sy[ 5 ]; + dy1 = sy[ 4 ] - ( S0*sy[5] ); + dy2 = sy[ 3 ] - ( S1*sy[4] ); + dy3 = sy[ 2 ] - ( S2*sy[3] ); + dy4 = sy[ 1 ] - ( S3*sy[2] ); + dy5 = sy[ 0 ] - ( S4*sy[1] ); + dz0 = sz[ 5 ]; + dz1 = sz[ 4 ] - ( S0*sz[5] ); + dz2 = sz[ 3 ] - ( S1*sz[4] ); + dz3 = sz[ 2 ] - ( S2*sz[3] ); + dz4 = sz[ 1 ] - ( S3*sz[2] ); + dz5 = sz[ 0 ] - ( S4*sz[1] ); + dw0 = sw[ 5 ]; + dw1 = sw[ 4 ] - ( S0*sw[5] ); + dw2 = sw[ 3 ] - ( S1*sw[4] ); + dw3 = sw[ 2 ] - ( S2*sw[3] ); + dw4 = sw[ 1 ] - ( S3*sw[2] ); + dw5 = sw[ 0 ] - ( S4*sw[1] ); + du0 = su[ 5 ]; + du1 = su[ 4 ] - ( S0*su[5] ); + du2 = su[ 3 ] - ( S1*su[4] ); + du3 = su[ 2 ] - ( S2*su[3] ); + du4 = su[ 1 ] - ( S3*su[2] ); + du5 = su[ 0 ] - ( S4*su[1] ); + } 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 + dy0 = sy[ 0 ]; + dy1 = sy[ 1 ] - ( S0*sy[0] ); + dy2 = sy[ 2 ] - ( S1*sy[1] ); + dy3 = sy[ 3 ] - ( S2*sy[2] ); + dy4 = sy[ 4 ] - ( S3*sy[3] ); + dy5 = sy[ 5 ] - ( S4*sy[4] ); + dz0 = sz[ 0 ]; + dz1 = sz[ 1 ] - ( S0*sz[0] ); + dz2 = sz[ 2 ] - ( S1*sz[1] ); + dz3 = sz[ 3 ] - ( S2*sz[2] ); + dz4 = sz[ 4 ] - ( S3*sz[3] ); + dz5 = sz[ 5 ] - ( S4*sz[4] ); + dw0 = sw[ 0 ]; + dw1 = sw[ 1 ] - ( S0*sw[0] ); + dw2 = sw[ 2 ] - ( S1*sw[1] ); + dw3 = sw[ 3 ] - ( S2*sw[2] ); + dw4 = sw[ 4 ] - ( S3*sw[3] ); + dw5 = sw[ 5 ] - ( S4*sw[4] ); + du0 = su[ 0 ]; + du1 = su[ 1 ] - ( S0*su[0] ); + du2 = su[ 2 ] - ( S1*su[1] ); + du3 = su[ 3 ] - ( S2*su[2] ); + du4 = su[ 4 ] - ( S3*su[3] ); + du5 = su[ 5 ] - ( S4*su[4] ); + } + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + iy = y.offset; + iz = z.offset; + iw = w.offset; + iu = u.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + ybuf = y.data; + zbuf = z.data; + wbuf = w.data; + ubuf = u.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++ ) { + ubuf[ iu ] = fcn( xbuf[ ix ], ybuf[ iy ], zbuf[ iz ], wbuf[ iw ] ); // eslint-disable-line max-len + ix += dx0; + iy += dy0; + iz += dz0; + iw += dw0; + iu += du0; + } + ix += dx1; + iy += dy1; + iz += dz1; + iw += dw1; + iu += du1; + } + ix += dx2; + iy += dy2; + iz += dz2; + iw += dw2; + iu += du2; + } + ix += dx3; + iy += dy3; + iz += dz3; + iw += dw3; + iu += du3; + } + ix += dx4; + iy += dy4; + iz += dz4; + iw += dw4; + iu += du4; + } + ix += dx5; + iy += dy5; + iz += dz5; + iw += dw5; + iu += du5; + } +} + + +// EXPORTS // + +module.exports = quaternary6d; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/7d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/7d.js new file mode 100644 index 000000000000..9909f377e8a0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/7d.js @@ -0,0 +1,382 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-statements, max-depth, max-lines-per-function */ + +'use strict'; + +// MAIN // + +/** +* Applies a quaternary callback to elements in seven-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {*} 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 {Object} y - object containing input ndarray meta data +* @param {*} y.dtype - data type +* @param {Collection} y.data - data buffer +* @param {NonNegativeIntegerArray} y.shape - dimensions +* @param {IntegerArray} y.strides - stride lengths +* @param {NonNegativeInteger} y.offset - index offset +* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} z - object containing input ndarray meta data +* @param {*} z.dtype - data type +* @param {Collection} z.data - data buffer +* @param {NonNegativeIntegerArray} z.shape - dimensions +* @param {IntegerArray} z.strides - stride lengths +* @param {NonNegativeInteger} z.offset - index offset +* @param {string} z.order - specifies whether `z` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} w - object containing input ndarray meta data +* @param {*} w.dtype - data type +* @param {Collection} w.data - data buffer +* @param {NonNegativeIntegerArray} w.shape - dimensions +* @param {IntegerArray} w.strides - stride lengths +* @param {NonNegativeInteger} w.offset - index offset +* @param {string} w.order - specifies whether `w` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} u - object containing output ndarray meta data +* @param {*} u.dtype - data type +* @param {Collection} u.data - data buffer +* @param {NonNegativeIntegerArray} u.shape - dimensions +* @param {IntegerArray} u.strides - stride lengths +* @param {NonNegativeInteger} u.offset - index offset +* @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order +* @param {Callback} fcn - quaternary callback +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function fcn( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( 8 ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 1, 1, 1, 1, 2, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 4, 2, 1 ]; +* var sy = [ 8, 8, 8, 8, 4, 2, 1 ]; +* var sz = [ 8, 8, 8, 8, 4, 2, 1 ]; +* var sw = [ 8, 8, 8, 8, 4, 2, 1 ]; +* var su = [ 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* var ow = 0; +* var ou = 0; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': ow, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': ou, +* 'order': 'row-major' +* }; +* +* // Apply the quaternary function: +* quaternary7d( x, y, z, w, u, true, fcn ); +* +* console.log( u.data ); +* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +*/ +function quaternary7d( x, y, z, w, u, isRowMajor, fcn ) { + var xbuf; + var ybuf; + var zbuf; + var wbuf; + var ubuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dy0; + var dy1; + var dy2; + var dy3; + var dy4; + var dy5; + var dy6; + var dz0; + var dz1; + var dz2; + var dz3; + var dz4; + var dz5; + var dz6; + var dw0; + var dw1; + var dw2; + var dw3; + var dw4; + var dw5; + var dw6; + var du0; + var du1; + var du2; + var du3; + var du4; + var du5; + var du6; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var sx; + var sy; + var sz; + var sw; + var su; + var ix; + var iy; + var iz; + var iw; + var iu; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + + // Note on variable naming convention: S#, dx#, dy#, dz#, dw#, du#, 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; + sy = y.strides; + sz = z.strides; + sw = w.strides; + su = u.strides; + if ( isRowMajor ) { + // 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 + dy0 = sy[ 6 ]; + dy1 = sy[ 5 ] - ( S0*sy[6] ); + dy2 = sy[ 4 ] - ( S1*sy[5] ); + dy3 = sy[ 3 ] - ( S2*sy[4] ); + dy4 = sy[ 2 ] - ( S3*sy[3] ); + dy5 = sy[ 1 ] - ( S4*sy[2] ); + dy6 = sy[ 0 ] - ( S5*sy[1] ); + dz0 = sz[ 6 ]; + dz1 = sz[ 5 ] - ( S0*sz[6] ); + dz2 = sz[ 4 ] - ( S1*sz[5] ); + dz3 = sz[ 3 ] - ( S2*sz[4] ); + dz4 = sz[ 2 ] - ( S3*sz[3] ); + dz5 = sz[ 1 ] - ( S4*sz[2] ); + dz6 = sz[ 0 ] - ( S5*sz[1] ); + dw0 = sw[ 6 ]; + dw1 = sw[ 5 ] - ( S0*sw[6] ); + dw2 = sw[ 4 ] - ( S1*sw[5] ); + dw3 = sw[ 3 ] - ( S2*sw[4] ); + dw4 = sw[ 2 ] - ( S3*sw[3] ); + dw5 = sw[ 1 ] - ( S4*sw[2] ); + dw6 = sw[ 0 ] - ( S5*sw[1] ); + du0 = su[ 6 ]; + du1 = su[ 5 ] - ( S0*su[6] ); + du2 = su[ 4 ] - ( S1*su[5] ); + du3 = su[ 3 ] - ( S2*su[4] ); + du4 = su[ 2 ] - ( S3*su[3] ); + du5 = su[ 1 ] - ( S4*su[2] ); + du6 = su[ 0 ] - ( S5*su[1] ); + } 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 + dy0 = sy[ 0 ]; + dy1 = sy[ 1 ] - ( S0*sy[0] ); + dy2 = sy[ 2 ] - ( S1*sy[1] ); + dy3 = sy[ 3 ] - ( S2*sy[2] ); + dy4 = sy[ 4 ] - ( S3*sy[3] ); + dy5 = sy[ 5 ] - ( S4*sy[4] ); + dy6 = sy[ 6 ] - ( S5*sy[5] ); + dz0 = sz[ 0 ]; + dz1 = sz[ 1 ] - ( S0*sz[0] ); + dz2 = sz[ 2 ] - ( S1*sz[1] ); + dz3 = sz[ 3 ] - ( S2*sz[2] ); + dz4 = sz[ 4 ] - ( S3*sz[3] ); + dz5 = sz[ 5 ] - ( S4*sz[4] ); + dz6 = sz[ 6 ] - ( S5*sz[5] ); + dw0 = sw[ 0 ]; + dw1 = sw[ 1 ] - ( S0*sw[0] ); + dw2 = sw[ 2 ] - ( S1*sw[1] ); + dw3 = sw[ 3 ] - ( S2*sw[2] ); + dw4 = sw[ 4 ] - ( S3*sw[3] ); + dw5 = sw[ 5 ] - ( S4*sw[4] ); + dw6 = sw[ 6 ] - ( S5*sw[5] ); + du0 = su[ 0 ]; + du1 = su[ 1 ] - ( S0*su[0] ); + du2 = su[ 2 ] - ( S1*su[1] ); + du3 = su[ 3 ] - ( S2*su[2] ); + du4 = su[ 4 ] - ( S3*su[3] ); + du5 = su[ 5 ] - ( S4*su[4] ); + du6 = su[ 6 ] - ( S5*su[5] ); + } + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + iy = y.offset; + iz = z.offset; + iw = w.offset; + iu = u.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + ybuf = y.data; + zbuf = z.data; + wbuf = w.data; + ubuf = u.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++ ) { + ubuf[ iu ] = fcn( xbuf[ ix ], ybuf[ iy ], zbuf[ iz ], wbuf[ iw ] ); // eslint-disable-line max-len + ix += dx0; + iy += dy0; + iz += dz0; + iw += dw0; + iu += du0; + } + ix += dx1; + iy += dy1; + iz += dz1; + iw += dw1; + iu += du1; + } + ix += dx2; + iy += dy2; + iz += dz2; + iw += dw2; + iu += du2; + } + ix += dx3; + iy += dy3; + iz += dz3; + iw += dw3; + iu += du3; + } + ix += dx4; + iy += dy4; + iz += dz4; + iw += dw4; + iu += du4; + } + ix += dx5; + iy += dy5; + iz += dz5; + iw += dw5; + iu += du5; + } + ix += dx6; + iy += dy6; + iz += dz6; + iw += dw6; + iu += du6; + } +} + + +// EXPORTS // + +module.exports = quaternary7d; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/8d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/8d.js new file mode 100644 index 000000000000..4c0fdf662bee --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/8d.js @@ -0,0 +1,408 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-statements, max-depth, max-lines-per-function, max-len */ + +'use strict'; + +// MAIN // + +/** +* Applies a quaternary callback to elements in eight-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {*} 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 {Object} y - object containing input ndarray meta data +* @param {*} y.dtype - data type +* @param {Collection} y.data - data buffer +* @param {NonNegativeIntegerArray} y.shape - dimensions +* @param {IntegerArray} y.strides - stride lengths +* @param {NonNegativeInteger} y.offset - index offset +* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} z - object containing input ndarray meta data +* @param {*} z.dtype - data type +* @param {Collection} z.data - data buffer +* @param {NonNegativeIntegerArray} z.shape - dimensions +* @param {IntegerArray} z.strides - stride lengths +* @param {NonNegativeInteger} z.offset - index offset +* @param {string} z.order - specifies whether `z` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} w - object containing input ndarray meta data +* @param {*} w.dtype - data type +* @param {Collection} w.data - data buffer +* @param {NonNegativeIntegerArray} w.shape - dimensions +* @param {IntegerArray} w.strides - stride lengths +* @param {NonNegativeInteger} w.offset - index offset +* @param {string} w.order - specifies whether `w` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} u - object containing output ndarray meta data +* @param {*} u.dtype - data type +* @param {Collection} u.data - data buffer +* @param {NonNegativeIntegerArray} u.shape - dimensions +* @param {IntegerArray} u.strides - stride lengths +* @param {NonNegativeInteger} u.offset - index offset +* @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order +* @param {Callback} fcn - quaternary callback +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function fcn( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( 8 ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 1, 1, 1, 1, 1, 2, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var sy = [ 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var sz = [ 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var sw = [ 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var su = [ 8, 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* var ow = 0; +* var ou = 0; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': ow, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': ou, +* 'order': 'row-major' +* }; +* +* // Apply the quaternary function: +* quaternary8d( x, y, z, w, u, true, fcn ); +* +* console.log( u.data ); +* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +*/ +function quaternary8d( x, y, z, w, u, isRowMajor, fcn ) { + var xbuf; + var ybuf; + var zbuf; + var wbuf; + var ubuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dy0; + var dy1; + var dy2; + var dy3; + var dy4; + var dy5; + var dy6; + var dy7; + var dz0; + var dz1; + var dz2; + var dz3; + var dz4; + var dz5; + var dz6; + var dz7; + var dw0; + var dw1; + var dw2; + var dw3; + var dw4; + var dw5; + var dw6; + var dw7; + var du0; + var du1; + var du2; + var du3; + var du4; + var du5; + var du6; + var du7; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var sx; + var sy; + var sz; + var sw; + var su; + var ix; + var iy; + var iz; + var iw; + var iu; + var i0; + var i1; + var i2; + var i3; + var i4; + var i5; + var i6; + var i7; + + // Note on variable naming convention: S#, dx#, dy#, dz#, dw#, du#, 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; + sy = y.strides; + sz = z.strides; + sw = w.strides; + su = u.strides; + if ( isRowMajor ) { + // 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 + dy0 = sy[ 7 ]; + dy1 = sy[ 6 ] - ( S0*sy[7] ); + dy2 = sy[ 5 ] - ( S1*sy[6] ); + dy3 = sy[ 4 ] - ( S2*sy[5] ); + dy4 = sy[ 3 ] - ( S3*sy[4] ); + dy5 = sy[ 2 ] - ( S4*sy[3] ); + dy6 = sy[ 1 ] - ( S5*sy[2] ); + dy7 = sy[ 0 ] - ( S6*sy[1] ); + dz0 = sz[ 7 ]; + dz1 = sz[ 6 ] - ( S0*sz[7] ); + dz2 = sz[ 5 ] - ( S1*sz[6] ); + dz3 = sz[ 4 ] - ( S2*sz[5] ); + dz4 = sz[ 3 ] - ( S3*sz[4] ); + dz5 = sz[ 2 ] - ( S4*sz[3] ); + dz6 = sz[ 1 ] - ( S5*sz[2] ); + dz7 = sz[ 0 ] - ( S6*sz[1] ); + dw0 = sw[ 7 ]; + dw1 = sw[ 6 ] - ( S0*sw[7] ); + dw2 = sw[ 5 ] - ( S1*sw[6] ); + dw3 = sw[ 4 ] - ( S2*sw[5] ); + dw4 = sw[ 3 ] - ( S3*sw[4] ); + dw5 = sw[ 2 ] - ( S4*sw[3] ); + dw6 = sw[ 1 ] - ( S5*sw[2] ); + dw7 = sw[ 0 ] - ( S6*sw[1] ); + du0 = su[ 7 ]; + du1 = su[ 6 ] - ( S0*su[7] ); + du2 = su[ 5 ] - ( S1*su[6] ); + du3 = su[ 4 ] - ( S2*su[5] ); + du4 = su[ 3 ] - ( S3*su[4] ); + du5 = su[ 2 ] - ( S4*su[3] ); + du6 = su[ 1 ] - ( S5*su[2] ); + du7 = su[ 0 ] - ( S6*su[1] ); + } 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 + dy0 = sy[ 0 ]; + dy1 = sy[ 1 ] - ( S0*sy[0] ); + dy2 = sy[ 2 ] - ( S1*sy[1] ); + dy3 = sy[ 3 ] - ( S2*sy[2] ); + dy4 = sy[ 4 ] - ( S3*sy[3] ); + dy5 = sy[ 5 ] - ( S4*sy[4] ); + dy6 = sy[ 6 ] - ( S5*sy[5] ); + dy7 = sy[ 7 ] - ( S6*sy[6] ); + dz0 = sz[ 0 ]; + dz1 = sz[ 1 ] - ( S0*sz[0] ); + dz2 = sz[ 2 ] - ( S1*sz[1] ); + dz3 = sz[ 3 ] - ( S2*sz[2] ); + dz4 = sz[ 4 ] - ( S3*sz[3] ); + dz5 = sz[ 5 ] - ( S4*sz[4] ); + dz6 = sz[ 6 ] - ( S5*sz[5] ); + dz7 = sz[ 7 ] - ( S6*sz[6] ); + dw0 = sw[ 0 ]; + dw1 = sw[ 1 ] - ( S0*sw[0] ); + dw2 = sw[ 2 ] - ( S1*sw[1] ); + dw3 = sw[ 3 ] - ( S2*sw[2] ); + dw4 = sw[ 4 ] - ( S3*sw[3] ); + dw5 = sw[ 5 ] - ( S4*sw[4] ); + dw6 = sw[ 6 ] - ( S5*sw[5] ); + dw7 = sw[ 7 ] - ( S6*sw[6] ); + du0 = su[ 0 ]; + du1 = su[ 1 ] - ( S0*su[0] ); + du2 = su[ 2 ] - ( S1*su[1] ); + du3 = su[ 3 ] - ( S2*su[2] ); + du4 = su[ 4 ] - ( S3*su[3] ); + du5 = su[ 5 ] - ( S4*su[4] ); + du6 = su[ 6 ] - ( S5*su[5] ); + du7 = su[ 7 ] - ( S6*su[6] ); + } + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + iy = y.offset; + iz = z.offset; + iw = w.offset; + iu = u.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + ybuf = y.data; + zbuf = z.data; + wbuf = w.data; + ubuf = u.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++ ) { + ubuf[ iu ] = fcn( xbuf[ ix ], ybuf[ iy ], zbuf[ iz ], wbuf[ iw ] ); + ix += dx0; + iy += dy0; + iz += dz0; + iw += dw0; + iu += du0; + } + ix += dx1; + iy += dy1; + iz += dz1; + iw += dw1; + iu += du1; + } + ix += dx2; + iy += dy2; + iz += dz2; + iw += dw2; + iu += du2; + } + ix += dx3; + iy += dy3; + iz += dz3; + iw += dw3; + iu += du3; + } + ix += dx4; + iy += dy4; + iz += dz4; + iw += dw4; + iu += du4; + } + ix += dx5; + iy += dy5; + iz += dz5; + iw += dw5; + iu += du5; + } + ix += dx6; + iy += dy6; + iz += dz6; + iw += dw6; + iu += du6; + } + ix += dx7; + iy += dy7; + iz += dz7; + iw += dw7; + iu += du7; + } +} + + +// EXPORTS // + +module.exports = quaternary8d; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/9d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/9d.js new file mode 100644 index 000000000000..61f0b70f4a74 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/9d.js @@ -0,0 +1,434 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-statements, max-depth, max-lines-per-function */ + +'use strict'; + +// MAIN // + +/** +* Applies a quaternary callback to elements in nine-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. +* +* @private +* @param {Object} x - object containing input ndarray meta data +* @param {*} 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 {Object} y - object containing input ndarray meta data +* @param {*} y.dtype - data type +* @param {Collection} y.data - data buffer +* @param {NonNegativeIntegerArray} y.shape - dimensions +* @param {IntegerArray} y.strides - stride lengths +* @param {NonNegativeInteger} y.offset - index offset +* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} z - object containing input ndarray meta data +* @param {*} z.dtype - data type +* @param {Collection} z.data - data buffer +* @param {NonNegativeIntegerArray} z.shape - dimensions +* @param {IntegerArray} z.strides - stride lengths +* @param {NonNegativeInteger} z.offset - index offset +* @param {string} z.order - specifies whether `z` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} w - object containing input ndarray meta data +* @param {*} w.dtype - data type +* @param {Collection} w.data - data buffer +* @param {NonNegativeIntegerArray} w.shape - dimensions +* @param {IntegerArray} w.strides - stride lengths +* @param {NonNegativeInteger} w.offset - index offset +* @param {string} w.order - specifies whether `w` is row-major (C-style) or column-major (Fortran-style) +* @param {Object} u - object containing output ndarray meta data +* @param {*} u.dtype - data type +* @param {Collection} u.data - data buffer +* @param {NonNegativeIntegerArray} u.shape - dimensions +* @param {IntegerArray} u.strides - stride lengths +* @param {NonNegativeInteger} u.offset - index offset +* @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order +* @param {Callback} fcn - quaternary callback +* @returns {void} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function fcn( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( 8 ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 1, 1, 1, 1, 1, 1, 2, 2, 2 ]; +* +* // Define the array strides: +* var sx = [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var sy = [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var sz = [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var sw = [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* var su = [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ]; +* +* // Define the index offsets: +* var ox = 0; +* var oy = 0; +* var oz = 0; +* var ow = 0; +* var ou = 0; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': ox, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': oy, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': oz, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': ow, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': ou, +* 'order': 'row-major' +* }; +* +* // Apply the quaternary function: +* quaternary9d( x, y, z, w, u, true, fcn ); +* +* console.log( u.data ); +* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +*/ +function quaternary9d( x, y, z, w, u, isRowMajor, fcn ) { + var xbuf; + var ybuf; + var zbuf; + var wbuf; + var ubuf; + var dx0; + var dx1; + var dx2; + var dx3; + var dx4; + var dx5; + var dx6; + var dx7; + var dx8; + var dy0; + var dy1; + var dy2; + var dy3; + var dy4; + var dy5; + var dy6; + var dy7; + var dy8; + var dz0; + var dz1; + var dz2; + var dz3; + var dz4; + var dz5; + var dz6; + var dz7; + var dz8; + var dw0; + var dw1; + var dw2; + var dw3; + var dw4; + var dw5; + var dw6; + var dw7; + var dw8; + var du0; + var du1; + var du2; + var du3; + var du4; + var du5; + var du6; + var du7; + var du8; + var sh; + var S0; + var S1; + var S2; + var S3; + var S4; + var S5; + var S6; + var S7; + var S8; + var sx; + var sy; + var sz; + var sw; + var su; + var ix; + var iy; + var iz; + var iw; + var iu; + 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#, dz#, dw#, du#, 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; + sy = y.strides; + sz = z.strides; + sw = w.strides; + su = u.strides; + if ( isRowMajor ) { + // 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 + dy0 = sy[ 8 ]; + dy1 = sy[ 7 ] - ( S0*sy[8] ); + dy2 = sy[ 6 ] - ( S1*sy[7] ); + dy3 = sy[ 5 ] - ( S2*sy[6] ); + dy4 = sy[ 4 ] - ( S3*sy[5] ); + dy5 = sy[ 3 ] - ( S4*sy[4] ); + dy6 = sy[ 2 ] - ( S5*sy[3] ); + dy7 = sy[ 1 ] - ( S6*sy[2] ); + dy8 = sy[ 0 ] - ( S7*sy[1] ); + dz0 = sz[ 8 ]; + dz1 = sz[ 7 ] - ( S0*sz[8] ); + dz2 = sz[ 6 ] - ( S1*sz[7] ); + dz3 = sz[ 5 ] - ( S2*sz[6] ); + dz4 = sz[ 4 ] - ( S3*sz[5] ); + dz5 = sz[ 3 ] - ( S4*sz[4] ); + dz6 = sz[ 2 ] - ( S5*sz[3] ); + dz7 = sz[ 1 ] - ( S6*sz[2] ); + dz8 = sz[ 0 ] - ( S7*sz[1] ); + dw0 = sw[ 8 ]; + dw1 = sw[ 7 ] - ( S0*sw[8] ); + dw2 = sw[ 6 ] - ( S1*sw[7] ); + dw3 = sw[ 5 ] - ( S2*sw[6] ); + dw4 = sw[ 4 ] - ( S3*sw[5] ); + dw5 = sw[ 3 ] - ( S4*sw[4] ); + dw6 = sw[ 2 ] - ( S5*sw[3] ); + dw7 = sw[ 1 ] - ( S6*sw[2] ); + dw8 = sw[ 0 ] - ( S7*sw[1] ); + du0 = su[ 8 ]; + du1 = su[ 7 ] - ( S0*su[8] ); + du2 = su[ 6 ] - ( S1*su[7] ); + du3 = su[ 5 ] - ( S2*su[6] ); + du4 = su[ 4 ] - ( S3*su[5] ); + du5 = su[ 3 ] - ( S4*su[4] ); + du6 = su[ 2 ] - ( S5*su[3] ); + du7 = su[ 1 ] - ( S6*su[2] ); + du8 = su[ 0 ] - ( S7*su[1] ); + } 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 + dy0 = sy[ 0 ]; + dy1 = sy[ 1 ] - ( S0*sy[0] ); + dy2 = sy[ 2 ] - ( S1*sy[1] ); + dy3 = sy[ 3 ] - ( S2*sy[2] ); + dy4 = sy[ 4 ] - ( S3*sy[3] ); + dy5 = sy[ 5 ] - ( S4*sy[4] ); + dy6 = sy[ 6 ] - ( S5*sy[5] ); + dy7 = sy[ 7 ] - ( S6*sy[6] ); + dy8 = sy[ 8 ] - ( S7*sy[7] ); + dz0 = sz[ 0 ]; + dz1 = sz[ 1 ] - ( S0*sz[0] ); + dz2 = sz[ 2 ] - ( S1*sz[1] ); + dz3 = sz[ 3 ] - ( S2*sz[2] ); + dz4 = sz[ 4 ] - ( S3*sz[3] ); + dz5 = sz[ 5 ] - ( S4*sz[4] ); + dz6 = sz[ 6 ] - ( S5*sz[5] ); + dz7 = sz[ 7 ] - ( S6*sz[6] ); + dz8 = sz[ 8 ] - ( S7*sz[7] ); + dw0 = sw[ 0 ]; + dw1 = sw[ 1 ] - ( S0*sw[0] ); + dw2 = sw[ 2 ] - ( S1*sw[1] ); + dw3 = sw[ 3 ] - ( S2*sw[2] ); + dw4 = sw[ 4 ] - ( S3*sw[3] ); + dw5 = sw[ 5 ] - ( S4*sw[4] ); + dw6 = sw[ 6 ] - ( S5*sw[5] ); + dw7 = sw[ 7 ] - ( S6*sw[6] ); + dw8 = sw[ 8 ] - ( S7*sw[7] ); + du0 = su[ 0 ]; + du1 = su[ 1 ] - ( S0*su[0] ); + du2 = su[ 2 ] - ( S1*su[1] ); + du3 = su[ 3 ] - ( S2*su[2] ); + du4 = su[ 4 ] - ( S3*su[3] ); + du5 = su[ 5 ] - ( S4*su[4] ); + du6 = su[ 6 ] - ( S5*su[5] ); + du7 = su[ 7 ] - ( S6*su[6] ); + du8 = su[ 8 ] - ( S7*su[7] ); + } + // Set the pointers to the first indexed elements in the respective ndarrays... + ix = x.offset; + iy = y.offset; + iz = z.offset; + iw = w.offset; + iu = u.offset; + + // Cache references to the input and output ndarray buffers... + xbuf = x.data; + ybuf = y.data; + zbuf = z.data; + wbuf = w.data; + ubuf = u.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++ ) { + ubuf[ iu ] = fcn( xbuf[ ix ], ybuf[ iy ], zbuf[ iz ], wbuf[ iw ] ); // eslint-disable-line max-len + ix += dx0; + iy += dy0; + iz += dz0; + iw += dw0; + iu += du0; + } + ix += dx1; + iy += dy1; + iz += dz1; + iw += dw1; + iu += du1; + } + ix += dx2; + iy += dy2; + iz += dz2; + iw += dw2; + iu += du2; + } + ix += dx3; + iy += dy3; + iz += dz3; + iw += dw3; + iu += du3; + } + ix += dx4; + iy += dy4; + iz += dz4; + iw += dw4; + iu += du4; + } + ix += dx5; + iy += dy5; + iz += dz5; + iw += dw5; + iu += du5; + } + ix += dx6; + iy += dy6; + iz += dz6; + iw += dw6; + iu += du6; + } + ix += dx7; + iy += dy7; + iz += dz7; + iw += dw7; + iu += du7; + } + ix += dx8; + iy += dy8; + iz += dz8; + iw += dw8; + iu += du8; + } +} + + +// EXPORTS // + +module.exports = quaternary9d; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/index.js new file mode 100644 index 000000000000..ac03879d1d4c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/index.js @@ -0,0 +1,137 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Return a kernel for applying a quaternary callback to elements in four input ndarrays and assigning results to elements in an output ndarray. +* +* @module @stdlib/ndarray/base/kernels/generic/quaternary/unblocked +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var kernel = require( '@stdlib/ndarray/base/kernels/generic/quaternary/unblocked' ); +* +* function add4( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 3, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 1 ]; +* var sy = [ 2, 1 ]; +* var sz = [ 2, 1 ]; +* var sw = [ 2, 1 ]; +* var su = [ 2, 1 ]; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': 0, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': 0, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': 0, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* // Resolve a kernel: +* var f = kernel( 2 ); +* +* // Apply the quaternary function: +* f( x, y, z, w, u, true, add4 ); +* +* var v = u.data; +* // returns [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var kernel0d = require( './0d.js' ); +var kernel1d = require( './1d.js' ); +var kernel2d = require( './2d.js' ); +var kernel3d = require( './3d.js' ); +var kernel4d = require( './4d.js' ); +var kernel5d = require( './5d.js' ); +var kernel6d = require( './6d.js' ); +var kernel7d = require( './7d.js' ); +var kernel8d = require( './8d.js' ); +var kernel9d = require( './9d.js' ); +var kernel10d = require( './10d.js' ); +var main = require( './main.js' ); + + +// MAIN // + +setReadOnly( main, 'kernel0d', kernel0d ); +setReadOnly( main, 'kernel1d', kernel1d ); +setReadOnly( main, 'kernel2d', kernel2d ); +setReadOnly( main, 'kernel3d', kernel3d ); +setReadOnly( main, 'kernel4d', kernel4d ); +setReadOnly( main, 'kernel5d', kernel5d ); +setReadOnly( main, 'kernel6d', kernel6d ); +setReadOnly( main, 'kernel7d', kernel7d ); +setReadOnly( main, 'kernel8d', kernel8d ); +setReadOnly( main, 'kernel9d', kernel9d ); +setReadOnly( main, 'kernel10d', kernel10d ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/main.js new file mode 100644 index 000000000000..f96e66765e6b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/main.js @@ -0,0 +1,147 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var kernel0d = require( './0d.js' ); +var kernel1d = require( './1d.js' ); +var kernel2d = require( './2d.js' ); +var kernel3d = require( './3d.js' ); +var kernel4d = require( './4d.js' ); +var kernel5d = require( './5d.js' ); +var kernel6d = require( './6d.js' ); +var kernel7d = require( './7d.js' ); +var kernel8d = require( './8d.js' ); +var kernel9d = require( './9d.js' ); +var kernel10d = require( './10d.js' ); + + +// VARIABLES // + +var KERNELS = [ + kernel0d, + kernel1d, + kernel2d, + kernel3d, + kernel4d, + kernel5d, + kernel6d, + kernel7d, + kernel8d, + kernel9d, + kernel10d +]; +var MAX_DIMS = KERNELS.length - 1; + + +// MAIN // + +/** +* Returns a kernel for applying a quaternary callback to elements in four input ndarrays and assigning results to elements in an output ndarray. +* +* @param {integer} ndims - number of dimensions +* @returns {(Function|null)} kernel function or null +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* function add4( a, b, c, d ) { +* return a + b + c + d; +* } +* +* // Create data buffers: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); +* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* // Define the shape of the input and output arrays: +* var shape = [ 3, 2 ]; +* +* // Define the array strides: +* var sx = [ 2, 1 ]; +* var sy = [ 2, 1 ]; +* var sz = [ 2, 1 ]; +* var sw = [ 2, 1 ]; +* var su = [ 2, 1 ]; +* +* // Create the input and output ndarray-like objects: +* var x = { +* 'dtype': 'float64', +* 'data': xbuf, +* 'shape': shape, +* 'strides': sx, +* 'offset': 0, +* 'order': 'row-major' +* }; +* var y = { +* 'dtype': 'float64', +* 'data': ybuf, +* 'shape': shape, +* 'strides': sy, +* 'offset': 0, +* 'order': 'row-major' +* }; +* var z = { +* 'dtype': 'float64', +* 'data': zbuf, +* 'shape': shape, +* 'strides': sz, +* 'offset': 0, +* 'order': 'row-major' +* }; +* var w = { +* 'dtype': 'float64', +* 'data': wbuf, +* 'shape': shape, +* 'strides': sw, +* 'offset': 0, +* 'order': 'row-major' +* }; +* var u = { +* 'dtype': 'float64', +* 'data': ubuf, +* 'shape': shape, +* 'strides': su, +* 'offset': 0, +* 'order': 'row-major' +* }; +* +* // Resolve a kernel: +* var f = kernel( 2 ); +* +* // Apply the quaternary function: +* f( x, y, z, w, u, true, add4 ); +* +* var v = u.data; +* // returns [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] +*/ +function kernel( ndims ) { + if ( ndims < 0 || ndims > MAX_DIMS ) { + return null; + } + return KERNELS[ ndims ]; +} + + +// EXPORTS // + +module.exports = kernel; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/package.json b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/package.json new file mode 100644 index 000000000000..d1efc1ace4a9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/package.json @@ -0,0 +1,62 @@ +{ + "name": "@stdlib/ndarray/base/kernels/generic/quaternary/unblocked", + "version": "0.0.0", + "description": "Return a kernel for applying a quaternary callback to elements in four input ndarrays and assigning results to elements in an output ndarray.", + "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": { + "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", + "ndarray", + "quaternary", + "apply", + "element-wise", + "elementwise", + "callback", + "kernel" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/test/test.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/test/test.js new file mode 100644 index 000000000000..ac70135cc197 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/test/test.js @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var oneTo = require( '@stdlib/array/one-to' ); +var zeros = require( '@stdlib/array/zeros' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var descriptor = require( '@stdlib/ndarray/base/descriptor' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); +var kernel = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof kernel, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns null if provided an unsupported number of dimensions', function test( t ) { + t.strictEqual( kernel( -1 ), null, 'returns expected value' ); + t.strictEqual( kernel( 11 ), null, 'returns expected value' ); + t.strictEqual( kernel( 100 ), null, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a kernel for applying a quaternary callback (0-dimensional)', function test( t ) { + var expected; + var x; + var u; + var f; + + x = descriptor( 'float64', new Float64Array( [ 5.0 ] ), [], [ 0 ], 0, 'row-major' ); + u = descriptor( 'float64', new Float64Array( [ 0.0 ] ), [], [ 0 ], 0, 'row-major' ); + + f = kernel( 0 ); + f( x, x, x, x, u, add4 ); + + expected = new Float64Array( [ 20.0 ] ); + t.strictEqual( isSameFloat64Array( u.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a kernel for applying a quaternary callback (row-major)', function test( t ) { + var expected; + var shapes; + var sh; + var st; + var x; + var u; + var f; + var i; + + shapes = [ + [ 6 ], + [ 2, 3 ], + [ 2, 1, 3 ], + [ 1, 2, 1, 3 ], + [ 1, 1, 2, 1, 3 ], + [ 1, 1, 1, 2, 1, 3 ], + [ 1, 1, 1, 1, 2, 1, 3 ], + [ 1, 1, 1, 1, 1, 2, 1, 3 ], + [ 1, 1, 1, 1, 1, 1, 2, 1, 3 ], + [ 1, 1, 1, 1, 1, 1, 1, 2, 1, 3 ] + ]; + expected = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0, 24.0 ] ); + + for ( i = 0; i < shapes.length; i++ ) { + sh = shapes[ i ]; + st = shape2strides( sh, 'row-major' ); + + x = descriptor( 'float64', oneTo( numel( sh ), 'float64' ), sh, st, strides2offset( sh, st ), 'row-major' ); + u = descriptor( 'float64', zeros( numel( sh ), 'float64' ), sh, st, strides2offset( sh, st ), 'row-major' ); + + f = kernel( sh.length ); + if ( sh.length <= 1 ) { + f( x, x, x, x, u, add4 ); + } else { + f( x, x, x, x, u, true, add4 ); + } + t.strictEqual( isSameFloat64Array( u.data, expected ), true, 'returns expected value for ' + sh.length + '-dimensional' ); + } + t.end(); +}); + +tape( 'the function returns a kernel for applying a quaternary callback (column-major)', function test( t ) { + var expected; + var shapes; + var sh; + var st; + var x; + var u; + var f; + var i; + + shapes = [ + [ 6 ], + [ 2, 3 ], + [ 2, 1, 3 ], + [ 1, 2, 1, 3 ], + [ 1, 1, 2, 1, 3 ], + [ 1, 1, 1, 2, 1, 3 ], + [ 1, 1, 1, 1, 2, 1, 3 ], + [ 1, 1, 1, 1, 1, 2, 1, 3 ], + [ 1, 1, 1, 1, 1, 1, 2, 1, 3 ], + [ 1, 1, 1, 1, 1, 1, 1, 2, 1, 3 ] + ]; + expected = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0, 24.0 ] ); + + for ( i = 0; i < shapes.length; i++ ) { + sh = shapes[ i ]; + st = shape2strides( sh, 'column-major' ); + + x = descriptor( 'float64', oneTo( numel( sh ), 'float64' ), sh, st, strides2offset( sh, st ), 'column-major' ); + u = descriptor( 'float64', zeros( numel( sh ), 'float64' ), sh, st, strides2offset( sh, st ), 'column-major' ); + + f = kernel( sh.length ); + if ( sh.length <= 1 ) { + f( x, x, x, x, u, add4 ); + } else { + f( x, x, x, x, u, false, add4 ); + } + t.strictEqual( isSameFloat64Array( u.data, expected ), true, 'returns expected value for ' + sh.length + '-dimensional' ); + } + t.end(); +}); From b37426870838fe82b77141c658c360f45cb8df75 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 1 Oct 2026 15:40:40 +0500 Subject: [PATCH 2/7] fix: lint errs --- .../unblocked/benchmark/benchmark.1d.js | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js index 01a9f8929a97..63bd3f3b22be 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js @@ -59,9 +59,23 @@ function createBenchmark( len, shape, xtype, utype, order ) { var u; var f; + x = discreteUniform( len, -100, 100, { + 'dtype': xtype + }); + y = discreteUniform( len, -100, 100, { + 'dtype': xtype + }); + z = discreteUniform( len, -100, 100, { + 'dtype': xtype + }); + w = discreteUniform( len, -100, 100, { + 'dtype': xtype + }); + u = filledarray( 0.0, len, utype ); + x = { 'dtype': xtype, - 'data': discreteUniform( len, -100, 100, { 'dtype': xtype } ), + 'data': x, 'shape': shape, 'strides': shape2strides( shape, order ), 'offset': 0, @@ -69,7 +83,7 @@ function createBenchmark( len, shape, xtype, utype, order ) { }; y = { 'dtype': xtype, - 'data': discreteUniform( len, -100, 100, { 'dtype': xtype } ), + 'data': y, 'shape': shape, 'strides': shape2strides( shape, order ), 'offset': 0, @@ -77,7 +91,7 @@ function createBenchmark( len, shape, xtype, utype, order ) { }; z = { 'dtype': xtype, - 'data': discreteUniform( len, -100, 100, { 'dtype': xtype } ), + 'data': z, 'shape': shape, 'strides': shape2strides( shape, order ), 'offset': 0, @@ -85,7 +99,7 @@ function createBenchmark( len, shape, xtype, utype, order ) { }; w = { 'dtype': xtype, - 'data': discreteUniform( len, -100, 100, { 'dtype': xtype } ), + 'data': w, 'shape': shape, 'strides': shape2strides( shape, order ), 'offset': 0, @@ -93,7 +107,7 @@ function createBenchmark( len, shape, xtype, utype, order ) { }; u = { 'dtype': utype, - 'data': filledarray( 0.0, len, utype ), + 'data': u, 'shape': shape, 'strides': shape2strides( shape, order ), 'offset': 0, From 5c61dc223d43e4cc97b234cfc62aed7972bc6031 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 1 Oct 2026 15:49:49 +0500 Subject: [PATCH 3/7] fix: lint err --- .../base/kernels/generic/quaternary/unblocked/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/package.json b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/package.json index d1efc1ace4a9..31e135bab188 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/package.json +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/package.json @@ -15,6 +15,7 @@ ], "main": "./lib", "directories": { + "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", "lib": "./lib", From 8b7f88498acba8f5ee6ed2a945a70194637a583d Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 2 Oct 2026 22:03:32 +0500 Subject: [PATCH 4/7] fix: apply suggestions from code review --- .../generic/quaternary/unblocked/README.md | 939 +++++++++++++++++- .../unblocked/benchmark/benchmark.1d.js | 74 +- .../unblocked/benchmark/benchmark.2d.js | 74 +- .../quaternary/unblocked/docs/repl.txt | 339 ++++++- .../quaternary/unblocked/examples/index.js | 7 +- .../generic/quaternary/unblocked/lib/0d.js | 24 +- .../generic/quaternary/unblocked/lib/10d.js | 16 +- .../generic/quaternary/unblocked/lib/1d.js | 27 +- .../generic/quaternary/unblocked/lib/2d.js | 24 +- .../generic/quaternary/unblocked/lib/3d.js | 24 +- .../generic/quaternary/unblocked/lib/4d.js | 34 +- .../generic/quaternary/unblocked/lib/5d.js | 16 +- .../generic/quaternary/unblocked/lib/6d.js | 16 +- .../generic/quaternary/unblocked/lib/7d.js | 16 +- .../generic/quaternary/unblocked/lib/8d.js | 16 +- .../generic/quaternary/unblocked/lib/9d.js | 16 +- .../generic/quaternary/unblocked/lib/index.js | 12 +- .../generic/quaternary/unblocked/lib/main.js | 12 +- .../generic/quaternary/unblocked/test/test.js | 14 +- 19 files changed, 1413 insertions(+), 287 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/README.md b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/README.md index daf74ad87636..f8e1c3c03993 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/README.md @@ -42,17 +42,15 @@ Returns a kernel for applying a quaternary callback to elements in four input nd ```javascript var Float64Array = require( '@stdlib/array/float64' ); - -function add4( a, b, c, d ) { - return a + b + c + d; -} +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); // Create data buffers: var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); -var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +var ubuf = new Float64Array( 6 ); // Define the shape of the input and output arrays: var shape = [ 3, 2 ]; @@ -112,8 +110,8 @@ var f = kernel( 2 ); // Apply the quaternary function: f( x, y, z, w, u, true, add4 ); -var v = u.data; -// returns [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] +var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +// returns [ [ 7.0, 8.0 ], [ 9.0, 10.0 ], [ 11.0, 12.0 ] ] ``` The function accepts the following arguments: @@ -127,49 +125,932 @@ var f = kernel( 100000 ); // returns null ``` - +The returned function accepts the following arguments: - +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. -
+The returned function iterates over ndarray elements according to the memory layout of the input ndarray. -## Notes +#### kernel.kernel0d( x, y, z, w, u, isRowMajor, fcn ) -- Each returned kernel expects the following arguments: +Applies a quaternary callback to elements in zero-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. - - **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). - - **y**: second input ndarray descriptor. - - **z**: third input ndarray descriptor. - - **w**: fourth input ndarray descriptor. - - **u**: output ndarray descriptor. - - **isRowMajor**: boolean indicating whether the arrays are in row-major order (required for kernels with two or more dimensions). - - **fcn**: quaternary callback accepting four scalar values and returning one scalar value. +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); -
+// Create data buffers: +var xbuf = new Float64Array( [ 1.0 ] ); +var ybuf = new Float64Array( [ 1.0 ] ); +var zbuf = new Float64Array( [ 1.0 ] ); +var wbuf = new Float64Array( [ 1.0 ] ); +var ubuf = new Float64Array( [ 0.0 ] ); - +// Define the shape of the input and output arrays: +var shape = []; -
+// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 0 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 0 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 0 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 0 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 0 ], + 'offset': 0, + 'order': 'row-major' +}; -## Examples +// Apply the quaternary function: +kernel.kernel0d( x, y, z, w, u, false, add4 ); - +var out = u.data; +// returns [ 4.0 ] +``` + +The function has the following parameters: + +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +#### kernel.kernel1d( x, y, z, w, u, isRowMajor, fcn ) + +Applies a quaternary callback to elements in one-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. ```javascript var Float64Array = require( '@stdlib/array/float64' ); var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); -var kernel = require( '@stdlib/ndarray/base/kernels/generic/quaternary/unblocked' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var ubuf = new Float64Array( 5 ); + +// Define the shape of the input and output arrays: +var shape = [ 5 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Apply the quaternary function: +kernel.kernel1d( x, y, z, w, u, false, add4 ); + +var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +// returns [ 4.0, 5.0, 6.0, 7.0, 8.0 ] +``` + +The function has the following parameters: + +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +#### kernel.kernel2d( x, y, z, w, u, isRowMajor, fcn ) + +Applies a quaternary callback to elements in two-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var ubuf = new Float64Array( 4 ); + +// Define the shape of the input and output arrays: +var shape = [ 2, 2 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Apply the quaternary function: +kernel.kernel2d( x, y, z, w, u, true, add4 ); + +var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +// returns [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ] +``` + +The function has the following parameters: + +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +#### kernel.kernel3d( x, y, z, w, u, isRowMajor, fcn ) + +Applies a quaternary callback to elements in three-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var ubuf = new Float64Array( 8 ); + +// Define the shape of the input and output arrays: +var shape = [ 2, 2, 2 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Apply the quaternary function: +kernel.kernel3d( x, y, z, w, u, true, add4 ); + +var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +// returns [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] +``` + +The function has the following parameters: + +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +#### kernel.kernel4d( x, y, z, w, u, isRowMajor, fcn ) + +Applies a quaternary callback to elements in four-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var ubuf = new Float64Array( 8 ); + +// Define the shape of the input and output arrays: +var shape = [ 1, 2, 2, 2 ]; -function add4( a, b, c, d ) { - return a + b + c + d; -} +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Apply the quaternary function: +kernel.kernel4d( x, y, z, w, u, true, add4 ); + +var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +// returns [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] +``` + +The function has the following parameters: + +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +#### kernel.kernel5d( x, y, z, w, u, isRowMajor, fcn ) + +Applies a quaternary callback to elements in five-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var ubuf = new Float64Array( 8 ); + +// Define the shape of the input and output arrays: +var shape = [ 1, 1, 2, 2, 2 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Apply the quaternary function: +kernel.kernel5d( x, y, z, w, u, true, add4 ); + +var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +// returns [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] +``` + +The function has the following parameters: + +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +#### kernel.kernel6d( x, y, z, w, u, isRowMajor, fcn ) + +Applies a quaternary callback to elements in six-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var ubuf = new Float64Array( 8 ); + +// Define the shape of the input and output arrays: +var shape = [ 1, 1, 1, 2, 2, 2 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Apply the quaternary function: +kernel.kernel6d( x, y, z, w, u, true, add4 ); + +var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +// returns [ [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +#### kernel.kernel7d( x, y, z, w, u, isRowMajor, fcn ) + +Applies a quaternary callback to elements in seven-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var ubuf = new Float64Array( 8 ); + +// Define the shape of the input and output arrays: +var shape = [ 1, 1, 1, 1, 2, 2, 2 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Apply the quaternary function: +kernel.kernel7d( x, y, z, w, u, true, add4 ); + +var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +// returns [ [ [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +#### kernel.kernel8d( x, y, z, w, u, isRowMajor, fcn ) + +Applies a quaternary callback to elements in eight-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var ubuf = new Float64Array( 8 ); + +// Define the shape of the input and output arrays: +var shape = [ 1, 1, 1, 1, 1, 2, 2, 2 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Apply the quaternary function: +kernel.kernel8d( x, y, z, w, u, true, add4 ); + +var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +// returns [ [ [ [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +#### kernel.kernel9d( x, y, z, w, u, isRowMajor, fcn ) + +Applies a quaternary callback to elements in nine-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var ubuf = new Float64Array( 8 ); + +// Define the shape of the input and output arrays: +var shape = [ 1, 1, 1, 1, 1, 1, 2, 2, 2 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Apply the quaternary function: +kernel.kernel9d( x, y, z, w, u, true, add4 ); + +var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +// returns [ [ [ [ [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +#### kernel.kernel10d( x, y, z, w, u, isRowMajor, fcn ) + +Applies a quaternary callback to elements in ten-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); + +// Create data buffers: +var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var ubuf = new Float64Array( 8 ); + +// Define the shape of the input and output arrays: +var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2, 2 ]; + +// Create the input and output ndarray-like objects: +var x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var y = { + 'dtype': 'float64', + 'data': ybuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var z = { + 'dtype': 'float64', + 'data': zbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var w = { + 'dtype': 'float64', + 'data': wbuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; +var u = { + 'dtype': 'float64', + 'data': ubuf, + 'shape': shape, + 'strides': [ 8, 8, 8, 8, 8, 8, 8, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major' +}; + +// Apply the quaternary function: +kernel.kernel10d( x, y, z, w, u, true, add4 ); + +var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +// returns [ [ [ [ [ [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] ] ] ] ] ] +``` + +The function has the following parameters: + +- **x**: first input ndarray descriptor (object with `dtype`, `data`, `shape`, `strides`, `offset`, `order`). +- **y**: second input ndarray descriptor. +- **z**: third input ndarray descriptor. +- **w**: fourth input ndarray descriptor. +- **u**: output ndarray descriptor. +- **isRowMajor**: boolean indicating whether the arrays are in row-major order. +- **fcn**: quaternary callback accepting four scalar values and returning one scalar value. + +
+ + + +
+ +## Notes + +- The quaternary callback is expected to have the following signature: + + ```text + fcn( v1, v2, v3, v4 ) + ``` + + where + + - **v1**: element from the first input ndarray. + - **v2**: element from the second input ndarray. + - **v3**: element from the third input ndarray. + - **v4**: element from the fourth input ndarray. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); +var kernel = require( '@stdlib/ndarray/base/kernels/generic/quaternary/unblocked' ); // Create data buffers: var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); -var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +var ubuf = new Float64Array( 6 ); // Define the array shapes: var shape = [ 3, 2 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js index 63bd3f3b22be..c75e5c6bdbb0 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.1d.js @@ -27,6 +27,9 @@ var pow = require( '@stdlib/math/base/special/pow' ); var filledarray = require( '@stdlib/array/filled' ); var add4 = require( '@stdlib/number/float64/base/add4' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var descriptor = require( '@stdlib/ndarray/base/descriptor' ); var orders = require( '@stdlib/ndarray/orders' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -52,6 +55,9 @@ var ORDERS = orders(); * @returns {Function} benchmark function */ function createBenchmark( len, shape, xtype, utype, order ) { + var isrm; + var opts; + var st; var x; var y; var z; @@ -59,60 +65,24 @@ function createBenchmark( len, shape, xtype, utype, order ) { var u; var f; - x = discreteUniform( len, -100, 100, { + isrm = isRowMajor( order ); + opts = { 'dtype': xtype - }); - y = discreteUniform( len, -100, 100, { - 'dtype': xtype - }); - z = discreteUniform( len, -100, 100, { - 'dtype': xtype - }); - w = discreteUniform( len, -100, 100, { - 'dtype': xtype - }); + }; + st = shape2strides( shape, order ); + + x = discreteUniform( len, -100, 100, opts ); + y = discreteUniform( len, -100, 100, opts ); + z = discreteUniform( len, -100, 100, opts ); + w = discreteUniform( len, -100, 100, opts ); u = filledarray( 0.0, len, utype ); - x = { - 'dtype': xtype, - 'data': x, - 'shape': shape, - 'strides': shape2strides( shape, order ), - 'offset': 0, - 'order': order - }; - y = { - 'dtype': xtype, - 'data': y, - 'shape': shape, - 'strides': shape2strides( shape, order ), - 'offset': 0, - 'order': order - }; - z = { - 'dtype': xtype, - 'data': z, - 'shape': shape, - 'strides': shape2strides( shape, order ), - 'offset': 0, - 'order': order - }; - w = { - 'dtype': xtype, - 'data': w, - 'shape': shape, - 'strides': shape2strides( shape, order ), - 'offset': 0, - 'order': order - }; - u = { - 'dtype': utype, - 'data': u, - 'shape': shape, - 'strides': shape2strides( shape, order ), - 'offset': 0, - 'order': order - }; + x = descriptor( xtype, x, shape, st, strides2offset( shape, st ), order ); + y = descriptor( xtype, y, shape, st, strides2offset( shape, st ), order ); + z = descriptor( xtype, z, shape, st, strides2offset( shape, st ), order ); + w = descriptor( xtype, w, shape, st, strides2offset( shape, st ), order ); + u = descriptor( utype, u, shape, st, strides2offset( shape, st ), order ); + f = kernel( shape.length ); return benchmark; @@ -127,7 +97,7 @@ function createBenchmark( len, shape, xtype, utype, order ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - f( x, y, z, w, u, add4 ); + f( x, y, z, w, u, isrm, add4 ); if ( isnan( u.data[ i%len ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.2d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.2d.js index 173910830b47..a4b92cc0a095 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/benchmark/benchmark.2d.js @@ -21,15 +21,17 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); 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 filledarray = require( '@stdlib/array/filled' ); var add4 = require( '@stdlib/number/float64/base/add4' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var descriptor = require( '@stdlib/ndarray/base/descriptor' ); var orders = require( '@stdlib/ndarray/orders' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -56,6 +58,8 @@ var ORDERS = orders(); */ function createBenchmark( len, shape, xtype, utype, order ) { var isrm; + var opts; + var st; var x; var y; var z; @@ -64,61 +68,23 @@ function createBenchmark( len, shape, xtype, utype, order ) { var f; isrm = isRowMajor( order ); - - x = discreteUniform( len, -100, 100, { - 'dtype': xtype - }); - y = discreteUniform( len, -100, 100, { - 'dtype': xtype - }); - z = discreteUniform( len, -100, 100, { - 'dtype': xtype - }); - w = discreteUniform( len, -100, 100, { + opts = { 'dtype': xtype - }); + }; + st = shape2strides( shape, order ); + + x = discreteUniform( len, -100, 100, opts ); + y = discreteUniform( len, -100, 100, opts ); + z = discreteUniform( len, -100, 100, opts ); + w = discreteUniform( len, -100, 100, opts ); u = filledarray( 0.0, len, utype ); - x = { - 'dtype': xtype, - 'data': x, - 'shape': shape, - 'strides': shape2strides( shape, order ), - 'offset': 0, - 'order': order - }; - y = { - 'dtype': xtype, - 'data': y, - 'shape': shape, - 'strides': shape2strides( shape, order ), - 'offset': 0, - 'order': order - }; - z = { - 'dtype': xtype, - 'data': z, - 'shape': shape, - 'strides': shape2strides( shape, order ), - 'offset': 0, - 'order': order - }; - w = { - 'dtype': xtype, - 'data': w, - 'shape': shape, - 'strides': shape2strides( shape, order ), - 'offset': 0, - 'order': order - }; - u = { - 'dtype': utype, - 'data': u, - 'shape': shape, - 'strides': shape2strides( shape, order ), - 'offset': 0, - 'order': order - }; + x = descriptor( xtype, x, shape, st, strides2offset( shape, st ), order ); + y = descriptor( xtype, y, shape, st, strides2offset( shape, st ), order ); + z = descriptor( xtype, z, shape, st, strides2offset( shape, st ), order ); + w = descriptor( xtype, w, shape, st, strides2offset( shape, st ), order ); + u = descriptor( utype, u, shape, st, strides2offset( shape, st ), order ); + f = kernel( shape.length ); return benchmark; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt index aee4812d3e84..4a8a8ca3b532 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt @@ -3,6 +3,19 @@ Returns a kernel for applying a quaternary callback to elements in four input ndarrays and assigning results to elements in an output ndarray. + The returned function has the following parameters: + + - x: first input ndarray descriptor (object with `dtype`, `data`, + `shape`, `strides`, `offset`, `order`). + - y: second input ndarray descriptor. + - z: third input ndarray descriptor. + - w: fourth input ndarray descriptor. + - u: output ndarray descriptor. + - isRowMajor: boolean indicating whether the arrays are in row-major + order. + - fcn: quaternary callback accepting four scalar values and returning one + scalar value. + If `ndims` is greater than the maximum supported number of dimensions, the function returns `null`. @@ -21,6 +34,330 @@ > var f = {{alias}}( 2 ) + +{{alias}}.kernel0d( x, y, z, w, u, isRowMajor, fcn ) + Applies a quaternary callback to elements in zero-dimensional input + ndarrays and assigns results to elements in an equivalently shaped + output ndarray. + + The `isRowMajor` parameter is unused. Providing a placeholder for this + parameter is recommended in order to ensure a monomorphic API. + + Parameters + ---------- + x: Object + First input ndarray descriptor. + + y: Object + Second input ndarray descriptor. + + z: Object + Third input ndarray descriptor. + + w: Object + Fourth input ndarray descriptor. + + u: Object + Output ndarray descriptor. + + isRowMajor: boolean + Boolean indicating whether the arrays are in row-major order. + + fcn: Function + Quaternary callback. + + +{{alias}}.kernel1d( x, y, z, w, u, isRowMajor, fcn ) + Applies a quaternary callback to elements in one-dimensional input + ndarrays and assigns results to elements in an equivalently shaped + output ndarray. + + The `isRowMajor` parameter is unused. Providing a placeholder for this + parameter is recommended in order to ensure a monomorphic API. + + Parameters + ---------- + x: Object + First input ndarray descriptor. + + y: Object + Second input ndarray descriptor. + + z: Object + Third input ndarray descriptor. + + w: Object + Fourth input ndarray descriptor. + + u: Object + Output ndarray descriptor. + + isRowMajor: boolean + Boolean indicating whether the arrays are in row-major order. + + fcn: Function + Quaternary callback. + + +{{alias}}.kernel2d( x, y, z, w, u, isRowMajor, fcn ) + Applies a quaternary callback to elements in two-dimensional input + ndarrays and assigns results to elements in an equivalently shaped + output ndarray. + + Parameters + ---------- + x: Object + First input ndarray descriptor. + + y: Object + Second input ndarray descriptor. + + z: Object + Third input ndarray descriptor. + + w: Object + Fourth input ndarray descriptor. + + u: Object + Output ndarray descriptor. + + isRowMajor: boolean + Boolean indicating whether the arrays are in row-major order. + + fcn: Function + Quaternary callback. + + +{{alias}}.kernel3d( x, y, z, w, u, isRowMajor, fcn ) + Applies a quaternary callback to elements in three-dimensional input + ndarrays and assigns results to elements in an equivalently shaped + output ndarray. + + Parameters + ---------- + x: Object + First input ndarray descriptor. + + y: Object + Second input ndarray descriptor. + + z: Object + Third input ndarray descriptor. + + w: Object + Fourth input ndarray descriptor. + + u: Object + Output ndarray descriptor. + + isRowMajor: boolean + Boolean indicating whether the arrays are in row-major order. + + fcn: Function + Quaternary callback. + + +{{alias}}.kernel4d( x, y, z, w, u, isRowMajor, fcn ) + Applies a quaternary callback to elements in four-dimensional input + ndarrays and assigns results to elements in an equivalently shaped + output ndarray. + + Parameters + ---------- + x: Object + First input ndarray descriptor. + + y: Object + Second input ndarray descriptor. + + z: Object + Third input ndarray descriptor. + + w: Object + Fourth input ndarray descriptor. + + u: Object + Output ndarray descriptor. + + isRowMajor: boolean + Boolean indicating whether the arrays are in row-major order. + + fcn: Function + Quaternary callback. + + +{{alias}}.kernel5d( x, y, z, w, u, isRowMajor, fcn ) + Applies a quaternary callback to elements in five-dimensional input + ndarrays and assigns results to elements in an equivalently shaped + output ndarray. + + Parameters + ---------- + x: Object + First input ndarray descriptor. + + y: Object + Second input ndarray descriptor. + + z: Object + Third input ndarray descriptor. + + w: Object + Fourth input ndarray descriptor. + + u: Object + Output ndarray descriptor. + + isRowMajor: boolean + Boolean indicating whether the arrays are in row-major order. + + fcn: Function + Quaternary callback. + + +{{alias}}.kernel6d( x, y, z, w, u, isRowMajor, fcn ) + Applies a quaternary callback to elements in six-dimensional input + ndarrays and assigns results to elements in an equivalently shaped + output ndarray. + + Parameters + ---------- + x: Object + First input ndarray descriptor. + + y: Object + Second input ndarray descriptor. + + z: Object + Third input ndarray descriptor. + + w: Object + Fourth input ndarray descriptor. + + u: Object + Output ndarray descriptor. + + isRowMajor: boolean + Boolean indicating whether the arrays are in row-major order. + + fcn: Function + Quaternary callback. + + +{{alias}}.kernel7d( x, y, z, w, u, isRowMajor, fcn ) + Applies a quaternary callback to elements in seven-dimensional input + ndarrays and assigns results to elements in an equivalently shaped + output ndarray. + + Parameters + ---------- + x: Object + First input ndarray descriptor. + + y: Object + Second input ndarray descriptor. + + z: Object + Third input ndarray descriptor. + + w: Object + Fourth input ndarray descriptor. + + u: Object + Output ndarray descriptor. + + isRowMajor: boolean + Boolean indicating whether the arrays are in row-major order. + + fcn: Function + Quaternary callback. + + +{{alias}}.kernel8d( x, y, z, w, u, isRowMajor, fcn ) + Applies a quaternary callback to elements in eight-dimensional input + ndarrays and assigns results to elements in an equivalently shaped + output ndarray. + + Parameters + ---------- + x: Object + First input ndarray descriptor. + + y: Object + Second input ndarray descriptor. + + z: Object + Third input ndarray descriptor. + + w: Object + Fourth input ndarray descriptor. + + u: Object + Output ndarray descriptor. + + isRowMajor: boolean + Boolean indicating whether the arrays are in row-major order. + + fcn: Function + Quaternary callback. + + +{{alias}}.kernel9d( x, y, z, w, u, isRowMajor, fcn ) + Applies a quaternary callback to elements in nine-dimensional input + ndarrays and assigns results to elements in an equivalently shaped + output ndarray. + + Parameters + ---------- + x: Object + First input ndarray descriptor. + + y: Object + Second input ndarray descriptor. + + z: Object + Third input ndarray descriptor. + + w: Object + Fourth input ndarray descriptor. + + u: Object + Output ndarray descriptor. + + isRowMajor: boolean + Boolean indicating whether the arrays are in row-major order. + + fcn: Function + Quaternary callback. + + +{{alias}}.kernel10d( x, y, z, w, u, isRowMajor, fcn ) + Applies a quaternary callback to elements in ten-dimensional input + ndarrays and assigns results to elements in an equivalently shaped + output ndarray. + + Parameters + ---------- + x: Object + First input ndarray descriptor. + + y: Object + Second input ndarray descriptor. + + z: Object + Third input ndarray descriptor. + + w: Object + Fourth input ndarray descriptor. + + u: Object + Output ndarray descriptor. + + isRowMajor: boolean + Boolean indicating whether the arrays are in row-major order. + + fcn: Function + Quaternary callback. + See Also -------- - diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/examples/index.js index 83c4ac32821e..538636493889 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/examples/index.js @@ -20,18 +20,15 @@ var Float64Array = require( '@stdlib/array/float64' ); var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var add4 = require( '@stdlib/number/float64/base/add4' ); var kernel = require( './../lib' ); -function add4( a, b, c, d ) { - return a + b + c + d; -} - // Create data buffers: var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); -var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +var ubuf = new Float64Array( 6 ); // Define the array shapes: var shape = [ 3, 2 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/0d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/0d.js index afd67a473533..fee5cccdf99c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/0d.js @@ -23,6 +23,10 @@ /** * Applies a quaternary callback to elements in zero-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. * +* ## Notes +* +* - The `isRowMajor` parameter is unused. Providing a placeholder for this parameter is recommended in order to ensure a monomorphic API. +* * @private * @param {Object} x - object containing input ndarray meta data * @param {*} x.dtype - data type @@ -59,21 +63,19 @@ * @param {IntegerArray} u.strides - stride lengths * @param {NonNegativeInteger} u.offset - index offset * @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order * @param {Callback} fcn - quaternary callback * @returns {void} * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn( a, b, c, d ) { -* return a + b + c + d; -* } +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0 ] ); -* var ybuf = new Float64Array( [ 2.0 ] ); -* var zbuf = new Float64Array( [ 3.0 ] ); -* var wbuf = new Float64Array( [ 4.0 ] ); +* var ybuf = new Float64Array( [ 1.0 ] ); +* var zbuf = new Float64Array( [ 1.0 ] ); +* var wbuf = new Float64Array( [ 1.0 ] ); * var ubuf = new Float64Array( [ 0.0 ] ); * * // Define the shape of the input and output arrays: @@ -136,12 +138,12 @@ * }; * * // Apply the quaternary function: -* quaternary0d( x, y, z, w, u, fcn ); +* quaternary0d( x, y, z, w, u, false, add4 ); * -* console.log( u.data ); -* // => [ 10.0 ] +* var out = u.data; +* // returns [ 4.0 ] */ -function quaternary0d( x, y, z, w, u, fcn ) { +function quaternary0d( x, y, z, w, u, isRowMajor, fcn ) { u.data[ u.offset ] = fcn( x.data[ x.offset ], y.data[ y.offset ], z.data[ z.offset ], w.data[ w.offset ] ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/10d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/10d.js index 0b20819cc841..3aebe64cc7c1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/10d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/10d.js @@ -67,16 +67,14 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn( a, b, c, d ) { -* return a + b + c + d; -* } +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); * var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); -* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); -* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); * var ubuf = new Float64Array( 8 ); * * // Define the shape of the input and output arrays: @@ -139,10 +137,10 @@ * }; * * // Apply the quaternary function: -* quaternary10d( x, y, z, w, u, true, fcn ); +* quaternary10d( x, y, z, w, u, true, add4 ); * -* console.log( u.data ); -* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ [ [ [ [ [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] ] ] ] ] ] */ function quaternary10d( x, y, z, w, u, isRowMajor, fcn ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/1d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/1d.js index e556fced5cb4..260b02c71530 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/1d.js @@ -23,6 +23,10 @@ /** * Applies a quaternary callback to elements in one-dimensional input ndarrays and assigns results to elements in an equivalently shaped output ndarray. * +* ## Notes +* +* - The `isRowMajor` parameter is unused. Providing a placeholder for this parameter is recommended in order to ensure a monomorphic API. +* * @private * @param {Object} x - object containing input ndarray meta data * @param {*} x.dtype - data type @@ -59,22 +63,21 @@ * @param {IntegerArray} u.strides - stride lengths * @param {NonNegativeInteger} u.offset - index offset * @param {string} u.order - specifies whether `u` is row-major (C-style) or column-major (Fortran-style) +* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order * @param {Callback} fcn - quaternary callback * @returns {void} * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn( a, b, c, d ) { -* return a + b + c + d; -* } +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); * var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); -* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0 ] ); -* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0 ] ); -* var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var ubuf = new Float64Array( 5 ); * * // Define the shape of the input and output arrays: * var shape = [ 5 ]; @@ -136,12 +139,12 @@ * }; * * // Apply the quaternary function: -* quaternary1d( x, y, z, w, u, fcn ); +* quaternary1d( x, y, z, w, u, false, add4 ); * -* console.log( u.data ); -* // => [ 7.0, 8.0, 9.0, 10.0, 11.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ 4.0, 5.0, 6.0, 7.0, 8.0 ] */ -function quaternary1d( x, y, z, w, u, fcn ) { +function quaternary1d( x, y, z, w, u, isRowMajor, fcn ) { var xbuf; var ybuf; var zbuf; @@ -160,7 +163,7 @@ function quaternary1d( x, y, z, w, u, fcn ) { var iu; var i; - // Note on variable naming convention: S#, where # corresponds to the loop number, with `0` being the innermost loop... + // Note on variable naming convention: S#, dx#, dy#, dz#, dw#, du#, 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 ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/2d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/2d.js index 14a6cf584e30..f049f213f378 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/2d.js @@ -65,20 +65,18 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn( a, b, c, d ) { -* return a + b + c + d; -* } +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // Create data buffers: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); -* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); -* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); -* var ubuf = new Float64Array( 6 ); +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +* var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +* var ubuf = new Float64Array( 4 ); * * // Define the shape of the input and output arrays: -* var shape = [ 3, 2 ]; +* var shape = [ 2, 2 ]; * * // Define the array strides: * var sx = [ 2, 1 ]; @@ -137,10 +135,10 @@ * }; * * // Apply the quaternary function: -* quaternary2d( x, y, z, w, u, true, fcn ); +* quaternary2d( x, y, z, w, u, true, add4 ); * -* console.log( u.data ); -* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ] */ function quaternary2d( x, y, z, w, u, isRowMajor, fcn ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/3d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/3d.js index 814dc598af0d..2b88d9ada390 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/3d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/3d.js @@ -67,20 +67,18 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn( a, b, c, d ) { -* return a + b + c + d; -* } +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // 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 ] ); -* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); -* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); -* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); -* var ubuf = new Float64Array( 12 ); +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var ubuf = new Float64Array( 8 ); * * // Define the shape of the input and output arrays: -* var shape = [ 3, 2, 2 ]; +* var shape = [ 2, 2, 2 ]; * * // Define the array strides: * var sx = [ 4, 2, 1 ]; @@ -139,10 +137,10 @@ * }; * * // Apply the quaternary function: -* quaternary3d( x, y, z, w, u, true, fcn ); +* quaternary3d( x, y, z, w, u, true, add4 ); * -* console.log( u.data ); -* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] */ function quaternary3d( x, y, z, w, u, isRowMajor, fcn ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/4d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/4d.js index d9a523067ef0..d4f81b802dfd 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/4d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/4d.js @@ -67,27 +67,25 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn( a, b, c, d ) { -* return a + b + c + d; -* } +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // 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 ] ); -* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); -* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); -* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); -* var ubuf = new Float64Array( 12 ); +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var ubuf = new Float64Array( 8 ); * * // Define the shape of the input and output arrays: -* var shape = [ 1, 3, 2, 2 ]; +* var shape = [ 1, 2, 2, 2 ]; * * // Define the array strides: -* var sx = [ 12, 4, 2, 1 ]; -* var sy = [ 12, 4, 2, 1 ]; -* var sz = [ 12, 4, 2, 1 ]; -* var sw = [ 12, 4, 2, 1 ]; -* var su = [ 12, 4, 2, 1 ]; +* var sx = [ 8, 4, 2, 1 ]; +* var sy = [ 8, 4, 2, 1 ]; +* var sz = [ 8, 4, 2, 1 ]; +* var sw = [ 8, 4, 2, 1 ]; +* var su = [ 8, 4, 2, 1 ]; * * // Define the index offsets: * var ox = 0; @@ -139,10 +137,10 @@ * }; * * // Apply the quaternary function: -* quaternary4d( x, y, z, w, u, true, fcn ); +* quaternary4d( x, y, z, w, u, true, add4 ); * -* console.log( u.data ); -* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] */ function quaternary4d( x, y, z, w, u, isRowMajor, fcn ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/5d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/5d.js index 983cf598aeb5..4afccde07531 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/5d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/5d.js @@ -67,16 +67,14 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn( a, b, c, d ) { -* return a + b + c + d; -* } +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); * var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); -* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); -* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); * var ubuf = new Float64Array( 8 ); * * // Define the shape of the input and output arrays: @@ -139,10 +137,10 @@ * }; * * // Apply the quaternary function: -* quaternary5d( x, y, z, w, u, true, fcn ); +* quaternary5d( x, y, z, w, u, true, add4 ); * -* console.log( u.data ); -* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] */ function quaternary5d( x, y, z, w, u, isRowMajor, fcn ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/6d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/6d.js index dcbb9b28b539..bf864edcfff3 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/6d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/6d.js @@ -67,16 +67,14 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn( a, b, c, d ) { -* return a + b + c + d; -* } +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); * var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); -* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); -* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); * var ubuf = new Float64Array( 8 ); * * // Define the shape of the input and output arrays: @@ -139,10 +137,10 @@ * }; * * // Apply the quaternary function: -* quaternary6d( x, y, z, w, u, true, fcn ); +* quaternary6d( x, y, z, w, u, true, add4 ); * -* console.log( u.data ); -* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] ] */ function quaternary6d( x, y, z, w, u, isRowMajor, fcn ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/7d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/7d.js index 9909f377e8a0..170c6eca733f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/7d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/7d.js @@ -67,16 +67,14 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn( a, b, c, d ) { -* return a + b + c + d; -* } +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); * var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); -* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); -* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); * var ubuf = new Float64Array( 8 ); * * // Define the shape of the input and output arrays: @@ -139,10 +137,10 @@ * }; * * // Apply the quaternary function: -* quaternary7d( x, y, z, w, u, true, fcn ); +* quaternary7d( x, y, z, w, u, true, add4 ); * -* console.log( u.data ); -* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ [ [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] ] ] */ function quaternary7d( x, y, z, w, u, isRowMajor, fcn ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/8d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/8d.js index 4c0fdf662bee..fc01d23ef084 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/8d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/8d.js @@ -67,16 +67,14 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn( a, b, c, d ) { -* return a + b + c + d; -* } +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); * var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); -* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); -* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); * var ubuf = new Float64Array( 8 ); * * // Define the shape of the input and output arrays: @@ -139,10 +137,10 @@ * }; * * // Apply the quaternary function: -* quaternary8d( x, y, z, w, u, true, fcn ); +* quaternary8d( x, y, z, w, u, true, add4 ); * -* console.log( u.data ); -* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ [ [ [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] ] ] ] */ function quaternary8d( x, y, z, w, u, isRowMajor, fcn ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/9d.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/9d.js index 61f0b70f4a74..a5da7d7a21ce 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/9d.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/9d.js @@ -67,16 +67,14 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn( a, b, c, d ) { -* return a + b + c + d; -* } +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); * var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); -* var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); -* var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); +* var zbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var wbuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); * var ubuf = new Float64Array( 8 ); * * // Define the shape of the input and output arrays: @@ -139,10 +137,10 @@ * }; * * // Apply the quaternary function: -* quaternary9d( x, y, z, w, u, true, fcn ); +* quaternary9d( x, y, z, w, u, true, add4 ); * -* console.log( u.data ); -* // => [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ [ [ [ [ [ [ [ [ 4.0, 5.0 ], [ 6.0, 7.0 ] ], [ [ 8.0, 9.0 ], [ 10.0, 11.0 ] ] ] ] ] ] ] ] ] */ function quaternary9d( x, y, z, w, u, isRowMajor, fcn ) { var xbuf; diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/index.js index ac03879d1d4c..b1224f882744 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/index.js @@ -25,18 +25,16 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * var kernel = require( '@stdlib/ndarray/base/kernels/generic/quaternary/unblocked' ); * -* function add4( a, b, c, d ) { -* return a + b + c + d; -* } -* * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); * var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); * var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); -* var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* var ubuf = new Float64Array( 6 ); * * // Define the shape of the input and output arrays: * var shape = [ 3, 2 ]; @@ -96,8 +94,8 @@ * // Apply the quaternary function: * f( x, y, z, w, u, true, add4 ); * -* var v = u.data; -* // returns [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ [ 7.0, 8.0 ], [ 9.0, 10.0 ], [ 11.0, 12.0 ] ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/main.js index f96e66765e6b..b22567722a4a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/lib/main.js @@ -61,17 +61,15 @@ var MAX_DIMS = KERNELS.length - 1; * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* -* function add4( a, b, c, d ) { -* return a + b + c + d; -* } +* var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +* var add4 = require( '@stdlib/number/float64/base/add4' ); * * // Create data buffers: * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var ybuf = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); * var zbuf = new Float64Array( [ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); * var wbuf = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] ); -* var ubuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* var ubuf = new Float64Array( 6 ); * * // Define the shape of the input and output arrays: * var shape = [ 3, 2 ]; @@ -131,8 +129,8 @@ var MAX_DIMS = KERNELS.length - 1; * // Apply the quaternary function: * f( x, y, z, w, u, true, add4 ); * -* var v = u.data; -* // returns [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] +* var arr = ndarray2array( u.data, u.shape, u.strides, u.offset, u.order ); +* // returns [ [ 7.0, 8.0 ], [ 9.0, 10.0 ], [ 11.0, 12.0 ] ] */ function kernel( ndims ) { if ( ndims < 0 || ndims > MAX_DIMS ) { diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/test/test.js b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/test/test.js index ac70135cc197..2354601bd010 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/test/test.js @@ -58,7 +58,7 @@ tape( 'the function returns a kernel for applying a quaternary callback (0-dimen u = descriptor( 'float64', new Float64Array( [ 0.0 ] ), [], [ 0 ], 0, 'row-major' ); f = kernel( 0 ); - f( x, x, x, x, u, add4 ); + f( x, x, x, x, u, false, add4 ); expected = new Float64Array( [ 20.0 ] ); t.strictEqual( isSameFloat64Array( u.data, expected ), true, 'returns expected value' ); @@ -97,11 +97,7 @@ tape( 'the function returns a kernel for applying a quaternary callback (row-maj u = descriptor( 'float64', zeros( numel( sh ), 'float64' ), sh, st, strides2offset( sh, st ), 'row-major' ); f = kernel( sh.length ); - if ( sh.length <= 1 ) { - f( x, x, x, x, u, add4 ); - } else { - f( x, x, x, x, u, true, add4 ); - } + f( x, x, x, x, u, true, add4 ); t.strictEqual( isSameFloat64Array( u.data, expected ), true, 'returns expected value for ' + sh.length + '-dimensional' ); } t.end(); @@ -139,11 +135,7 @@ tape( 'the function returns a kernel for applying a quaternary callback (column- u = descriptor( 'float64', zeros( numel( sh ), 'float64' ), sh, st, strides2offset( sh, st ), 'column-major' ); f = kernel( sh.length ); - if ( sh.length <= 1 ) { - f( x, x, x, x, u, add4 ); - } else { - f( x, x, x, x, u, false, add4 ); - } + f( x, x, x, x, u, false, add4 ); t.strictEqual( isSameFloat64Array( u.data, expected ), true, 'returns expected value for ' + sh.length + '-dimensional' ); } t.end(); From 9192550876126336fc63139e9b69553ece382c3b Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sat, 3 Oct 2026 11:11:24 +0500 Subject: [PATCH 5/7] fix: repl --- .../quaternary/unblocked/docs/repl.txt | 66 ++++++++----------- 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt index 4a8a8ca3b532..98aa7ffd44da 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt @@ -5,19 +5,18 @@ The returned function has the following parameters: - - x: first input ndarray descriptor (object with `dtype`, `data`, - `shape`, `strides`, `offset`, `order`). + - x: first input ndarray descriptor (object with `dtype`, `data`, `shape`, + `strides`, `offset`, `order`). - y: second input ndarray descriptor. - z: third input ndarray descriptor. - w: fourth input ndarray descriptor. - u: output ndarray descriptor. - - isRowMajor: boolean indicating whether the arrays are in row-major - order. + - isRowMajor: boolean indicating whether the arrays are in row-major order. - fcn: quaternary callback accepting four scalar values and returning one scalar value. - If `ndims` is greater than the maximum supported number of dimensions, - the function returns `null`. + If `ndims` is greater than the maximum supported number of dimensions, the + function returns `null`. Parameters ---------- @@ -36,9 +35,8 @@ {{alias}}.kernel0d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in zero-dimensional input - ndarrays and assigns results to elements in an equivalently shaped - output ndarray. + Applies a quaternary callback to elements in zero-dimensional input ndarrays + and assigns results to elements in an equivalently shaped output ndarray. The `isRowMajor` parameter is unused. Providing a placeholder for this parameter is recommended in order to ensure a monomorphic API. @@ -68,9 +66,8 @@ {{alias}}.kernel1d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in one-dimensional input - ndarrays and assigns results to elements in an equivalently shaped - output ndarray. + Applies a quaternary callback to elements in one-dimensional input ndarrays + and assigns results to elements in an equivalently shaped output ndarray. The `isRowMajor` parameter is unused. Providing a placeholder for this parameter is recommended in order to ensure a monomorphic API. @@ -100,9 +97,8 @@ {{alias}}.kernel2d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in two-dimensional input - ndarrays and assigns results to elements in an equivalently shaped - output ndarray. + Applies a quaternary callback to elements in two-dimensional input ndarrays + and assigns results to elements in an equivalently shaped output ndarray. Parameters ---------- @@ -129,9 +125,8 @@ {{alias}}.kernel3d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in three-dimensional input - ndarrays and assigns results to elements in an equivalently shaped - output ndarray. + Applies a quaternary callback to elements in three-dimensional input ndarrays + and assigns results to elements in an equivalently shaped output ndarray. Parameters ---------- @@ -158,9 +153,8 @@ {{alias}}.kernel4d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in four-dimensional input - ndarrays and assigns results to elements in an equivalently shaped - output ndarray. + Applies a quaternary callback to elements in four-dimensional input ndarrays + and assigns results to elements in an equivalently shaped output ndarray. Parameters ---------- @@ -187,9 +181,8 @@ {{alias}}.kernel5d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in five-dimensional input - ndarrays and assigns results to elements in an equivalently shaped - output ndarray. + Applies a quaternary callback to elements in five-dimensional input ndarrays + and assigns results to elements in an equivalently shaped output ndarray. Parameters ---------- @@ -216,9 +209,8 @@ {{alias}}.kernel6d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in six-dimensional input - ndarrays and assigns results to elements in an equivalently shaped - output ndarray. + Applies a quaternary callback to elements in six-dimensional input ndarrays + and assigns results to elements in an equivalently shaped output ndarray. Parameters ---------- @@ -245,9 +237,8 @@ {{alias}}.kernel7d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in seven-dimensional input - ndarrays and assigns results to elements in an equivalently shaped - output ndarray. + Applies a quaternary callback to elements in seven-dimensional input ndarrays + and assigns results to elements in an equivalently shaped output ndarray. Parameters ---------- @@ -274,9 +265,8 @@ {{alias}}.kernel8d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in eight-dimensional input - ndarrays and assigns results to elements in an equivalently shaped - output ndarray. + Applies a quaternary callback to elements in eight-dimensional input ndarrays + and assigns results to elements in an equivalently shaped output ndarray. Parameters ---------- @@ -303,9 +293,8 @@ {{alias}}.kernel9d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in nine-dimensional input - ndarrays and assigns results to elements in an equivalently shaped - output ndarray. + Applies a quaternary callback to elements in nine-dimensional input ndarrays + and assigns results to elements in an equivalently shaped output ndarray. Parameters ---------- @@ -332,9 +321,8 @@ {{alias}}.kernel10d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in ten-dimensional input - ndarrays and assigns results to elements in an equivalently shaped - output ndarray. + Applies a quaternary callback to elements in ten-dimensional input ndarrays + and assigns results to elements in an equivalently shaped output ndarray. Parameters ---------- From f35f029e183366fc128a4d785cab5678cce4dd87 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sat, 3 Oct 2026 11:17:02 +0500 Subject: [PATCH 6/7] fix: lint err --- .../kernels/generic/quaternary/unblocked/docs/repl.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt index 98aa7ffd44da..d39e38bab0ce 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt @@ -237,8 +237,9 @@ {{alias}}.kernel7d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in seven-dimensional input ndarrays - and assigns results to elements in an equivalently shaped output ndarray. + Applies a quaternary callback to elements in seven-dimensional input + ndarrays and assigns results to elements in an equivalently shaped output + ndarray. Parameters ---------- @@ -265,8 +266,9 @@ {{alias}}.kernel8d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in eight-dimensional input ndarrays - and assigns results to elements in an equivalently shaped output ndarray. + Applies a quaternary callback to elements in eight-dimensional input + ndarrays and assigns results to elements in an equivalently shaped output + ndarray. Parameters ---------- From 789866cf74bea91c16093668e1425454bbda2be5 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sat, 3 Oct 2026 11:21:09 +0500 Subject: [PATCH 7/7] fix: lint err --- .../base/kernels/generic/quaternary/unblocked/docs/repl.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt index d39e38bab0ce..b534d7904ed4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/kernels/generic/quaternary/unblocked/docs/repl.txt @@ -125,8 +125,9 @@ {{alias}}.kernel3d( x, y, z, w, u, isRowMajor, fcn ) - Applies a quaternary callback to elements in three-dimensional input ndarrays - and assigns results to elements in an equivalently shaped output ndarray. + Applies a quaternary callback to elements in three-dimensional input + ndarrays and assigns results to elements in an equivalently shaped output + ndarray. Parameters ----------